use of com.sun.identity.liberty.ws.soapbinding.SOAPFaultException in project OpenAM by OpenRock.
the class InteractionManager method newRedirectFault.
private SOAPFaultException newRedirectFault(String messageID) {
RedirectRequestElement re = null;
try {
re = objectFactory.createRedirectRequestElement();
} catch (JAXBException je) {
debug.error("InteractionManager.newRedirectFault():" + " can not create RedirectRequestElement", je);
}
CorrelationHeader ch = new CorrelationHeader();
String responseID = ch.getMessageID();
ch.setRefToMessageID(messageID);
String redirectUrl = null;
String lbRedirectUrl = interactionConfig.getLbWSPRedirectHandler();
String wspRedirectUrl = interactionConfig.getWSPRedirectHandler();
if (debug.messageEnabled()) {
debug.message("InteractionManager.newRedirectURLFault():" + "wspRedirectURL:" + wspRedirectUrl + ", lbRedirectUrl:" + lbRedirectUrl);
}
if (lbRedirectUrl == null) {
redirectUrl = wspRedirectUrl + "?" + TRANS_ID + "=" + responseID;
if (debug.messageEnabled()) {
debug.message("InteractionManager.newRedirectURLFault():" + "lbRedirectURL is null, rediectUrl:" + redirectUrl);
}
} else {
//lbRedirectUrl defined
redirectUrl = lbRedirectUrl + "?" + TRANS_ID + "=" + responseID + "&" + InteractionConfig.HANDLER_HOST_ID + "=" + InteractionConfig.getInstance().getLocalServerId();
if (debug.messageEnabled()) {
debug.message("InteractionManager.newRedirectURLFault():" + "lbRedirectURL is not null, rediectUrl:" + redirectUrl);
}
}
re.setRedirectURL(redirectUrl);
List details = new ArrayList();
try {
details.add(Utils.convertJAXBToElement(re));
} catch (JAXBException je) {
debug.error("InteractionManager.newRedirectFault():" + " can not create newRedirectFault:" + " can not convert JAXBObject to Element", je);
}
SOAPFault sf = new SOAPFault(QNAME_SERVER, SERVER_ERROR, FAULT_ACTOR, new SOAPFaultDetail(details));
Message sfmsg = new Message(sf);
sfmsg.setCorrelationHeader(ch);
SOAPFaultException sfe = new SOAPFaultException(sfmsg);
return sfe;
}
use of com.sun.identity.liberty.ws.soapbinding.SOAPFaultException in project OpenAM by OpenRock.
the class InteractionManager method sendRequest.
/**
* Sends SOAP request to <code>WSP</code>.
* This would be invoked at <code>WSC</code> side.
*
* @param requestMessage request message.
* @param connectTo SOAP URL to which to send the SOAP request
* @param certAlias SOAP Client Certificate Alias
* @param soapAction SOAP Action Attribute
* @param returnToURL URL to which to redirect user agent after
* <code>WSP</code> - resource owner interactions
* @param httpRequest HTTP request object of current user agent request
* @param httpResponse HTTP response object of current user agent request
* @return response SOAP response message sent by <code>WSP</code>.
*
* @throws InteractionException for generic interaction error
* @throws InteractionRedirectException if user agent is redirected to
* <code>WSP</code> for resource owner interactions
* @throws SOAPBindingException for generic SOAP binding errors
* @throws SOAPFaultException if the response message has SOAP fault
*
* @supported.api
*/
public Message sendRequest(Message requestMessage, String connectTo, String certAlias, String soapAction, String returnToURL, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws InteractionException, InteractionRedirectException, SOAPBindingException, SOAPFaultException {
if (debug.messageEnabled()) {
debug.message("InteractionManager.sendRequest():" + " entering with messageID=" + requestMessage.getCorrelationHeader().getMessageID() + ":refToMessageID=" + requestMessage.getCorrelationHeader().getRefToMessageID() + ":requestMessage=" + requestMessage);
}
// construct and set UserInteraction element in requestMessage
if (interactionConfig.wscIncludesUserInteractionHeader()) {
Enumeration locales = httpRequest.getLocales();
List acceptLanguages = new ArrayList();
while (locales.hasMoreElements()) {
acceptLanguages.add(locales.nextElement().toString());
}
if (debug.messageEnabled()) {
debug.message("InteractionManager.sendRequest():" + "Accept-Language specified by httpRequest=" + acceptLanguages);
}
UserInteractionElement ue = createUserInteractionElement(acceptLanguages);
String id = SAMLUtils.generateID();
ue.setId(id);
if (ue != null) {
try {
Element element = Utils.convertJAXBToElement(ue);
requestMessage.setOtherSOAPHeader(element, id);
} catch (JAXBException je) {
debug.error("InteractionManager.sendRequest():" + "not setting userInteractionHeader:" + "can not convert JAXBObject to Element", je);
}
}
}
Message responseMessage = null;
try {
if (debug.messageEnabled()) {
debug.message("InteractionManager.sendRequest():" + "invoking soap Client.sendRequest():" + ":requestMessage=" + requestMessage + ":connecTo=" + connectTo);
}
if (LogUtil.isLogEnabled()) {
String[] objs = new String[1];
objs[0] = requestMessage.getCorrelationHeader().getMessageID();
LogUtil.access(Level.INFO, LogUtil.IS_SENDING_MESSAGE, objs);
}
responseMessage = Client.sendRequest(requestMessage, connectTo, certAlias, soapAction);
} catch (SOAPFaultException sfe) {
if (debug.messageEnabled()) {
debug.message("InteractionManager.sendRequest():" + " catching SOAPFaultException=" + sfe);
}
String redirectURL = getRedirectURL(sfe);
if (redirectURL == null) {
throw sfe;
}
String responseID = getResponseID(sfe);
responseMessage = handleRedirectRequest(requestMessage, redirectURL, responseID, connectTo, certAlias, soapAction, returnToURL, httpRequest, httpResponse);
}
if (debug.messageEnabled()) {
debug.message("InteractionManager.sendRequest():" + " returning response message=" + responseMessage);
}
if (LogUtil.isLogEnabled()) {
String[] objs = new String[2];
objs[0] = responseMessage.getCorrelationHeader().getMessageID();
objs[1] = requestMessage.getCorrelationHeader().getMessageID();
LogUtil.access(Level.INFO, LogUtil.IS_RETURNING_RESPONSE_MESSAGE, objs);
}
return responseMessage;
}
use of com.sun.identity.liberty.ws.soapbinding.SOAPFaultException in project OpenAM by OpenRock.
the class PPRequestHandler method getServiceInstanceUpdateHeader.
/**
* Gets the service instance update header.
*
* @exception SOAPFaultException.
*/
private ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader() throws SOAPFaultException {
ServiceInstanceUpdate siu = IDPPServiceManager.getInstance().getServiceInstanceUpdate();
ServiceInstanceUpdateHeader siuHeader = siu.getServiceInstanceUpdateHeader();
if (siu.isSOAPFaultNeeded()) {
QName faultCodeServer = new QName(SOAPBindingConstants.NS_SOAP, "Server");
SOAPFaultDetail detail = new SOAPFaultDetail(SOAPFaultDetail.ENDPOINT_MOVED, null, null);
SOAPFault sf = new SOAPFault(faultCodeServer, IDPPUtils.bundle.getString("endPointMoved"), null, detail);
Message sfmsg = new Message(sf);
sfmsg.setServiceInstanceUpdateHeader(siuHeader);
SOAPFaultException sfe = new SOAPFaultException(sfmsg);
throw sfe;
}
return siuHeader;
}
use of com.sun.identity.liberty.ws.soapbinding.SOAPFaultException in project OpenAM by OpenRock.
the class PPRequestHandler method initInteraction.
/**
* Initialize interaction for the queries that require interaction
* @param isQuery true if this is a <code>PP</code> query request,
* false if this is a <code>PP</code> modify request.
* @param interactResourceMap map of resources that need an interaction
* This map will have key as the resource
* and the value as interaction type.
* @param msg SOAP request message
* @exception SOAPFaultException for interaction redirection
* @exception IDPPException for any other failure.
*/
private void initInteraction(boolean isQuery, Map interactResourceMap, Message msg) throws SOAPFaultException, IDPPException {
IDPPUtils.debug.message("PPRequestHandler.initInteraction:Init");
if (msg == null || interactResourceMap == null || interactResourceMap.isEmpty()) {
IDPPUtils.debug.error("PPRequestHandler.initInteraction:Null" + "Input parameters");
throw new IDPPException(IDPPUtils.bundle.getString("nullInputParams"));
}
try {
//Create Interaction inquiry element
InquiryElement inquiry = JAXBObjectFactory.getObjectFactory().createInquiryElement();
inquiry.setTitle(IDPPUtils.bundle.getString(IDPPConstants.INTERACTION_TITLE));
List selectElements = inquiry.getSelectOrConfirmOrText();
Set inquirySelects = interactResourceMap.keySet();
Iterator iter = inquirySelects.iterator();
while (iter.hasNext()) {
String resource = (String) iter.next();
String interactionType = (String) interactResourceMap.get(resource);
if (interactionType.equals(IDPPConstants.INTERACT_FOR_CONSENT)) {
selectElements.add(getInteractConfirmElement(isQuery, resource, msg));
} else if (interactionType.equals(IDPPConstants.INTERACT_FOR_VALUE)) {
selectElements.addAll(getInteractTextElements(isQuery, resource, msg));
}
}
String lang = getLanguage(msg);
if (LogUtil.isLogEnabled()) {
String[] data = { logMsg };
LogUtil.access(Level.INFO, LogUtil.PP_INTERACTION_SUCCESS, data);
}
InteractionManager.getInstance().handleInteraction(msg, inquiry, lang);
} catch (InteractionSOAPFaultException ise) {
if (IDPPUtils.debug.messageEnabled()) {
IDPPUtils.debug.message("PPRequestHandler.initInteraction:" + "Interact redirection happened");
}
throw ise.getSOAPFaultException();
} catch (Exception ex) {
IDPPUtils.debug.error("PPRequestHandler.initInteraction:Failed");
throw new IDPPException(ex);
}
}
Aggregations