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.sentrysoftware.wbem.sblim.slp.internal.msg;
25  
26  /*-
27   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
28   * WBEM Java Client
29   * ჻჻჻჻჻჻
30   * Copyright (C) 2023 Sentry Software
31   * ჻჻჻჻჻჻
32   * This program is free software: you can redistribute it and/or modify
33   * it under the terms of the GNU Lesser General Public License as
34   * published by the Free Software Foundation, either version 3 of the
35   * License, or (at your option) any later version.
36   *
37   * This program is distributed in the hope that it will be useful,
38   * but WITHOUT ANY WARRANTY; without even the implied warranty of
39   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40   * GNU General Lesser Public License for more details.
41   *
42   * You should have received a copy of the GNU General Lesser Public
43   * License along with this program.  If not, see
44   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
45   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
46   */
47  
48  import java.io.IOException;
49  import java.util.List;
50  
51  import org.sentrysoftware.wbem.sblim.slp.ServiceLocationException;
52  import org.sentrysoftware.wbem.sblim.slp.ServiceURL;
53  
54  /*
55   * 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
56   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Service
57   * Location header (function = SrvDeReg = 4) |
58   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length of
59   * <scope-list> | <scope-list> \
60   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | URL Entry \
61   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Length of
62   * <tag-list> | <tag-list> \
63   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The
64   * <tag-list> is a <string-list> of attribute tags to deregister as defined in
65   * Section 9.4. If no <tag-list> is present, the SrvDeReg deregisters the
66   * service in all languages it has been registered in. If the <tag-list> is
67   * present, the SrvDeReg deregisters the attributes whose tags are listed in the
68   * tag spec. Services registered with Authentication Blocks MUST NOT include a
69   * <tag-list> in a SrvDeReg message: A DA will respond with an
70   * AUTHENTICATION_FAILED error in this case.
71   */
72  
73  /**
74   * ServiceDeregistration message
75   * 
76   */
77  public class ServiceDeregistration extends SLPMessage {
78  
79  	private List<String> iScopeList;
80  
81  	private ServiceURL iURL;
82  
83  	private List<String> iTagList;
84  
85  	/**
86  	 * parse
87  	 * 
88  	 * @param pHdr
89  	 * @param pInStr
90  	 * @return SLPMessage
91  	 * @throws ServiceLocationException
92  	 * @throws IOException
93  	 */
94  	public static SLPMessage parse(MsgHeader pHdr, SLPInputStream pInStr)
95  			throws ServiceLocationException, IOException {
96  		return new ServiceDeregistration(pHdr, pInStr.readStringList(), pInStr.readURL(), pInStr
97  				.readStringList());
98  	}
99  
100 	/**
101 	 * Ctor.
102 	 * 
103 	 * @param pScopeList
104 	 *            - list of scope strings
105 	 * @param pURL
106 	 * @param pTagList
107 	 */
108 	public ServiceDeregistration(List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
109 		super(SRV_DEREG);
110 		init(pScopeList, pURL, pTagList);
111 	}
112 
113 	/**
114 	 * Ctor.
115 	 * 
116 	 * @param pLangTag
117 	 * @param pScopeList
118 	 *            - list of scope strings
119 	 * @param pURL
120 	 * @param pTagList
121 	 */
122 	public ServiceDeregistration(String pLangTag, List<String> pScopeList, ServiceURL pURL,
123 			List<String> pTagList) {
124 		super(SRV_DEREG, pLangTag);
125 		init(pScopeList, pURL, pTagList);
126 	}
127 
128 	/**
129 	 * Ctor.
130 	 * 
131 	 * @param pHeader
132 	 * @param pScopeList
133 	 *            - list of scope strings
134 	 * @param pURL
135 	 * @param pTagList
136 	 */
137 	public ServiceDeregistration(MsgHeader pHeader, List<String> pScopeList, ServiceURL pURL,
138 			List<String> pTagList) {
139 		super(pHeader);
140 		init(pScopeList, pURL, pTagList);
141 	}
142 
143 	/**
144 	 * getServiceURL
145 	 * 
146 	 * @return ServiceURL
147 	 */
148 	public ServiceURL getServiceURL() {
149 		return this.iURL;
150 	}
151 
152 	/**
153 	 * @param pOption
154 	 */
155 	@Override
156 	protected boolean serializeBody(SLPOutputStream pOutStr, SerializeOption pOption) {
157 		return pOutStr.writeStringList(this.iScopeList) && pOutStr.write(this.iURL)
158 				&& pOutStr.writeStringList(this.iTagList);
159 	}
160 
161 	private void init(List<String> pScopeList, ServiceURL pURL, List<String> pTagList) {
162 		this.iScopeList = pScopeList;
163 		this.iURL = pURL;
164 		this.iTagList = pTagList;
165 	}
166 
167 }