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