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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations