use of java.net.URLStreamHandler in project OpenAM by OpenRock.
the class AuthContext method processRequest.
protected Document processRequest(String xmlRequest) throws AuthLoginException {
Document doc = null;
try {
Request request = new Request(xmlRequest);
RequestSet set = new RequestSet(AuthXMLTags.AUTH_SERVICE);
set.addRequest(request);
URL url = authServiceURL;
if (url.getProtocol().equals("https") && (nickName != null)) {
Class[] paramtype = { String.class };
Object[] param = { nickName };
String protHandler = protHandlerPkg + ".https.Handler";
Constructor construct = Class.forName(protHandler).getConstructor(paramtype);
URLStreamHandler handler = (URLStreamHandler) construct.newInstance(param);
url = new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile(), handler);
}
if (authDebug.messageEnabled()) {
authDebug.message("Service URL : " + url.toString());
}
Vector responses = PLLClient.send(url, set, cookieTable);
if ((responses.isEmpty()) || (responses.size() != 1)) {
throw new L10NMessageImpl(amAuthContext, "responseError", null);
}
Response res = (Response) responses.elementAt(0);
String responseStr = (String) res.getContent();
doc = XMLUtils.getXMLDocument(new ByteArrayInputStream(responseStr.getBytes("UTF-8")));
} catch (Exception e) {
authDebug.message("error in getting service url", e);
throw new AuthLoginException(amAuthContext, "xmlProcessError", null, e);
}
return (doc);
}
use of java.net.URLStreamHandler in project OpenAM by OpenRock.
the class AMURLStreamHandlerFactory method createURLStreamHandler.
/**
* Returns configured https protocol handler.
* @param protocol - the protocol ("https")
* @return a <code>URLStreamHandler</code> for https protocol.
*/
public URLStreamHandler createURLStreamHandler(String protocol) {
String method = "AMURLStreamHandlerFactory.createURLStreamHandler ";
URLStreamHandler prot_handler = null;
if (protocol.equalsIgnoreCase("https") && (prot_handler_string != null)) {
try {
prot_handler = (URLStreamHandler) Class.forName(prot_handler_string).newInstance();
} catch (ClassNotFoundException e) {
debug.error(method + "Failed to find protocol handler class ", e);
} catch (InstantiationException e) {
debug.error(method + "Failed to instantiate protocol handler class ", e);
} catch (IllegalAccessException e) {
debug.error(method + "Invalid access for protocol handler class ", e);
}
}
return prot_handler;
}
Aggregations