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 2014/06/30 12:01:16 UTC
svn commit: r1606661 -
/webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
Author: coheigea
Date: Mon Jun 30 10:01:16 2014
New Revision: 1606661
URL: http://svn.apache.org/r1606661
Log:
Minor fix to avoid creating an iterator
Modified:
webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
Modified: webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java?rev=1606661&r1=1606660&r2=1606661&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java (original)
+++ webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java Mon Jun 30 10:01:16 2014
@@ -384,24 +384,26 @@ public class PolicyEnforcer implements S
private void verifyPolicy(SecurityEvent securityEvent) throws WSSPolicyException, XMLSecurityException {
{
//We have to check the failed assertions for logging purposes firstly...
- Iterator<Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>>> assertionStateMapIterator = this.failedAssertionStateMap.iterator();
- alternative:
- while (assertionStateMapIterator.hasNext()) {
- Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>> map = assertionStateMapIterator.next();
- //every list entry counts as an alternative...
- Map<Assertion, List<Assertable>> assertionListMap = map.get(securityEvent.getSecurityEventType());
- if (assertionListMap != null && assertionListMap.size() > 0) {
- Iterator<Map.Entry<Assertion, List<Assertable>>> assertionStateIterator = assertionListMap.entrySet().iterator();
- while (assertionStateIterator.hasNext()) {
- Map.Entry<Assertion, List<Assertable>> assertionStateEntry = assertionStateIterator.next();
- List<Assertable> assertionStates = assertionStateEntry.getValue();
- Iterator<Assertable> assertableIterator = assertionStates.iterator();
- while (assertableIterator.hasNext()) {
- Assertable assertable = assertableIterator.next();
- boolean asserted = assertable.assertEvent(securityEvent);
- //...so if one fails, continue with the next map entry and increment the notAssertedCount
- if (!asserted) {
- continue alternative;
+ if (!this.failedAssertionStateMap.isEmpty()) {
+ Iterator<Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>>> assertionStateMapIterator = this.failedAssertionStateMap.iterator();
+ alternative:
+ while (assertionStateMapIterator.hasNext()) {
+ Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>> map = assertionStateMapIterator.next();
+ //every list entry counts as an alternative...
+ Map<Assertion, List<Assertable>> assertionListMap = map.get(securityEvent.getSecurityEventType());
+ if (assertionListMap != null && assertionListMap.size() > 0) {
+ Iterator<Map.Entry<Assertion, List<Assertable>>> assertionStateIterator = assertionListMap.entrySet().iterator();
+ while (assertionStateIterator.hasNext()) {
+ Map.Entry<Assertion, List<Assertable>> assertionStateEntry = assertionStateIterator.next();
+ List<Assertable> assertionStates = assertionStateEntry.getValue();
+ Iterator<Assertable> assertableIterator = assertionStates.iterator();
+ while (assertableIterator.hasNext()) {
+ Assertable assertable = assertableIterator.next();
+ boolean asserted = assertable.assertEvent(securityEvent);
+ //...so if one fails, continue with the next map entry and increment the notAssertedCount
+ if (!asserted) {
+ continue alternative;
+ }
}
}
}
@@ -548,6 +550,10 @@ public class PolicyEnforcer implements S
}
private void logFailedAssertions() {
+ if (this.failedAssertionStateMap.isEmpty()) {
+ return;
+ }
+
Iterator<Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>>> assertionStateMapIterator = this.failedAssertionStateMap.iterator();
while (assertionStateMapIterator.hasNext()) {
Map<SecurityEventConstants.Event, Map<Assertion, List<Assertable>>> map = assertionStateMapIterator.next();