use of com.iplanet.services.comm.share.Response 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.Response in project OpenAM by OpenRock.
the class SessionRequestHandler method processRequest.
private Response processRequest(final PLLAuditor auditor, final Request req, final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) {
final SessionRequest sreq = SessionRequest.parseXML(req.getContent());
auditor.setMethod(sreq.getMethodName());
SessionResponse sres = new SessionResponse(sreq.getRequestID(), sreq.getMethodID());
Object context;
try {
// use remote client IP as default RestrictedToken context
context = SessionUtils.getClientAddress(servletRequest);
this.clientToken = null;
} catch (Exception ex) {
sessionDebug.error("SessionRequestHandler encounterd exception", ex);
sres.setException(ex.getMessage());
return auditedExceptionResponse(auditor, sres);
}
String requester = sreq.getRequester();
if (requester != null) {
try {
context = RestrictedTokenContext.unmarshal(requester);
if (context instanceof SSOToken) {
SSOTokenManager ssoTokenManager = SSOTokenManager.getInstance();
SSOToken adminToken = (SSOToken) context;
if (!ssoTokenManager.isValidToken(adminToken)) {
sres.setException(SessionBundle.getString("appTokenInvalid") + requester);
return auditedExceptionResponse(auditor, sres);
}
this.clientToken = (SSOToken) context;
}
} catch (Exception ex) {
if (sessionDebug.warningEnabled()) {
sessionDebug.warning("SessionRequestHandler.processRequest:" + "app token invalid, sending Session response" + " with Exception");
}
sres.setException(SessionBundle.getString("appTokenInvalid") + requester);
return auditedExceptionResponse(auditor, sres);
}
}
try {
sres = (SessionResponse) RestrictedTokenContext.doUsing(context, new RestrictedTokenAction() {
public Object run() throws Exception {
return processSessionRequest(auditor, sreq, servletRequest, servletResponse);
}
});
} catch (Exception ex) {
sessionDebug.error("SessionRequestHandler encounterd exception", ex);
sres.setException(ex.getMessage());
}
if (sres.getException() == null) {
auditor.auditAccessSuccess();
} else {
auditor.auditAccessFailure(sres.getException());
}
return new Response(sres.toXMLString());
}
use of com.iplanet.services.comm.share.Response 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;
}
use of com.iplanet.services.comm.share.Response in project OpenAM by OpenRock.
the class AuthXMLHandler method process.
/**
* process the request and return the response
* @param requests Vector of
* <code>com.iplanet.services.comm.server.RequestHandler</code> objects.
* @param servletRequest <code>HttpServletRequest</code>object for
* this request.
* @param servletResponse <code>HttpServletResponse</code> object for this
* request.
* @param servletContext <code>servletContext</code> object for this request
* @return <code>ResponseSet</code> object for the processed request.
*/
public ResponseSet process(PLLAuditor auditor, List<Request> requests, HttpServletRequest servletRequest, HttpServletResponse servletResponse, ServletContext servletContext) {
ResponseSet rset = new ResponseSet(AuthXMLTags.AUTH_SERVICE);
auditor.setComponent(AUTHENTICATION);
for (Request req : requests) {
Response res = processRequest(auditor, req, servletRequest, servletResponse);
rset.addResponse(res);
}
return rset;
}
use of com.iplanet.services.comm.share.Response in project OpenAM by OpenRock.
the class NamingService method processRequest.
private Response processRequest(Request req) {
String content = req.getContent();
NamingRequest nreq = NamingRequest.parseXML(content);
NamingResponse nres = new NamingResponse(nreq.getRequestID());
// get the version from nreq and check old
float reqVersion = Float.valueOf(nreq.getRequestVersion()).floatValue();
boolean limitNametable = (reqVersion > 1.0);
// get the sesisonId from nreq
String sessionId = nreq.getSessionId();
try {
if (sessionId == null) {
nres.setNamingTable(NamingService.getNamingTable(limitNametable));
} else {
Hashtable tempHash = new Hashtable();
tempHash = transferTable(NamingService.getNamingTable(limitNametable));
Hashtable replacedTable = null;
URL url = usePreferredNamingURL(nreq, reqVersion);
if (url != null) {
String uri = (reqVersion < 3.0) ? SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR) : WebtopNaming.getURI(url);
if (uri.equals(Constants.EMPTY)) {
uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
if (namingDebug.messageEnabled()) {
namingDebug.message("uri is blank; adding " + uri);
}
}
replacedTable = replaceTable(tempHash, url.getProtocol(), url.getHost(), Integer.toString(url.getPort()), uri);
} else {
replacedTable = replaceTable(tempHash, sessionId);
}
if (replacedTable == null) {
nres.setException("SessionID ---" + sessionId + "---is Invalid");
} else {
nres.setNamingTable(replacedTable);
}
nres.setAttribute(Constants.NAMING_AM_LB_COOKIE, sessionCookies.getLBCookie(sessionId));
}
} catch (Exception e) {
String errorMsg = "Failed to process naming request";
namingDebug.error(errorMsg, e);
if (e.getMessage() != null) {
errorMsg = e.getMessage();
}
nres.setException(errorMsg);
}
// %uri with the actual value
if (reqVersion < 3.0) {
String uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
if (!uri.startsWith("/")) {
uri = "/" + uri;
}
nres.replaceURI(uri);
}
return new Response(nres.toXMLString());
}
Aggregations