Search in sources :

Example 6 with URLStreamHandler

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);
}
Also used : Constructor(java.lang.reflect.Constructor) L10NMessageImpl(com.sun.identity.shared.locale.L10NMessageImpl) Request(com.iplanet.services.comm.share.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) RemoteHttpServletRequest(org.forgerock.openam.authentication.service.protocol.RemoteHttpServletRequest) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) Document(org.w3c.dom.Document) URL(java.net.URL) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) AMSecurityPropertiesException(com.sun.identity.security.AMSecurityPropertiesException) IOException(java.io.IOException) AuthException(com.sun.identity.authentication.service.AuthException) URLStreamHandler(java.net.URLStreamHandler) RemoteHttpServletResponse(org.forgerock.openam.authentication.service.protocol.RemoteHttpServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) RequestSet(com.iplanet.services.comm.share.RequestSet) ByteArrayInputStream(java.io.ByteArrayInputStream) Vector(java.util.Vector)

Example 7 with URLStreamHandler

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;
}
Also used : URLStreamHandler(java.net.URLStreamHandler)

Aggregations

URLStreamHandler (java.net.URLStreamHandler)7 URL (java.net.URL)5 IOException (java.io.IOException)2 URLStreamHandlerFactory (java.net.URLStreamHandlerFactory)2 Vector (java.util.Vector)2 Request (com.iplanet.services.comm.share.Request)1 RequestSet (com.iplanet.services.comm.share.RequestSet)1 Response (com.iplanet.services.comm.share.Response)1 SSOException (com.iplanet.sso.SSOException)1 HttpService (com.splunk.HttpService)1 Service (com.splunk.Service)1 ServiceArgs (com.splunk.ServiceArgs)1 AuthException (com.sun.identity.authentication.service.AuthException)1 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)1 AMSecurityPropertiesException (com.sun.identity.security.AMSecurityPropertiesException)1 L10NMessageImpl (com.sun.identity.shared.locale.L10NMessageImpl)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 HttpURLConnection (java.net.HttpURLConnection)1