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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 1999 by Sun Microsystems, Inc. 23 * All rights reserved. 24 * 25 */ 26 27 // SSrvDereg.java: Message class for SLP service deregistration request. 28 // Author: James Kempf 29 // Created On: Thu Oct 9 15:00:38 1997 30 // Last Modified By: James Kempf 31 // Last Modified On: Tue Oct 27 10:57:39 1998 32 // Update Count: 102 33 // 34 35 package com.sun.slp; 36 37 import java.util.*; 38 import java.io.*; 39 40 41 /** 42 * The SSrvDereg class models the server side SLP service deregistration. The 43 * default class does SLPv2 deregs, but subclasses can do other versions 44 * by redefining the initialize() and makeReply() messages. 45 * 46 * @author James Kempf 47 */ 48 49 class SSrvDereg extends SrvLocMsgImpl { 50 51 ServiceURL URL = null; // the service URL. 52 Hashtable URLSignature = null; // Authentication block. 53 Vector tags = null; // Vector of String 54 55 // Construct a SSrvDereg from the input stream. 56 57 SSrvDereg(SrvLocHeader hdr, DataInputStream dis) 58 throws ServiceLocationException, IOException { 59 60 super(hdr, SrvLocHeader.SrvDereg); 61 62 this.initialize(dis); 63 64 } 65 66 // Initialize the object. 67 68 void initialize(DataInputStream dis) 69 throws ServiceLocationException, IOException { 70 71 SLPServerHeaderV2 hdr = (SLPServerHeaderV2)getHeader(); 72 StringBuffer buf = new StringBuffer(); 73 74 // Parse in scopes. 75 76 hdr.parseScopesIn(dis); 77 78 // Parse in the service URL. 79 80 Hashtable ht = new Hashtable(); 81 82 URL = 83 hdr.parseServiceURLIn(dis, 84 ht, 85 ServiceLocationException.INVALID_REGISTRATION); 86 87 URLSignature = (Hashtable)ht.get(URL); 88 89 // Get the tag lists. 90 91 hdr.getString(buf, dis); 92 93 tags = hdr.parseCommaSeparatedListIn(buf.toString(), true); 94 95 // If no tags, then set the tags vector to null. This indicates 96 // that the service: URL needs to be deregistered. 97 98 if (tags.size() <= 0) { 99 tags = null; 100 101 } else { 102 103 // Unescape the tags. 104 105 hdr.unescapeTags(tags); 106 107 } 108 109 // Construct description. 110 111 hdr.constructDescription("SrvDereg", 112 " URL=``" + URL + "''\n" + 113 " tags=``" + tags + "''\n" + 114 " URL signature=" + 115 AuthBlock.desc(URLSignature) + "\n"); 116 117 } 118 119 // Return a SrvAck. We ignore the existing flag, since in V2, fresh comes 120 // in. In this case, all we need to do is clone the header. 121 122 SrvLocMsg makeReply() { 123 124 SLPServerHeaderV2 hdr = 125 ((SLPServerHeaderV2)getHeader()).makeReplyHeader(); 126 127 // Construct description. 128 129 hdr.constructDescription("SrvAck", ""); 130 131 return hdr; 132 133 } 134 135 } 136