ResponseToken respToken = null;
String userName = null;
String password = null;
HttpSession session = null;
IdentityPassiveSTSClient passiveSTSClient = null;
Map paramMap = req.getParameterMap();
String frontEndUrl = null;
frontEndUrl = getAdminConsoleURL(req);
session = req.getSession();
userName = (String) req.getParameter(PassiveRequestorConstants.USER_NAME);
password = (String) req.getParameter(PassiveRequestorConstants.PASSWORD);
if (userName == null || password == null) {
session.setAttribute(PassiveRequestorConstants.ACTION, getAttribute(paramMap,
PassiveRequestorConstants.ACTION));
session.setAttribute(PassiveRequestorConstants.ATTRIBUTE, getAttribute(paramMap,
PassiveRequestorConstants.ATTRIBUTE));
session.setAttribute(PassiveRequestorConstants.CONTEXT, getAttribute(paramMap,
PassiveRequestorConstants.CONTEXT));
session.setAttribute(PassiveRequestorConstants.REPLY_TO, getAttribute(paramMap,
PassiveRequestorConstants.REPLY_TO));
session.setAttribute(PassiveRequestorConstants.PSEUDO, getAttribute(paramMap,
PassiveRequestorConstants.PSEUDO));
session.setAttribute(PassiveRequestorConstants.REALM, getAttribute(paramMap,
PassiveRequestorConstants.REALM));
session.setAttribute(PassiveRequestorConstants.REQUEST, getAttribute(paramMap,
PassiveRequestorConstants.REQUEST));
session.setAttribute(PassiveRequestorConstants.REQUEST_POINTER, getAttribute(paramMap,
PassiveRequestorConstants.REQUEST_POINTER));
session.setAttribute(PassiveRequestorConstants.POLCY, getAttribute(paramMap,
PassiveRequestorConstants.POLCY));
resp.sendRedirect(frontEndUrl + "passive-sts/login.jsp");
return;
}
paramMap = (Map) session.getAttribute(PassiveRequestorConstants.PASSIVE_REQ_ATTR_MAP);
session.removeAttribute(PassiveRequestorConstants.PASSIVE_REQ_ATTR_MAP);
reqToken = new RequestToken();
reqToken.setAction((String) session.getAttribute(PassiveRequestorConstants.ACTION));
reqToken.setAttributes((String) session.getAttribute(PassiveRequestorConstants.ATTRIBUTE));
reqToken.setContext((String) session.getAttribute(PassiveRequestorConstants.CONTEXT));
reqToken.setReplyTo((String) session.getAttribute(PassiveRequestorConstants.REPLY_TO));
reqToken.setPseudo((String) session.getAttribute(PassiveRequestorConstants.PSEUDO));
reqToken.setRealm((String) session.getAttribute(PassiveRequestorConstants.REALM));
reqToken.setRequest((String) session.getAttribute(PassiveRequestorConstants.REQUEST));
reqToken.setRequestPointer((String) session
.getAttribute(PassiveRequestorConstants.REQUEST_POINTER));
reqToken.setPolicy((String) session.getAttribute(PassiveRequestorConstants.POLCY));
reqToken.setUserName(userName);
reqToken.setPassword(password);
String serverURL = CarbonUIUtil.getServerURL(session.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) session.getServletContext()
.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
passiveSTSClient = new IdentityPassiveSTSClient(serverURL, configContext);
respToken = passiveSTSClient.getResponse(reqToken);
if (respToken != null && respToken.getAuthenticated()) {
sendData(req, resp, respToken, frontEndUrl, reqToken.getAction());
} else {
resp.sendRedirect(frontEndUrl + "passive-sts/login.jsp");