Revision 5057
Added by daigle over 14 years ago
MetacatClient.java | ||
---|---|---|
32 | 32 |
import java.io.StringWriter; |
33 | 33 |
import java.io.Reader; |
34 | 34 |
import java.net.URL; |
35 |
import java.util.HashMap; |
|
36 | 35 |
import java.util.Properties; |
37 | 36 |
import java.util.Vector; |
38 | 37 |
import javax.servlet.http.HttpServletRequest; |
39 |
import javax.xml.xpath.XPath; |
|
40 |
import javax.xml.xpath.XPathFactory; |
|
41 |
import org.w3c.dom.Document; |
|
42 | 38 |
|
43 | 39 |
import org.w3c.dom.Node; |
44 | 40 |
import org.w3c.dom.NodeList; |
... | ... | |
164 | 160 |
} |
165 | 161 |
|
166 | 162 |
/** |
163 |
* Method used to log in to a metacat server. Implementations will need |
|
164 |
* to cache a cookie value to make the session persistent. Each time a |
|
165 |
* call is made to one of the other methods (e.g., read), the cookie will |
|
166 |
* need to be passed back to the metacat server along with the request. |
|
167 |
* |
|
168 |
* @param username the username of the user, like an LDAP DN |
|
169 |
* @param password the password for that user for authentication |
|
170 |
* @return the response string from metacat in XML format |
|
171 |
* @throws MetacatAuthException when the username/password could |
|
172 |
* not be authenticated |
|
173 |
*/ |
|
174 |
public String validateSession(String sessionId) |
|
175 |
throws MetacatAuthException, MetacatInaccessibleException { |
|
176 |
|
|
177 |
Properties prop = new Properties(); |
|
178 |
prop.put("action", "validatesession"); |
|
179 |
prop.put("sessionid", sessionId); |
|
180 |
|
|
181 |
String response = null; |
|
182 |
try { |
|
183 |
response = sendDataForString(prop, null, null, 0); |
|
184 |
} catch (Exception e) { |
|
185 |
throw new MetacatInaccessibleException(e.getMessage()); |
|
186 |
} |
|
187 |
|
|
188 |
if (response.indexOf("<validateSession><status>") == -1) { |
|
189 |
setSessionId(""); |
|
190 |
throw new MetacatAuthException(response); |
|
191 |
} |
|
192 |
|
|
193 |
return response; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
167 | 197 |
* Read an XML document from the metacat server session, accessed by docid, |
168 | 198 |
* and returned as a Reader. |
169 | 199 |
* |
Also available in: Unified diff
Add session validation to metacat tpc and workflow scheduler. Fix sanparks skin session management so it always uses the logged in session id.