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 by Sun Microsystems, Inc. 26 * All rights reserved. 27 * 28 */ 29 30 // SCCS Status: %W% %G% 31 // SSrvDereg.java: Message class for SLP service deregistration request. 32 // Author: James Kempf 33 // Created On: Thu Oct 9 15:00:38 1997 34 // Last Modified By: James Kempf 35 // Last Modified On: Tue Oct 27 10:57:39 1998 36 // Update Count: 102 37 // 38 39 package com.sun.slp; 40 41 import java.util.*; 42 import java.io.*; 43 44 45 /** 46 * The SSrvDereg class models the server side SLP service deregistration. The 47 * default class does SLPv2 deregs, 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 SSrvDereg extends SrvLocMsgImpl { 55 56 ServiceURL URL = null; // the service URL. 57 Hashtable URLSignature = null; // Authentication block. 58 Vector tags = null; // Vector of String 59 60 // Construct a SSrvDereg from the input stream. 61 62 SSrvDereg(SrvLocHeader hdr, DataInputStream dis) 63 throws ServiceLocationException, IOException { 64 65 super(hdr, SrvLocHeader.SrvDereg); 66 67 this.initialize(dis); 68 69 } 70 71 // Initialize the object. 72 73 void initialize(DataInputStream dis) 74 throws ServiceLocationException, IOException { 75 76 SLPServerHeaderV2 hdr = (SLPServerHeaderV2)getHeader(); 77 StringBuffer buf = new StringBuffer(); 78 79 // Parse in scopes. 80 81 hdr.parseScopesIn(dis); 82 83 // Parse in the service URL. 84 85 Hashtable ht = new Hashtable(); 86 87 URL = 88 hdr.parseServiceURLIn(dis, 89 ht, 90 ServiceLocationException.INVALID_REGISTRATION); 91 92 URLSignature = (Hashtable)ht.get(URL); 93 94 // Get the tag lists. 95 96 hdr.getString(buf, dis); 97 98 tags = hdr.parseCommaSeparatedListIn(buf.toString(), true); 99 100 // If no tags, then set the tags vector to null. This indicates 101 // that the service: URL needs to be deregistered. 102 103 if (tags.size() <= 0) { 104 tags = null; 105 106 } else { 107 108 // Unescape the tags. 109 110 hdr.unescapeTags(tags); 111 112 } 113 114 // Construct description. 115 116 hdr.constructDescription("SrvDereg", 117 " URL=``" + URL + "''\n" + 118 " tags=``" + tags + "''\n" + 119 " URL signature=" + 120 AuthBlock.desc(URLSignature) + "\n"); 121 122 } 123 124 // Return a SrvAck. We ignore the existing flag, since in V2, fresh comes 125 // in. In this case, all we need to do is clone the header. 126 127 SrvLocMsg makeReply() { 128 129 SLPServerHeaderV2 hdr = 130 ((SLPServerHeaderV2)getHeader()).makeReplyHeader(); 131 132 // Construct description. 133 134 hdr.constructDescription("SrvAck", ""); 135 136 return hdr; 137 138 } 139 140 } 141