Search in sources :

Example 6 with Request

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

the class PolicyRequestHandler method process.

/**
     *  Process the requests aÎnd return the responses.
     *
     *  @param requests Requests specified in the policy request
     *  @return the set of the response
     */
public ResponseSet process(PLLAuditor auditor, List<Request> requests, HttpServletRequest servletRequest, HttpServletResponse servletResponse, ServletContext servletContext) {
    ResponseSet resSet = new ResponseSet(PolicyService.POLICY_SERVICE);
    int size = requests.size();
    auditor.setComponent(POLICY);
    for (Request req : requests) {
        Response res = null;
        try {
            res = processRequest(req, auditor);
        } catch (PolicyEvaluationException pe) {
            if (debug.messageEnabled()) {
                debug.message("PolicyRequesthandler.process" + " caught PolicyEvaluationException:", pe);
            }
            PolicyService ps = new PolicyService();
            try {
                String rev = getPolicyServiceRevision();
                ps.setRevision(rev);
            } catch (PolicyEvaluationException pee) {
                debug.error("PolicyRequesthandler.process" + " can not get service revision number, " + ",revision defaulting to :" + PolicyService.ON_ERROR_REVISION_NUMBER, pee);
                ps.setRevision(PolicyService.ON_ERROR_REVISION_NUMBER);
            }
            PolicyResponse pRes = new PolicyResponse();
            pRes.setMethodID(PolicyResponse.POLICY_EXCEPTION);
            pRes.setRequestId(pe.getRequestId());
            pRes.setExceptionMsg(pe.getMessage());
            pRes.setIssueInstant(System.currentTimeMillis());
            ps.setMethodID(PolicyService.POLICY_RESPONSE_ID);
            ps.setPolicyResponse(pRes);
            res = new Response(ps.toXMLString());
            auditor.auditAccessFailure(pe.getMessage());
        }
        if (res != null) {
            resSet.addResponse(res);
        }
    }
    return resSet;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) Request(com.iplanet.services.comm.share.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) ResponseSet(com.iplanet.services.comm.share.ResponseSet)

Example 7 with Request

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

the class WebtopNaming method getNamingTable.

private static Hashtable getNamingTable(URL nameurl) throws Exception {
    Hashtable nametbl = null;
    NamingRequest nrequest = new NamingRequest(NamingRequest.reqVersion);
    Request request = new Request(nrequest.toXMLString());
    RequestSet set = new RequestSet(NAMING_SERVICE);
    set.addRequest(request);
    Vector responses = null;
    try {
        responses = PLLClient.send(nameurl, set);
        if (responses.size() != 1) {
            throw new Exception(NamingBundle.getString("unexpectedResponse"));
        }
        Response res = (Response) responses.elementAt(0);
        NamingResponse nres = NamingResponse.parseXML(res.getContent());
        if (nres.getException() != null) {
            throw new Exception(nres.getException());
        }
        nametbl = nres.getNamingTable();
    } catch (SendRequestException sre) {
        debug.error("Naming service connection failed for " + nameurl, sre);
    } catch (Exception e) {
        debug.error("getNamingTable: ", e);
    }
    return nametbl;
}
Also used : NamingResponse(com.iplanet.services.naming.share.NamingResponse) Response(com.iplanet.services.comm.share.Response) SendRequestException(com.iplanet.services.comm.client.SendRequestException) NamingRequest(com.iplanet.services.naming.share.NamingRequest) RequestSet(com.iplanet.services.comm.share.RequestSet) Hashtable(java.util.Hashtable) Request(com.iplanet.services.comm.share.Request) NamingRequest(com.iplanet.services.naming.share.NamingRequest) NamingResponse(com.iplanet.services.naming.share.NamingResponse) Vector(java.util.Vector) SendRequestException(com.iplanet.services.comm.client.SendRequestException) MalformedURLException(java.net.MalformedURLException)

Example 8 with Request

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

the class SessionRequestHandler method process.

public ResponseSet process(PLLAuditor auditor, List<Request> requests, HttpServletRequest servletRequest, HttpServletResponse servletResponse, ServletContext servletContext) {
    ResponseSet rset = new ResponseSet(SessionService.SESSION_SERVICE);
    auditor.setComponent(SESSION);
    for (Request req : requests) {
        Response res = processRequest(auditor, req, servletRequest, servletResponse);
        rset.addResponse(res);
    }
    return rset;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) Request(com.iplanet.services.comm.share.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) ResponseSet(com.iplanet.services.comm.share.ResponseSet)

Example 9 with Request

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

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

Request (com.iplanet.services.comm.share.Request)10 Response (com.iplanet.services.comm.share.Response)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 RequestSet (com.iplanet.services.comm.share.RequestSet)5 ResponseSet (com.iplanet.services.comm.share.ResponseSet)5 Vector (java.util.Vector)4 SSOException (com.iplanet.sso.SSOException)3 SessionException (com.iplanet.dpro.session.SessionException)2 SessionRequest (com.iplanet.dpro.session.share.SessionRequest)2 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)2 SendRequestException (com.iplanet.services.comm.client.SendRequestException)2 NamingRequest (com.iplanet.services.naming.share.NamingRequest)2 NamingResponse (com.iplanet.services.naming.share.NamingResponse)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 SessionID (com.iplanet.dpro.session.SessionID)1 AlreadyRegisteredException (com.iplanet.services.comm.client.AlreadyRegisteredException)1 URLNotFoundException (com.iplanet.services.naming.URLNotFoundException)1 SSOToken (com.iplanet.sso.SSOToken)1