}
private static Key processSecurityTokenReference(KeyInfoHeaderBlock keyInfo, CallbackHandler callbackHandler)throws XWSSecurityException {
Key returnKey = null;
SecurityEnvironment secEnv = new DefaultSecurityEnvironmentImpl(callbackHandler);
SecurityTokenReference str = keyInfo.getSecurityTokenReference(0);
ReferenceElement refElement = str.getReference();
if (refElement instanceof KeyIdentifier) {
KeyIdentifier keyId = (KeyIdentifier)refElement;
byte[] decodedValue = keyId.getDecodedReferenceValue().getBytes();
if (MessageConstants.X509SubjectKeyIdentifier_NS.equals(keyId.getValueType()) ||
MessageConstants.X509v3SubjectKeyIdentifier_NS.equals(keyId.getValueType())) {
returnKey = secEnv.getPrivateKey(null, decodedValue);
} else if(MessageConstants.ThumbPrintIdentifier_NS.equals(keyId.getValueType())){
throw new XWSSecurityException("Unsupported KeyValueType :" + keyId.getValueType());
}
} /*else if(refElement instanceof DirectReference){
String uri = ((DirectReference) refElement).getURI();
}*/ else if (refElement instanceof X509IssuerSerial) {
BigInteger serialNumber = ((X509IssuerSerial) refElement).getSerialNumber();
String issuerName = ((X509IssuerSerial) refElement).getIssuerName();
returnKey = secEnv.getPrivateKey(null, serialNumber, issuerName);
}else {
log.log(
Level.SEVERE, "WSS0338.unsupported.reference.mechanism");
throw new XWSSecurityException(
"Key reference mechanism not supported");