public SOAPEnvelope validate(RahasData data) throws TrustException {
// retrieve the message context
MessageContext inMsgCtx = data.getInMessageContext();
// retrieve the list of tokens from the message context
TokenStorage tkStorage = TrustUtil.getTokenStore(inMsgCtx);
// Create envelope
SOAPEnvelope env = TrustUtil.createSOAPEnvelope(inMsgCtx
.getEnvelope().getNamespace().getNamespaceURI());
// Create RSTR element, with respective version
OMElement rstrElem;
int wstVersion = data.getVersion();
if (RahasConstants.VERSION_05_02 == wstVersion) {
rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
wstVersion, env.getBody());
} else {
OMElement rstrcElem = TrustUtil
.createRequestSecurityTokenResponseCollectionElement(
wstVersion, env.getBody());
rstrElem = TrustUtil.createRequestSecurityTokenResponseElement(
wstVersion, rstrcElem);
}
// Create TokenType element, set to RSTR/Status
TrustUtil.createTokenTypeElement(wstVersion, rstrElem).setText(
TrustUtil.getWSTNamespace(wstVersion)
+ RahasConstants.TOK_TYPE_STATUS);
// Create Status element
OMElement statusElement = createMessageElement(wstVersion,
rstrElem, RahasConstants.LocalNames.STATUS);
// Obtain the token
Token tk = tkStorage.getToken(data.getTokenId());
// create the crypto object
PublicKey issuerPBKey = getIssuerPublicKey(inMsgCtx);
boolean valid = isValid(tk, issuerPBKey);