final boolean stsValidated = valid;
try {
if (WSSConstants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) {
Crypto crypto = getCrypto(tokenContext.getWssSecurityProperties());
X509V3SecurityTokenImpl x509V3SecurityToken = new X509V3SecurityTokenImpl(
tokenContext.getWsSecurityContext(),
crypto,
tokenContext.getWssSecurityProperties().getCallbackHandler(),
securityTokenData, binarySecurityTokenType.getId(),
tokenContext.getWssSecurityProperties()
) {
@Override
public void verify() throws XMLSecurityException {
if (stsValidated) {
// Already validated
return;
}
try {
super.verify();
} catch (XMLSecurityException ex) {
Element tokenElement =
convertToDOM(binarySecurityTokenType, securityTokenData);
validateTokenToSTS(tokenElement, message);
}
}
};
x509V3SecurityToken.setElementPath(tokenContext.getElementPath());
x509V3SecurityToken.setXMLSecEvent(tokenContext.getFirstXMLSecEvent());
return x509V3SecurityToken;
} else if (WSSConstants.NS_X509PKIPathv1.equals(binarySecurityTokenType.getValueType())) {
Crypto crypto = getCrypto(tokenContext.getWssSecurityProperties());
X509PKIPathv1SecurityTokenImpl x509PKIPathv1SecurityToken =
new X509PKIPathv1SecurityTokenImpl(