[java-shib-common COMMIT] in /branches/REL_1: doc/RELEASE-NOTES.txt src/main/java/edu/internet2/middleware/shibboleth...

noreply at shibboleth.net noreply at shibboleth.net
Wed Jan 13 21:28:48 EST 2016


Author: putmanb
Date: Wed Jan 13 21:28:48 2016
New Revision: 1135

URL: http://svn.shibboleth.net/view/java-shib-common?rev=1135&view=rev
Log:
SC-203: Metadata Scope extension XMLObject impl fails on invalid regular expression value

Modified:
    branches/REL_1/doc/RELEASE-NOTES.txt
    branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/ShibbolethMetadataScope.java
    branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibbolethMetadataScopeImpl.java
    branches/REL_1/src/test/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibMDScopeTest.java

Modified: branches/REL_1/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-shib-common/branches/REL_1/doc/RELEASE-NOTES.txt?rev=1135&r1=1134&r2=1135&view=diff
==============================================================================
--- branches/REL_1/doc/RELEASE-NOTES.txt	(original)
+++ branches/REL_1/doc/RELEASE-NOTES.txt	Wed Jan 13 21:28:48 2016
@@ -1,3 +1,7 @@
+Changes in Release 1.4.5
+=============================================
+[SC-203] - Metadata Scope extension XMLObject impl fails on invalid regular expression value 
+
 Changes in Release 1.4.4
 =============================================
 

Modified: branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/ShibbolethMetadataScope.java
URL: http://svn.shibboleth.net/view/java-shib-common/branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/ShibbolethMetadataScope.java?rev=1135&r1=1134&r2=1135&view=diff
==============================================================================
--- branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/ShibbolethMetadataScope.java	(original)
+++ branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/ShibbolethMetadataScope.java	Wed Jan 13 21:28:48 2016
@@ -71,11 +71,25 @@
     public void setRegexp(XSBooleanValue newRegexp);
 
     /**
-     * Gets the match pattern used to evaluate if a scope matches the scope criteria given by this extension. If regular
-     * expressions are not used in the scope criteria then this pattern must simply perform a direct match of the
-     * string.
+     * Convenience method which returns a match {@link Pattern} that <b>may</b> be used to evaluate whether 
+     * a candidate scope matches the scope criteria given by this extension, when the value is indicated to 
+     * be a regular expression. 
      * 
-     * @return match pattern used to evaluate if a scope matches the scope criteria
+     * <p>
+     * This may only be called when {@link #getRegexp()} evaluates to <code>true</code>. Otherwise an
+     * {@link IllegalStateException} is thrown.
+     * </p>
+     * 
+     * <p>
+     * The scope value supplied to {@link #setValue(String)} <b>MUST</b> be a valid Java regular expression
+     * as defined by {@link Pattern}, else a fatal error will result.
+     * </p>
+     * 
+     * @return match pattern used to evaluate if a scope matches a regular expression scope criteria
+     * 
+     * @deprecated No replacement. The caller should instead evaluate the scope value supplied by
+     * {@link #getValue()} in an implementation-specific manner
      */
+    @Deprecated
     public Pattern getMatchPattern();
 }

Modified: branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibbolethMetadataScopeImpl.java
URL: http://svn.shibboleth.net/view/java-shib-common/branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibbolethMetadataScopeImpl.java?rev=1135&r1=1134&r2=1135&view=diff
==============================================================================
--- branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibbolethMetadataScopeImpl.java	(original)
+++ branches/REL_1/src/main/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibbolethMetadataScopeImpl.java	Wed Jan 13 21:28:48 2016
@@ -87,11 +87,17 @@
     /** {@inheritDoc} */
     public void setValue(String newScopeValue) {
         scopeValue = prepareForAssignment(scopeValue, newScopeValue);
-        matchPattern = Pattern.compile(scopeValue);
+        matchPattern = null;
     }
 
     /** {@inheritDoc} */
     public Pattern getMatchPattern() {
+        if (getRegexp() != Boolean.TRUE) {
+            throw new IllegalStateException("Scope value is not indicated to be a regex");
+        }
+        if (matchPattern == null) {
+            matchPattern = Pattern.compile(scopeValue);
+        }
         return matchPattern;
     }
 

Modified: branches/REL_1/src/test/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibMDScopeTest.java
URL: http://svn.shibboleth.net/view/java-shib-common/branches/REL_1/src/test/java/edu/internet2/middleware/shibboleth/common/xmlobject/impl/ShibMDScopeTest.java?rev=1135&r1=1134&r2=1135&view=diff
==============================================================================

[... 47 lines stripped ...]


More information about the commits mailing list