10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License"). 6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 220Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 230Sstevel@tonic-gate * All rights reserved. 240Sstevel@tonic-gate * 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate // SSrvDereg.java: Message class for SLP service deregistration request. 280Sstevel@tonic-gate // Author: James Kempf 290Sstevel@tonic-gate // Created On: Thu Oct 9 15:00:38 1997 300Sstevel@tonic-gate // Last Modified By: James Kempf 310Sstevel@tonic-gate // Last Modified On: Tue Oct 27 10:57:39 1998 320Sstevel@tonic-gate // Update Count: 102 330Sstevel@tonic-gate // 340Sstevel@tonic-gate 350Sstevel@tonic-gate package com.sun.slp; 360Sstevel@tonic-gate 370Sstevel@tonic-gate import java.util.*; 380Sstevel@tonic-gate import java.io.*; 390Sstevel@tonic-gate 400Sstevel@tonic-gate 410Sstevel@tonic-gate /** 420Sstevel@tonic-gate * The SSrvDereg class models the server side SLP service deregistration. The 430Sstevel@tonic-gate * default class does SLPv2 deregs, but subclasses can do other versions 440Sstevel@tonic-gate * by redefining the initialize() and makeReply() messages. 450Sstevel@tonic-gate * 460Sstevel@tonic-gate * @author James Kempf 470Sstevel@tonic-gate */ 480Sstevel@tonic-gate 490Sstevel@tonic-gate class SSrvDereg extends SrvLocMsgImpl { 500Sstevel@tonic-gate 510Sstevel@tonic-gate ServiceURL URL = null; // the service URL. 520Sstevel@tonic-gate Hashtable URLSignature = null; // Authentication block. 530Sstevel@tonic-gate Vector tags = null; // Vector of String 540Sstevel@tonic-gate 550Sstevel@tonic-gate // Construct a SSrvDereg from the input stream. 560Sstevel@tonic-gate SSrvDereg(SrvLocHeader hdr, DataInputStream dis)570Sstevel@tonic-gate SSrvDereg(SrvLocHeader hdr, DataInputStream dis) 580Sstevel@tonic-gate throws ServiceLocationException, IOException { 590Sstevel@tonic-gate 600Sstevel@tonic-gate super(hdr, SrvLocHeader.SrvDereg); 610Sstevel@tonic-gate 620Sstevel@tonic-gate this.initialize(dis); 630Sstevel@tonic-gate 640Sstevel@tonic-gate } 650Sstevel@tonic-gate 660Sstevel@tonic-gate // Initialize the object. 670Sstevel@tonic-gate initialize(DataInputStream dis)680Sstevel@tonic-gate void initialize(DataInputStream dis) 690Sstevel@tonic-gate throws ServiceLocationException, IOException { 700Sstevel@tonic-gate 710Sstevel@tonic-gate SLPServerHeaderV2 hdr = (SLPServerHeaderV2)getHeader(); 720Sstevel@tonic-gate StringBuffer buf = new StringBuffer(); 730Sstevel@tonic-gate 740Sstevel@tonic-gate // Parse in scopes. 750Sstevel@tonic-gate 760Sstevel@tonic-gate hdr.parseScopesIn(dis); 770Sstevel@tonic-gate 780Sstevel@tonic-gate // Parse in the service URL. 790Sstevel@tonic-gate 800Sstevel@tonic-gate Hashtable ht = new Hashtable(); 810Sstevel@tonic-gate 820Sstevel@tonic-gate URL = 830Sstevel@tonic-gate hdr.parseServiceURLIn(dis, 840Sstevel@tonic-gate ht, 850Sstevel@tonic-gate ServiceLocationException.INVALID_REGISTRATION); 860Sstevel@tonic-gate 870Sstevel@tonic-gate URLSignature = (Hashtable)ht.get(URL); 880Sstevel@tonic-gate 890Sstevel@tonic-gate // Get the tag lists. 900Sstevel@tonic-gate 910Sstevel@tonic-gate hdr.getString(buf, dis); 920Sstevel@tonic-gate 930Sstevel@tonic-gate tags = hdr.parseCommaSeparatedListIn(buf.toString(), true); 940Sstevel@tonic-gate 950Sstevel@tonic-gate // If no tags, then set the tags vector to null. This indicates 960Sstevel@tonic-gate // that the service: URL needs to be deregistered. 970Sstevel@tonic-gate 980Sstevel@tonic-gate if (tags.size() <= 0) { 990Sstevel@tonic-gate tags = null; 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate } else { 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate // Unescape the tags. 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate hdr.unescapeTags(tags); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate } 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate // Construct description. 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate hdr.constructDescription("SrvDereg", 1120Sstevel@tonic-gate " URL=``" + URL + "''\n" + 1130Sstevel@tonic-gate " tags=``" + tags + "''\n" + 1140Sstevel@tonic-gate " URL signature=" + 1150Sstevel@tonic-gate AuthBlock.desc(URLSignature) + "\n"); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate } 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate // Return a SrvAck. We ignore the existing flag, since in V2, fresh comes 1200Sstevel@tonic-gate // in. In this case, all we need to do is clone the header. 1210Sstevel@tonic-gate makeReply()1220Sstevel@tonic-gate SrvLocMsg makeReply() { 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate SLPServerHeaderV2 hdr = 1250Sstevel@tonic-gate ((SLPServerHeaderV2)getHeader()).makeReplyHeader(); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate // Construct description. 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate hdr.constructDescription("SrvAck", ""); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate return hdr; 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate } 136