1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright (c) 1999, 2001 by Sun Microsystems, Inc. 26 * All rights reserved. 27 * 28 */ 29 30 // SCCS Status: %W% %G% 31 // SSrvReg.java: Message class for SLP service registration request. 32 // Author: James Kempf 33 // Created On: Thu Oct 9 14:47:48 1997 34 // Last Modified By: Jason Goldschmidt 35 // Last Modified On: Thu Apr 5 14:46:29 2001 36 // Update Count: 107 37 // 38 39 package com.sun.slp; 40 41 import java.util.*; 42 import java.io.*; 43 44 45 /** 46 * The SSrvReg class models the server side SLP service registration. The 47 * default class does SLPv2 regs, but subclasses can do other versions 48 * by redefining the initialize() and makeReply() messages. 49 * 50 * @version %R%.%L% %D% 51 * @author James Kempf 52 */ 53 54 class SSrvReg extends SrvLocMsgImpl { 55 56 ServiceURL URL = null; // the service URL. 57 String serviceType = ""; // service type. 58 Vector attrList = new Vector(); // ServiceLocationAttribute objects. 59 Hashtable URLSignature = null; // signature for URL. 60 Hashtable attrSignature = null; // the signatures for the attributes. 61 62 // Construct a SSrvReg from the input stream. 63 64 SSrvReg(SrvLocHeader hdr, DataInputStream dis) 65 throws ServiceLocationException, IOException { 66 67 super(hdr, SrvLocHeader.SrvReg); 68 69 this.initialize(dis); 70 71 } 72 73 // Initialize the object from the input stream. 74 75 void initialize(DataInputStream dis) 76 throws ServiceLocationException, IOException { 77 78 SLPServerHeaderV2 hdr = (SLPServerHeaderV2)getHeader(); 79 StringBuffer buf = new StringBuffer(); 80 81 // Parse in the service URL 82 83 Hashtable table = new Hashtable(); 84 85 URL = 86 hdr.parseServiceURLIn(dis, 87 table, 88 ServiceLocationException.INVALID_REGISTRATION); 89 90 URLSignature = (Hashtable)table.get(URL); 91 92 // Parse in service type name. 93 94 hdr.getString(buf, dis); 95 96 // Validate and set URL type. 97 98 ServiceType t = new ServiceType(buf.toString()); 99 100 if (!(URL.getServiceType()).isServiceURL() && 101 !t.equals(URL.getServiceType())) { 102 URL.setServiceType(t); 103 104 } 105 106 // Parse in the scope list. 107 108 hdr.parseScopesIn(dis); 109 110 // Parse in the attribute list. 111 112 attrSignature = 113 hdr.parseAuthenticatedAttributeVectorIn(attrList, dis, false); 114 115 hdr.constructDescription("SrvReg", 116 " URL=``" + 117 URL + "''\n" + 118 " service type=``" + 119 serviceType + "''\n" + 120 " attribute list=``" + 121 attrList + "''\n" + 122 " URL signature=" + 123 AuthBlock.desc(URLSignature) + "\n" + 124 " attribute signature=" + 125 AuthBlock.desc(attrSignature) + "\n"); 126 } 127 128 // Return a SrvAck. We ignore the existing flag, since in V2, fresh comes 129 // in. In this case, all we need to do is clone the header. 130 131 SrvLocMsg makeReply(boolean existing) { 132 133 SLPServerHeaderV2 hdr = 134 ((SLPServerHeaderV2)getHeader()).makeReplyHeader(); 135 136 // Construct description. 137 138 hdr.constructDescription("SrvAck", ""); 139 140 return hdr; 141 142 } 143 } 144