Search in sources :

Example 1 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 2 with Request

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

the class SessionPLLSender method sendPLLRequest.

/**
     * Returns a Session Response object based on the XML document received from
     * remote Session Server. This is in response to a request that we send to
     * the session server.
     *
     * @param svcurl The URL of the Session Service.
     * @param sreq The Session Request XML document.
     * @return a Vector of responses from the remote server
     * @exception com.iplanet.dpro.session.SessionException if there was an error in sending the XML
     *            document or if the response has multiple components.
     */
public SessionResponse sendPLLRequest(URL svcurl, SessionRequest sreq) throws SessionException {
    try {
        String cookies = sessionCookies.getCookieName() + "=" + sreq.getSessionID();
        if (!SystemProperties.isServerMode()) {
            SessionID sessionID = new SessionID(sreq.getSessionID());
            cookies = cookies + ";" + sessionCookies.getLBCookie(sessionID);
        }
        final Request req = new Request(sreq.toXMLString());
        final RequestSet set = new RequestSet(SESSION_SERVICE);
        set.addRequest(req);
        final Vector responses = PLLClient.send(svcurl, cookies, set);
        if (responses.size() != 1) {
            throw new SessionException(SessionBundle.rbName, "unexpectedResponse", null);
        }
        final Response res = (Response) responses.elementAt(0);
        return SessionResponse.parseXML(res.getContent());
    } catch (Exception e) {
        throw new SessionException(e);
    }
}
Also used : Response(com.iplanet.services.comm.share.Response) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) RequestSet(com.iplanet.services.comm.share.RequestSet) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) Request(com.iplanet.services.comm.share.Request) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID) Vector(java.util.Vector) SessionException(com.iplanet.dpro.session.SessionException)

Example 3 with Request

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

the class ResourceResultCache method sendPLLRequest.

/**
     * Return a PolicyService object based on the XML document received
     * from remote Policy Server. This is in response to a request that we
     * send to the Policy server.
     * @param policyServiceUrl The URL of the Policy Service
     * @param preq The SessionRequest XML document
     * @return PolicyService 
     * @exception SendRequestException is thrown if there was an error in
     * sending the XML document or PolicyException if there are any parsing
     * errors.     
     */
public static PolicyService sendPLLRequest(URL policyServiceUrl, PolicyRequest preq) throws SendRequestException, PolicyException {
    String lbcookie = null;
    try {
        lbcookie = getLBCookie(preq);
    } catch (Exception e) {
        throw new SendRequestException(e);
    }
    PolicyService policyService = new PolicyService();
    policyService.setMethodID(PolicyService.POLICY_REQUEST_ID);
    policyService.setPolicyRequest(preq);
    String xmlString = policyService.toXMLString();
    Request request = new Request(xmlString);
    RequestSet requestSet = new RequestSet(PolicyService.POLICY_SERVICE);
    requestSet.addRequest(request);
    if (debug.messageEnabled()) {
        debug.message("ResourceResultCache.sendPLLRequest:" + "sending PLL request to URL=" + policyServiceUrl + ":\nPLL message=" + xmlString);
    }
    Vector responses = PLLClient.send(policyServiceUrl, lbcookie, requestSet);
    Response response = (Response) responses.elementAt(0);
    PolicyService ps = PolicyService.parseXML(response.getContent());
    if (debug.messageEnabled()) {
        debug.message("ResourceResultCache.sendPLLRequest:" + "result=" + ps.toXMLString());
    }
    return ps;
}
Also used : SendRequestException(com.iplanet.services.comm.client.SendRequestException) AdvicesHandleableByAMResponse(com.sun.identity.policy.remote.AdvicesHandleableByAMResponse) PolicyResponse(com.sun.identity.policy.remote.PolicyResponse) Response(com.iplanet.services.comm.share.Response) RequestSet(com.iplanet.services.comm.share.RequestSet) PolicyService(com.sun.identity.policy.remote.PolicyService) PolicyListenerRequest(com.sun.identity.policy.remote.PolicyListenerRequest) Request(com.iplanet.services.comm.share.Request) ResourceResultRequest(com.sun.identity.policy.remote.ResourceResultRequest) RemoveListenerRequest(com.sun.identity.policy.remote.RemoveListenerRequest) AdvicesHandleableByAMRequest(com.sun.identity.policy.remote.AdvicesHandleableByAMRequest) PolicyRequest(com.sun.identity.policy.remote.PolicyRequest) Vector(java.util.Vector) JSONException(org.json.JSONException) PolicyException(com.sun.identity.policy.PolicyException) SendRequestException(com.iplanet.services.comm.client.SendRequestException) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AlreadyRegisteredException(com.iplanet.services.comm.client.AlreadyRegisteredException) IOException(java.io.IOException) SessionException(com.iplanet.dpro.session.SessionException)

Example 4 with Request

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

the class LogService method process.

/**
     * The method which accepts the request set, parses the xml request and
     * executes the appropriate log operation.
     * @param requests
     * @param servletRequest
     * @param servletResponse
     * @return The response set which contains the result of the log operation.
     */
public ResponseSet process(PLLAuditor auditor, List<Request> requests, HttpServletRequest servletRequest, HttpServletResponse servletResponse, ServletContext servletContext) {
    if (Debug.messageEnabled()) {
        Debug.message("LogService.process() called :requests are");
        for (Request req : requests) {
            Debug.message("xml = " + req.getContent());
        }
    }
    ResponseSet rset = new ResponseSet(LOG_SERVICE);
    for (Request req : requests) {
        // remember sid string is the last item in the log tag
        String xmlRequestString = req.getContent();
        Response res;
        if ((xmlRequestString == null) || xmlRequestString.equals("null")) {
            Debug.error("Received a null log request");
            res = new Response("NULL_LOG_REQUEST");
            rset.addResponse(res);
        } else {
            int l = xmlRequestString.length();
            int sidi = xmlRequestString.indexOf("sid=");
            int sidj = xmlRequestString.indexOf("</log");
            loggedBySid = xmlRequestString.substring((sidi + 5), (sidj - 2));
            try {
                //NOTE source ip address restrictions are temporary kludge
                // for 6.1 session hijacking hotpatch
                InetAddress remoteClient = SessionUtils.getClientAddress(servletRequest);
                SSOToken ssoToken = RestrictedTokenHelper.resolveRestrictedToken(loggedBySid, remoteClient);
                SSOTokenManager ssom = SSOTokenManager.getInstance();
                if (!ssom.isValidToken(ssoToken)) {
                    String loggedByID = ssoToken.getPrincipal().getName();
                    Debug.error("LogService::process(): access denied for" + " user :" + loggedByID);
                    res = new Response("UNAUTHORIZED");
                    rset.addResponse(res);
                    return rset;
                }
            } catch (SSOException e) {
                Debug.error("LogService::process(): SSOException", e);
                res = new Response("UNAUTHORIZED");
                rset.addResponse(res);
                return rset;
            } catch (Exception e) {
                Debug.error("LogService::process(): ", e);
                res = new Response("ERROR");
                rset.addResponse(res);
            }
            try {
                ByteArrayInputStream bin = new ByteArrayInputStream(xmlRequestString.getBytes("UTF-8"));
                LogOperation op = (LogOperation) parser.parse(bin);
                res = op.execute(auditEventPublisher, auditEventFactory);
            } catch (Exception e) {
                Debug.error("LogService::process():", e);
                // FORMAT ERROR RESPONSE HERE
                res = new Response("ERROR");
                if (MonitoringUtil.isRunning()) {
                    SsoServerLoggingSvcImpl slsi = Agent.getLoggingSvcMBean();
                    SsoServerLoggingHdlrEntryImpl slei = slsi.getHandler(SsoServerLoggingSvcImpl.REMOTE_HANDLER_NAME);
                    slei.incHandlerFailureCount(1);
                }
            }
            rset.addResponse(res);
        }
    }
    return rset;
}
Also used : SSOTokenManager(com.iplanet.sso.SSOTokenManager) SSOToken(com.iplanet.sso.SSOToken) Request(com.iplanet.services.comm.share.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) ResponseSet(com.iplanet.services.comm.share.ResponseSet) SSOException(com.iplanet.sso.SSOException) SSOException(com.iplanet.sso.SSOException) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) ByteArrayInputStream(java.io.ByteArrayInputStream) InetAddress(java.net.InetAddress) SsoServerLoggingSvcImpl(com.sun.identity.monitoring.SsoServerLoggingSvcImpl) SsoServerLoggingHdlrEntryImpl(com.sun.identity.monitoring.SsoServerLoggingHdlrEntryImpl)

Example 5 with Request

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

the class NamingService method process.

public ResponseSet process(PLLAuditor auditor, List<Request> requests, HttpServletRequest servletRequest, HttpServletResponse servletResponse, ServletContext servletContext) {
    ResponseSet rset = new ResponseSet(NAMING_SERVICE_PACKAGE);
    for (Request req : requests) {
        Response res = processRequest(req);
        rset.addResponse(res);
    }
    return rset;
}
Also used : NamingResponse(com.iplanet.services.naming.share.NamingResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) Request(com.iplanet.services.comm.share.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) NamingRequest(com.iplanet.services.naming.share.NamingRequest) ResponseSet(com.iplanet.services.comm.share.ResponseSet)

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