CallbackHandler callbackHandler =
NegotiationUtils.getCallbackHandler(
message.getContextualProperty(SecurityConstants.CALLBACK_HANDLER), this.getClass()
);
SpnegoTokenContext spnegoToken = new SpnegoTokenContext();
Object spnegoClientAction =
message.getContextualProperty(SecurityConstants.SPNEGO_CLIENT_ACTION);
if (spnegoClientAction instanceof SpnegoClientAction) {
spnegoToken.setSpnegoClientAction((SpnegoClientAction)spnegoClientAction);
}
try {
spnegoToken.retrieveServiceTicket(jaasContext, callbackHandler, kerberosSpn);
} catch (WSSecurityException e) {
throw new Fault(e);
}
//
// Now initiate WS-Trust exchange
//
STSClient client = STSUtils.getClient(message, "spnego");
AddressingProperties maps =
(AddressingProperties)message.get("javax.xml.ws.addressing.context.outbound");
if (maps == null) {
maps = (AddressingProperties)message.get("javax.xml.ws.addressing.context");
}
synchronized (client) {
try {
String s = SpnegoTokenInterceptorProvider.setupClient(client, message, aim);
if (maps != null) {
client.setAddressingNamespace(maps.getNamespaceURI());
}
SecurityToken tok = client.requestSecurityToken(s, Base64.encode(spnegoToken.getToken()));
byte[] wrappedTok = spnegoToken.unwrapKey(tok.getSecret());
tok.setSecret(wrappedTok);
spnegoToken.clear();
return tok;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {