use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.
the class InteractionManager method getInteractionResponseElement.
/**
* Gets interaction response that was gathered from resource owner
* by <code>InteractionManager</code>
*
* @param requestMessage request message.
*
* @return interaction response that was gathered by
* <code>InteractionManager</code>.
*
* @throws InteractionException for interaction error
*
* @supported.api
*/
public InteractionResponseElement getInteractionResponseElement(Message requestMessage) throws InteractionException {
InteractionResponseElement interactionResponseElement = null;
CorrelationHeader ch = requestMessage.getCorrelationHeader();
String messageID = ch.getRefToMessageID();
CacheEntry cacheEntry = null;
if (messageID != null) {
cacheEntry = cache.getCacheEntry(messageID);
if (cacheEntry != null) {
interactionResponseElement = cacheEntry.getInteractionResponseElement();
}
if (debug.messageEnabled()) {
debug.message("InteractionManager.getInteractionResponseElement():" + "for messageID=" + messageID + ":" + "responseElement=" + (interactionResponseElement != null));
}
}
if (LogUtil.isLogEnabled()) {
String[] objs = new String[3];
objs[0] = ch.getMessageID();
objs[1] = ch.getRefToMessageID();
objs[2] = (cacheEntry == null) ? "NULL" : "NOT NULL";
LogUtil.access(Level.INFO, LogUtil.IS_RETURNING_RESPONSE_ELEMENT, objs);
}
return interactionResponseElement;
}
use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.
the class PPRequestHandler method processInteractionConsentResponse.
/**
* Process the interaction response
* @param isQuery true if this is a <code>PP</code> query request,
* false if this is a <code>PP</code> modify request.
* @param msg SOAP Request Message
* @param resource interaction resource
* @return true if the consent is allowed.
*/
private boolean processInteractionConsentResponse(boolean isQuery, Message msg, String resource) {
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler.processInteraction" + "Response:Init");
}
if (msg == null || resource == null) {
IDPPUtils.debug.error("PPRequestHandler:processInteraction" + "Response:null input params");
return false;
}
resource = IDPPUtils.getExpressionContext(resource);
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler:processInteraction" + "PP Element that was trying to access:" + resource);
}
try {
InteractionResponseElement ire = InteractionManager.getInstance().getInteractionResponseElement(msg);
if (ire == null) {
return false;
}
Map responses = InteractionUtils.getParameters(ire);
if (responses == null || responses.isEmpty()) {
return false;
}
String value = (String) responses.get(resource);
if (value == null || value.equals("false")) {
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler.process" + "Interaction: response is deny");
}
return false;
} else {
return true;
}
} catch (Exception e) {
IDPPUtils.debug.error("PPRequestHandler.processInteraction" + "Response: Exception occured.", e);
return false;
}
}
use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.
the class PPRequestHandler method processInteractionValueResponse.
/**
* Process the interaction response for values.
* @param isQuery true if this is a <code>PP</code> query request,
* false if this is a <code>PP</code> modify request.
* @param msg SOAP Request Message
* @param resource interaction resource
* @return Map map of interacted data.
*/
private Map processInteractionValueResponse(boolean isQuery, Message msg, String resource) {
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler.processInteraction" + "Response:Init");
}
if (msg == null || resource == null) {
IDPPUtils.debug.error("PPRequestHandler:processInteraction" + "Response:null input params");
return null;
}
//Get the actual element
resource = IDPPUtils.getExpressionContext(resource);
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler:processInteraction" + "PP Element that was trying to access:" + resource);
}
try {
Map interactedData = new HashMap();
InteractionResponseElement ire = InteractionManager.getInstance().getInteractionResponseElement(msg);
if (ire == null) {
return null;
}
Map responses = InteractionUtils.getParameters(ire);
if (responses == null || responses.isEmpty()) {
return null;
}
String lang = getLanguage(msg);
PPInteractionHelper interactionHelper = new PPInteractionHelper(lang);
Map queries = interactionHelper.getInteractForValueQuestions(isQuery, resource);
Iterator iter = queries.keySet().iterator();
while (iter.hasNext()) {
String query = (String) iter.next();
String value = (String) responses.get(query);
if (value == null || value.length() == 0) {
continue;
}
interactedData.put(interactionHelper.getPPAttribute(query), value);
}
return interactedData;
} catch (Exception e) {
IDPPUtils.debug.error("PPRequestHandler.processInteraction" + "Response: Exception occured.", e);
return null;
}
}
use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.
the class WSPRedirectHandlerServlet method sendInteractionResponsePage.
private void sendInteractionResponsePage(String messageID, HttpServletRequest httpRequest, HttpServletResponse httpResponse, String returnToURL) throws IOException {
if (debug.messageEnabled()) {
debug.message("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "entering");
}
try {
//read and save query parameters;
InteractionResponseElement interactionResponseElement = JAXBObjectFactory.getObjectFactory().createInteractionResponseElement();
List list = interactionResponseElement.getParameter();
Enumeration parameterNames = httpRequest.getParameterNames();
while (parameterNames.hasMoreElements()) {
String parameterName = (String) parameterNames.nextElement();
/*
ParameterType parameterType
= JAXBObjectFactory.getObjectFactory()
.createParameterType();
*/
String parameterValue = httpRequest.getParameter(parameterName);
if (debug.messageEnabled()) {
debug.message("WSPRedirectHandlerServlet" + ".sendInteractionResponsePage():" + "parameterName=" + parameterName + ", parameterValue=" + parameterValue);
}
int index = parameterName.indexOf(PARAMETER_PREFIX);
if (index != -1) {
ParameterType parameterType = JAXBObjectFactory.getObjectFactory().createParameterType();
parameterName = parameterName.substring(index + PARAMETER_PREFIX.length());
parameterType.setName(parameterName);
parameterType.setValue(parameterValue);
list.add(parameterType);
}
}
if (LogUtil.isLogEnabled()) {
String[] objs = new String[1];
objs[0] = messageID;
LogUtil.access(Level.INFO, LogUtil.IS_COLLECTED_RESPONSE_FROM_USER_AGENT, objs);
}
//store InteractionResponse in interaction manager;
InteractionManager.getInstance().setInteractionResponseElement(messageID, interactionResponseElement);
if (returnToURL.indexOf("?") != -1) {
returnToURL = returnToURL + "&" + InteractionManager.RESEND_MESSAGE + "=" + InteractionManager.getInstance().getRequestMessageID(messageID);
} else {
returnToURL = returnToURL + "?" + InteractionManager.RESEND_MESSAGE + "=" + messageID;
}
if (debug.messageEnabled()) {
debug.message("WSPRedirectHandlerServlet." + " sendInteractionResponsePage():" + "redirecting user agent to returnToURL=" + returnToURL);
}
httpResponse.sendRedirect(returnToURL);
if (LogUtil.isLogEnabled()) {
String[] objs = new String[1];
objs[0] = messageID;
LogUtil.access(Level.INFO, LogUtil.IS_REDIRECTED_USER_AGENT_BACK, objs);
}
} catch (JAXBException je) {
debug.error("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "catching JAXBException =", je);
showErrorPage(httpRequest, httpResponse, "Error createing JAXBObject:" + je.getMessage());
} catch (Exception e) {
debug.error("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "catching Exception =", e);
}
}
Aggregations