View Javadoc
1   /*
2     (C) Copyright IBM Corp. 2007, 2009
3   
4     THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
5     ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
6     CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
7   
8     You can obtain a current copy of the Eclipse Public License from
9     http://www.opensource.org/licenses/eclipse-1.0.php
10  
11    @author : Endre Bak, IBM, ebak@de.ibm.com
12   * 
13   * Change History
14   * Flag       Date        Prog         Description
15   *------------------------------------------------------------------------------- 
16   * 1804402    2007-09-28  ebak         IPv6 ready SLP
17   * 1892103    2008-02-12  ebak         SLP improvements
18   * 2003590    2008-06-30  blaschke-oss Change licensing from CPL to EPL
19   * 2204488 	  2008-10-28  raman_arora  Fix code to remove compiler warnings
20   * 2524131    2009-01-21  raman_arora  Upgrade client to JDK 1.5 (Phase 1)
21   * 2531371    2009-02-10  raman_arora  Upgrade client to JDK 1.5 (Phase 2) 
22   */
23  
24  package org.metricshub.wbem.sblim.slp.internal.msg;
25  
26  /*-
27   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
28   * WBEM Java Client
29   * ჻჻჻჻჻჻
30   * Copyright 2023 - 2025 MetricsHub
31   * ჻჻჻჻჻჻
32   * Licensed under the Apache License, Version 2.0 (the "License");
33   * you may not use this file except in compliance with the License.
34   * You may obtain a copy of the License at
35   *
36   *      http://www.apache.org/licenses/LICENSE-2.0
37   *
38   * Unless required by applicable law or agreed to in writing, software
39   * distributed under the License is distributed on an "AS IS" BASIS,
40   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41   * See the License for the specific language governing permissions and
42   * limitations under the License.
43   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
44   */
45  
46  import java.io.IOException;
47  import java.util.List;
48  import org.metricshub.wbem.sblim.slp.ServiceLocationException;
49  import org.metricshub.wbem.sblim.slp.ServiceURL;
50  
51  /*
52   * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
53   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Service
54   * Location header (function = SrvDeReg = 4) |
55   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length of
56   * <scope-list> | <scope-list> \
57   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | URL Entry \
58   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length of
59   * <tag-list> | <tag-list> \
60   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The
61   * <tag-list> is a <string-list> of attribute tags to deregister as defined in
62   * Section 9.4. If no <tag-list> is present, the SrvDeReg deregisters the
63   * service in all languages it has been registered in. If the <tag-list> is
64   * present, the SrvDeReg deregisters the attributes whose tags are listed in the
65   * tag spec. Services registered with Authentication Blocks MUST NOT include a
66   * <tag-list> in a SrvDeReg message: A DA will respond with an
67   * AUTHENTICATION_FAILED error in this case.
68   */
69  
70  /**
71   * ServiceDeregistration message
72   *
73   */
74  public class ServiceDeregistration extends SLPMessage {
75  	private List<String> iScopeList;
76  
77  	private ServiceURL iURL;
78  
79  	private List<String> iTagList;
80  
81  	/**
82  	 * parse
83  	 *
84  	 * @param pHdr
85  	 * @param pInStr
86  	 * @return SLPMessage
87  	 * @throws ServiceLocationException
88  	 * @throws IOException
89  	 */
90  	public static SLPMessage parse(MsgHeader pHdr, SLPInputStream pInStr) throws ServiceLocationException, IOException {
91  		return new ServiceDeregistration(pHdr, pInStr.readStringList(), pInStr.readURL(), pInStr.readStringList());
92  	}
93  
94  	/**
95  	 * Ctor.
96  	 *
97  	 * @param pScopeList
98  	 *            - list of scope strings
99  	 * @param pURL
100 	 * @param pTagList
101 	 */
102 	public ServiceDeregistration(List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
103 		super(SRV_DEREG);
104 		init(pScopeList, pURL, pTagList);
105 	}
106 
107 	/**
108 	 * Ctor.
109 	 *
110 	 * @param pLangTag
111 	 * @param pScopeList
112 	 *            - list of scope strings
113 	 * @param pURL
114 	 * @param pTagList
115 	 */
116 	public ServiceDeregistration(String pLangTag, List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
117 		super(SRV_DEREG, pLangTag);
118 		init(pScopeList, pURL, pTagList);
119 	}
120 
121 	/**
122 	 * Ctor.
123 	 *
124 	 * @param pHeader
125 	 * @param pScopeList
126 	 *            - list of scope strings
127 	 * @param pURL
128 	 * @param pTagList
129 	 */
130 	public ServiceDeregistration(MsgHeader pHeader, List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
131 		super(pHeader);
132 		init(pScopeList, pURL, pTagList);
133 	}
134 
135 	/**
136 	 * getServiceURL
137 	 *
138 	 * @return ServiceURL
139 	 */
140 	public ServiceURL getServiceURL() {
141 		return this.iURL;
142 	}
143 
144 	/**
145 	 * @param pOption
146 	 */
147 	@Override
148 	protected boolean serializeBody(SLPOutputStream pOutStr, SerializeOption pOption) {
149 		return (
150 			pOutStr.writeStringList(this.iScopeList) && pOutStr.write(this.iURL) && pOutStr.writeStringList(this.iTagList)
151 		);
152 	}
153 
154 	private void init(List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
155 		this.iScopeList = pScopeList;
156 		this.iURL = pURL;
157 		this.iTagList = pTagList;
158 	}
159 }