Author: prabath
Date: Wed Apr 21 09:54:21 2010
New Revision: 936232
URL: http://svn.apache.org/viewvc?rev=936232&view=rev
Log:
Validator to allow missing UsernameToken and X509Token if they are optional
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/PolicyBasedResultsValidator.java
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/PolicyBasedResultsValidator.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/PolicyBasedResultsValidator.java?rev=936232&r1=936231&r2=936232&view=diff
==============================================================================
---
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/PolicyBasedResultsValidator.java
(original)
+++
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/PolicyBasedResultsValidator.java
Wed Apr 21 09:54:21 2010
@@ -291,9 +291,10 @@ public class PolicyBasedResultsValidator
for (Iterator iter = tokens.iterator(); iter.hasNext();) {
Token token = (Token) iter.next();
if(token instanceof UsernameToken) {
+ UsernameToken ut = (UsernameToken) token;
//Check presence of a UsernameToken
WSSecurityEngineResult utResult =
WSSecurityUtil.fetchActionResult(results, WSConstants.UT);
- if(utResult == null) {
+ if(utResult == null && !ut.isOptional()) {
throw new RampartException("usernameTokenMissing");
}
@@ -304,8 +305,9 @@ public class PolicyBasedResultsValidator
throw new RampartException("samlTokenMissing");
}
} else if ( token instanceof X509Token) {
+ X509Token x509Token = (X509Token) token;
WSSecurityEngineResult x509Result =
WSSecurityUtil.fetchActionResult(results, WSConstants.BST);
- if(x509Result == null) {
+ if(x509Result == null && !x509Token.isOptional()) {
throw new RampartException("binaryTokenMissing");
}
}