You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2012/06/13 14:47:54 UTC
svn commit: r1349810 -
/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java
Author: coheigea
Date: Wed Jun 13 12:47:54 2012
New Revision: 1349810
URL: http://svn.apache.org/viewvc?rev=1349810&view=rev
Log:
[WSS-392] - WSS4J can't handle SAML KeyIdentifier references to encrypted SAML Assertions stored in the cache
Modified:
webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java
Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java?rev=1349810&r1=1349809&r2=1349810&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/str/SignatureSTRParser.java Wed Jun 13 12:47:54 2012
@@ -214,23 +214,7 @@ public class SignatureSTRParser implemen
principal = new CustomTokenPrincipal(id);
} else if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())
|| WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) {
- AssertionWrapper assertion =
- SAMLUtil.getAssertionFromKeyIdentifier(
- secRef, strElement, data, wsDocInfo
- );
- if (bspCompliant) {
- BSPEnforcer.checkSamlTokenBSPCompliance(secRef, assertion);
- }
- SAMLKeyInfo samlKi =
- SAMLUtil.getCredentialFromSubject(assertion, data,
- wsDocInfo, bspCompliant);
- X509Certificate[] foundCerts = samlKi.getCerts();
- if (foundCerts != null && foundCerts.length > 0) {
- certs = new X509Certificate[]{foundCerts[0]};
- }
- secretKey = samlKi.getSecret();
- publicKey = samlKi.getPublicKey();
- principal = createPrincipalFromSAML(assertion);
+ parseSAMLKeyIdentifier(secRef, wsDocInfo, data, bspCompliant);
} else {
parseBSTKeyIdentifier(secRef, crypto, wsDocInfo, data, bspCompliant);
}
@@ -355,6 +339,37 @@ public class SignatureSTRParser implemen
}
/**
+ * Parse the KeyIdentifier for a SAML Assertion
+ */
+ private void parseSAMLKeyIdentifier(
+ SecurityTokenReference secRef,
+ WSDocInfo wsDocInfo,
+ RequestData data,
+ boolean bspCompliant
+ ) throws WSSecurityException {
+ String valueType = secRef.getKeyIdentifierValueType();
+ secretKey = getSecretKeyFromToken(secRef.getKeyIdentifierValue(), valueType, data);
+ if (secretKey == null) {
+ AssertionWrapper assertion =
+ SAMLUtil.getAssertionFromKeyIdentifier(
+ secRef, secRef.getElement(), data, wsDocInfo
+ );
+ if (bspCompliant) {
+ BSPEnforcer.checkSamlTokenBSPCompliance(secRef, assertion);
+ }
+ SAMLKeyInfo samlKi =
+ SAMLUtil.getCredentialFromSubject(assertion, data, wsDocInfo, bspCompliant);
+ X509Certificate[] foundCerts = samlKi.getCerts();
+ if (foundCerts != null && foundCerts.length > 0) {
+ certs = new X509Certificate[]{foundCerts[0]};
+ }
+ secretKey = samlKi.getSecret();
+ publicKey = samlKi.getPublicKey();
+ principal = createPrincipalFromSAML(assertion);
+ }
+ }
+
+ /**
* Parse the KeyIdentifier for a BinarySecurityToken
*/
private void parseBSTKeyIdentifier(