if (strId != null) {
try {
X509Certificate cert = context.getSecurityEnvironment().getCertificate(
context.getExtraneousProperties(), keyIdBytes, MessageConstants.KEY_INDETIFIER_TYPE);
WSSElementFactory elementFactory = new WSSElementFactory(context.getSOAPVersion());
SecurityElement bst = elementFactory.createBinarySecurityToken(null, cert.getEncoded());
SSEData data = new SSEData(bst, false, context.getNamespaceContext());
context.getSTRTransformCache().put(strId, data);
} catch (XWSSecurityException ex) {
} catch (CertificateEncodingException ex) {
} catch (Exception ex) {
//ignore the exception
}
}
} else if (MessageConstants.ThumbPrintIdentifier_NS.equals(valueType)) {
//for policy verification
AuthenticationTokenPolicy.X509CertificateBinding x509Binding = new AuthenticationTokenPolicy.X509CertificateBinding();
x509Binding.setValueType(MessageConstants.ThumbPrintIdentifier_NS);
x509Binding.setReferenceType(MessageConstants.KEY_INDETIFIER_TYPE);
if (inferredKB == null) {
context.getSecurityContext().setInferredKB(x509Binding);
} else if (PolicyTypeUtil.symmetricKeyBinding(inferredKB)) {
((SymmetricKeyBinding) inferredKB).setKeyBinding(x509Binding);
isSymmetric = true;
} else if (PolicyTypeUtil.derivedTokenKeyBinding(inferredKB)) {
DerivedTokenKeyBinding dktBind = (DerivedTokenKeyBinding) inferredKB;
if (dktBind.getOriginalKeyBinding() == null) {
((DerivedTokenKeyBinding) inferredKB).setOriginalKeyBinding(x509Binding);
} else if (PolicyTypeUtil.symmetricKeyBinding(dktBind.getOriginalKeyBinding())) {
dktBind.getOriginalKeyBinding().setKeyBinding(x509Binding);
isSymmetric = true;
}
}
// get the key
byte[] keyIdBytes = XMLUtil.getDecodedBase64EncodedData(referenceValue);
if (purpose == Purpose.VERIFY || purpose == Purpose.ENCRYPT) {
context.setExtraneousProperty(MessageConstants.REQUESTER_KEYID, new String(keyIdBytes));
X509Certificate cert = context.getSecurityEnvironment().getCertificate(
context.getExtraneousProperties(), keyIdBytes, MessageConstants.THUMB_PRINT_TYPE);
if (!isSymmetric) {
context.getSecurityEnvironment().updateOtherPartySubject(
DefaultSecurityEnvironmentImpl.getSubject(context), cert);
}
returnKey = cert.getPublicKey();
} else if (purpose == Purpose.SIGN || purpose == Purpose.DECRYPT) {
returnKey = context.getSecurityEnvironment().getPrivateKey(
context.getExtraneousProperties(),
keyIdBytes, MessageConstants.THUMB_PRINT_TYPE);
}
if (strId != null) {
try {
X509Certificate cert = context.getSecurityEnvironment().getCertificate(
context.getExtraneousProperties(), keyIdBytes, MessageConstants.THUMB_PRINT_TYPE);
WSSElementFactory elementFactory = new WSSElementFactory(context.getSOAPVersion());
SecurityElement bst = elementFactory.createBinarySecurityToken(null, cert.getEncoded());
SSEData data = new SSEData(bst, false, context.getNamespaceContext());
context.getSTRTransformCache().put(strId, data);
} catch (XWSSecurityException ex) {
} catch (CertificateEncodingException ex) {
} catch (Exception ex) {