Search in sources :

Example 6 with RequestSet

use of com.iplanet.services.comm.share.RequestSet 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 RequestSet

use of com.iplanet.services.comm.share.RequestSet in project OpenAM by OpenRock.

the class RemoteHandler method flush.

/**
     * Flush any buffered output.
     */
public synchronized void flush() {
    if (recCount <= 0) {
        if (Debug.messageEnabled()) {
            Debug.message("RemoteHandler.flush(): no records " + "in buffer to send");
        }
        return;
    }
    Vector responses = new Vector();
    if (Debug.messageEnabled()) {
        Debug.message("RemoteHandler.flush(): sending buffered records");
    }
    String thisAMException = null;
    try {
        Iterator sidIter = reqSetMap.keySet().iterator();
        while (sidIter.hasNext()) {
            String currentLoggedBySID = (String) sidIter.next();
            URL logHostURL = getLogHostURL(currentLoggedBySID);
            if (logHostURL == null) {
                Debug.error("RemoteHandler.flush(): logHostURL is null");
                this.recCount = 0;
                reqSetMap = new HashMap();
                return;
            }
            RequestSet reqSet = (RequestSet) reqSetMap.get(currentLoggedBySID);
            responses = PLLClient.send(logHostURL, reqSet);
            Iterator respIter = responses.iterator();
            while (respIter.hasNext()) {
                Response resp = (Response) respIter.next();
                String respContent = resp.getContent();
                if (!respContent.equals("OK")) {
                    Debug.error("RemoteHandler.flush(): " + respContent + " on remote machine");
                    if (thisAMException == null) {
                        thisAMException = "RemoteHandler.flush(): " + respContent + " on remote machine";
                    }
                }
            }
        }
    } catch (Exception e) {
        Debug.error("RemoteHandler.flush(): ", e);
    }
    this.recCount = 0;
    reqSetMap = new HashMap();
    if (thisAMException != null) {
        throw new AMLogException(thisAMException);
    }
}
Also used : Response(com.iplanet.services.comm.share.Response) RequestSet(com.iplanet.services.comm.share.RequestSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AMLogException(com.sun.identity.log.AMLogException) Vector(java.util.Vector) URL(java.net.URL) AMLogException(com.sun.identity.log.AMLogException) ThreadPoolException(com.iplanet.am.util.ThreadPoolException) MalformedURLException(java.net.MalformedURLException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException)

Example 8 with RequestSet

use of com.iplanet.services.comm.share.RequestSet in project OpenAM by OpenRock.

the class RemoteHandler method publish.

/**
     * This method sends the LogRecord to the remote logging service.
     * @param logRecord The LogRecord to be published to the remote 
     *        logging service.
     */
public synchronized void publish(java.util.logging.LogRecord logRecord) {
    logName = logRecord.getLoggerName();
    String xml = getFormatter().format(logRecord);
    if (xml == null || xml.length() <= 0) {
        if (Debug.warningEnabled()) {
            Debug.warning(logName + ":RemoteHandler.publish : formatted xml is null");
        }
        return;
    }
    Request request = new Request(xml);
    if (logRecord instanceof ILogRecord) {
        Map logInfoMap = ((ILogRecord) logRecord).getLogInfoMap();
        String loggedBySid = (String) logInfoMap.get(LogConstants.LOGGED_BY_SID);
        if (loggedBySid != null) {
            RequestSet reqSet = (RequestSet) reqSetMap.get(loggedBySid);
            if (reqSet == null) {
                reqSet = new RequestSet("Logging");
            }
            reqSet.addRequest(request);
            reqSetMap.put(loggedBySid, reqSet);
        }
    }
    this.recCount++;
    if (this.recCount >= recCountLimit) {
        if (Debug.messageEnabled()) {
            Debug.message(logName + ":RemoteHandler.publish(): got " + recCount + " records, flushing all");
        }
        nonBlockingFlush();
    }
}
Also used : RequestSet(com.iplanet.services.comm.share.RequestSet) Request(com.iplanet.services.comm.share.Request) ILogRecord(com.sun.identity.log.ILogRecord) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RequestSet (com.iplanet.services.comm.share.RequestSet)8 Response (com.iplanet.services.comm.share.Response)6 Vector (java.util.Vector)6 Request (com.iplanet.services.comm.share.Request)5 SSOException (com.iplanet.sso.SSOException)3 IOException (java.io.IOException)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3 SessionException (com.iplanet.dpro.session.SessionException)2 SessionID (com.iplanet.dpro.session.SessionID)2 SendRequestException (com.iplanet.services.comm.client.SendRequestException)2 URLNotFoundException (com.iplanet.services.naming.URLNotFoundException)2 AuthException (com.sun.identity.authentication.service.AuthException)2 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)2 MalformedURLException (java.net.MalformedURLException)2 Map (java.util.Map)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ThreadPoolException (com.iplanet.am.util.ThreadPoolException)1 SessionRequest (com.iplanet.dpro.session.share.SessionRequest)1 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)1