if(wsscVer.getNamespaceURI().equals(WSSCVersion.WSSC_13_NS_URI)){
wsTrustVer = WSTrustVersion.WS_TRUST_13;
}else{
wsTrustVer = WSTrustVersion.WS_TRUST_10;
}
WSTrustElementFactory eleFac = WSTrustElementFactory.newInstance(wsTrustVer);
jaxbContext = WSTrustElementFactory.getContext(wsTrustVer);
try {
marshaller = jaxbContext.createMarshaller();
unmarshaller = jaxbContext.createUnmarshaller();
} catch (JAXBException ex){
log.log(Level.SEVERE,"WSSC0016.problem.mar.unmar", ex);
throw new RuntimeException("Problem creating JAXB Marshaller/Unmarshaller", ex);
}
final Message request = Messages.create(marshaller, eleFac.toJAXBElement(rst), sctConfig.getWSBinding().getSOAPVersion());
// Log Request created
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_1009_SEND_REQ_MESSAGE(printMessageAsString(request)));
}
Packet reqPacket = new Packet(request);
if (sctConfig.getSCToken() != null){
reqPacket.invocationProperties.put(SC_ASSERTION, sctConfig.getSCToken());
}
if (sctConfig.getPacket() != null){
for(WSTrustConstants.STS_PROPERTIES stsProperty : WSTrustConstants.STS_PROPERTIES.values()) {
reqPacket.invocationProperties.put(stsProperty.toString(),sctConfig.getPacket().invocationProperties.get(stsProperty.toString()));
}
}
//reqPacket.setEndPointAddressString(endPointAddress);
reqPacket.endpointAddress = packet.endpointAddress;
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE,
LogStringsMessages.WSSC_1008_SET_EP_ADDRESS(endPointAddress));
}
// Add addressing headers to the message
try{
reqPacket = addAddressingHeaders(reqPacket, sctConfig.getWSDLPort(), sctConfig.getWSBinding(), action, sctConfig.getAddressingVersion());
}catch (WSSecureConversationException ex){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0017_PROBLEM_ADD_ADDRESS_HEADERS(), ex);
throw new RuntimeException(LogStringsMessages.WSSC_0017_PROBLEM_ADD_ADDRESS_HEADERS(), ex);
}
// Ideally this property for enabling FI or not should be available to the pipeline.
// As a workaround for now, we
// copy the property for the client packet to the reqPacket mananually here.
if (sctConfig.getPacket() != null){
reqPacket.contentNegotiation = sctConfig.getPacket().contentNegotiation;
}
copyStandardSecurityProperties(sctConfig.getPacket(),reqPacket);
// Send the message
Packet respPacket = null;
if(sctConfig.getClientTube() != null){
reqPacket = ((SecurityClientTube)sctConfig.getClientTube()).processClientRequestPacket(reqPacket);
Tube tubeline = sctConfig.getNextTube();
Fiber fiber = getFiberEngine().createFiber();
respPacket = fiber.runSync(tubeline, reqPacket);
respPacket = ((SecurityClientTube)sctConfig.getClientTube()).processClientResponsePacket(respPacket);
}else{
WSITClientAuthContext wsitAuthCtx = (WSITClientAuthContext)sctConfig.getOtherOptions().get(MessageConstants.WSIT_CLIENT_AUTHCONTEXT);
if (wsitAuthCtx != null){
try{
respPacket = wsitAuthCtx.secureRequest(reqPacket, null, true);
} catch (XWSSecurityException e) {
throw new RuntimeException( e);
}
}
}
// Obtain the RequestSecurtyTokenResponse
final Message response = respPacket.getMessage();
BaseSTSResponse rstr = null;
if (!response.isFault()){
JAXBElement rstrEle = null;
try {
rstrEle = (JAXBElement)response.readPayloadAsJAXB(unmarshaller);
}catch (JAXBException ex){
log.log(Level.SEVERE,
LogStringsMessages.WSSC_0018_ERR_JAXB_RSTR(), ex);
throw new RuntimeException(LogStringsMessages.WSSC_0018_ERR_JAXB_RSTR(), ex);
}
if(wsscVer.getNamespaceURI().equals(WSSCVersion.WSSC_13.getNamespaceURI())){
try {
rstr = eleFac.createRSTRCollectionFrom(rstrEle);
} catch (Exception e) {
rstr = eleFac.createRSTRFrom(rstrEle);
}
}else{
rstr = eleFac.createRSTRFrom(rstrEle);
}
} else {
try{
//SOAPFaultBuilder builder = SOAPFaultBuilder.create(response);
//throw (SOAPFaultException)builder.createException(null, response);