in modules/rampart-trust/src/main/java/org/apache/rahas/TokenRequestDispatcher.java [49:135]
public SOAPEnvelope handle(MessageContext inMsgCtx,
MessageContext outMsgCtx) throws TrustException {
if(mlog.isDebugEnabled()){
mlog.debug("*********************** TokenRequestDispatcher received \n"+inMsgCtx.getEnvelope());
}
RahasData data = new RahasData(inMsgCtx);
String reqType = data.getRequestType();
String tokenType = data.getTokenType();
if ((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_ISSUE).equals(reqType) ||
(RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_ISSUE).equals(reqType)) {
log.debug("issue");
TokenIssuer issuer;
if (tokenType == null || tokenType.trim().length() == 0) {
issuer = config.getDefaultIssuerInstace();
} else {
issuer = config.getIssuer(tokenType);
}
SOAPEnvelope response = issuer.issue(data);
//set the response wsa/soap action in the out message context
outMsgCtx.getOptions().setAction(issuer.getResponseAction(data));
if(mlog.isDebugEnabled()){
mlog.debug("*********************** TokenRequestDispatcher sent out \n"+response);
}
return response;
} else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_VALIDATE).equals(reqType) ||
(RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_VALIDATE).equals(reqType)) {
log.debug("validate");
TokenValidator validator;
if (tokenType == null || tokenType.trim().length() == 0) {
validator = config.getDefaultValidatorInstance();
} else {
validator = config.getValidator(tokenType);
}
SOAPEnvelope response = validator.validate(data);
outMsgCtx.getOptions().setAction(
TrustUtil.getActionValue(data.getVersion(),
RahasConstants.RSTR_ACTION_VALIDATE));
return response;
} else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_RENEW).equals(reqType) ||
(RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_RENEW).equals(reqType)) {
log.debug("renew");
TokenRenewer renewer;
if (tokenType == null || tokenType.trim().length() == 0) {
renewer = config.getDefaultRenewerInstance();
} else {
renewer = config.getRenewer(tokenType);
}
SOAPEnvelope response = renewer.renew(data);
outMsgCtx.getOptions().setAction(
TrustUtil.getActionValue(data.getVersion(),
RahasConstants.RSTR_ACTION_RENEW));
return response;
} else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_CANCEL).equals(reqType) ||
(RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_CANCEL).equals(reqType)) {
log.debug("cancel");
TokenCanceler canceler = config.getDefaultCancelerInstance();
SOAPEnvelope response = canceler.cancel(data);
//set the response wsa/soap action in the out message context
outMsgCtx.getOptions().setAction(canceler.getResponseAction(data));
return response;
} else {
throw new TrustException(TrustException.INVALID_REQUEST);
}
}