xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/CSrvDereg.java (revision 55fea89dcaa64928bed4327112404dcb3e07b79f)
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 //  CSrvDereg.java:   Client side Service Deregistration
28 //  Author:           James Kempf
29 //  Created On:       Tue Feb 10 13:17:41 1998
30 //  Last Modified By: James Kempf
31 //  Last Modified On: Tue Oct 27 10:57:38 1998
32 //  Update Count:     42
33 //
34 
35 package com.sun.slp;
36 
37 import java.util.*;
38 import java.io.*;
39 
40 
41 /**
42  * The SrvDeReg class models the server side SLP service deregistration.
43  *
44  * @author James Kempf
45  */
46 
47 
48 class CSrvDereg extends SrvLocMsgImpl {
49 
50     // Construct a CSrvDereg from the arguments. This is the client side
51     //  SrvDereg for transmission to the server.
52 
CSrvDereg(Locale locale, ServiceURL url, Vector scopes, Vector tags, Hashtable auth)53     CSrvDereg(Locale locale,
54 	      ServiceURL url,
55 	      Vector scopes,
56 	      Vector tags,
57 	      Hashtable auth)
58 	throws ServiceLocationException {
59 
60 	// Null tags argument means deregister the service URL, but it
61 	// can't be empty.
62 
63 	if (tags != null && tags.size() <= 0) {
64 	    throw
65 		new IllegalArgumentException(
66 			SLPConfig.getSLPConfig().formatMessage("empty_vector",
67 							       new Object[0]));
68 	}
69 
70 	this.initialize(locale, url, scopes, tags, auth);
71 
72     }
73 
74     // Initialize object. V1 will do it differently.
75 
initialize(Locale locale, ServiceURL url, Vector scopes, Vector tags, Hashtable auth)76     void initialize(Locale locale,
77 		    ServiceURL url,
78 		    Vector scopes,
79 		    Vector tags,
80 		    Hashtable auth)
81 	throws ServiceLocationException {
82 
83 	SLPConfig config = SLPConfig.getSLPConfig();
84 	SLPHeaderV2 hdr =
85 	    new SLPHeaderV2(SrvLocHeader.SrvDereg, false, locale);
86 	this.hdr = hdr;
87 	hdr.scopes = (Vector)scopes.clone();
88 
89 	// Escape tags.
90 
91 	if (tags != null) {
92 	    hdr.escapeTags(tags);
93 
94 	} else {
95 	    tags = new Vector();
96 
97 	}
98 
99 	ByteArrayOutputStream baos = new ByteArrayOutputStream();
100 
101 	// Escape scopes.
102 
103 	hdr.escapeScopeStrings(scopes);
104 
105 	// Parse out the scopes.
106 
107 	hdr.parseCommaSeparatedListOut(scopes, baos);
108 
109 	// Parse out the URL. Ignore overflow.
110 
111 	hdr.parseServiceURLOut(url,
112 			       config.getHasSecurity(),
113 			       auth,
114 			       baos,
115 			       false);
116 
117 	// Parse out the tags.
118 
119 	hdr.parseCommaSeparatedListOut(tags, baos);
120 
121 	hdr.payload = baos.toByteArray();
122 
123     }
124 
125 }
126