use of com.sun.identity.liberty.ws.soapbinding.Message 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.Message 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.Message in project OpenAM by OpenRock.
the class DiscoveryClient method createRequest.
private Message createRequest() throws DiscoveryException {
if (!processed) {
processResourceOffering();
processed = true;
}
// create new Message according to different secuMechID
Message req = null;
ProviderHeader provH = null;
if (providerID != null) {
try {
provH = new ProviderHeader(providerID);
} catch (SOAPBindingException sbe) {
throw new DiscoveryException(sbe.getMessage());
}
}
if (clientMech == Message.X509_TOKEN) {
DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: mech=x509");
try {
req = new Message(provH, token);
} catch (SOAPBindingException sbe) {
throw new DiscoveryException(sbe.getMessage());
}
} else if ((clientMech == Message.SAML_TOKEN) || (clientMech == Message.BEARER_TOKEN)) {
if (DiscoSDKUtils.debug.messageEnabled()) {
DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: " + "mech=saml or bearer");
}
try {
req = new Message(provH, assertion);
} catch (SOAPBindingException sbe) {
throw new DiscoveryException(sbe.getMessage());
}
} else {
if (DiscoSDKUtils.debug.messageEnabled()) {
DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: " + "mech=anon");
}
try {
req = new Message(provH);
} catch (SOAPBindingException sbe) {
throw new DiscoveryException(sbe.getMessage());
}
}
if (clientAuth) {
req.setClientAuthentication(clientAuth);
}
req.setWSFVersion(wsfVersion);
return req;
}
use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.
the class DiscoveryClient method getResourceOffering.
/**
* Queries discovery service for resource offering.
* @param query discovery query object
* @return Query response Element corresponding to the query
* @exception DiscoveryException if error occurs
*/
public QueryResponse getResourceOffering(Query query) throws DiscoveryException {
Message req = createRequest();
req.setSOAPBody(DiscoSDKUtils.parseXML(query.toString()));
return new QueryResponse(getResponse(req));
}
use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.
the class DiscoveryClient method modify.
/**
* Modifies discovery resource offering.
* @param modify List of Modify object
* @return List of <code>ModifyResponse</code> object
* @exception DiscoveryException if error occurs
*/
public ModifyResponse modify(Modify modify) throws DiscoveryException {
Message req = createRequest();
req.setSOAPBody(DiscoSDKUtils.parseXML(modify.toString()));
return new ModifyResponse(getResponse(req));
}
Aggregations