[java-identity-provider] 02/04: IDP-1456 Strip deprecated method from md:Scope OpenSAML classes

Rod Widdowson rdw at steadingsoftware.com
Sat May 25 11:29:23 EDT 2019


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=4c4a60cfc08cbd44bbc1df7cbae8f6f4bfdd497d

commit 4c4a60cfc08cbd44bbc1df7cbae8f6f4bfdd497d
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat May 25 14:28:40 2019 +0100

    IDP-1456 Strip deprecated method from md:Scope OpenSAML classes
    
    https://issues.shibboleth.net/jira/browse/IDP-1456
---
 .../net/shibboleth/idp/saml/xmlobject/Scope.java   | 24 ---------------
 .../idp/saml/xmlobject/impl/ScopeImpl.java         | 34 ++++++--------------
 .../idp/saml/xmlobject/impl/ScopeTest.java         | 36 ++--------------------
 3 files changed, 11 insertions(+), 83 deletions(-)

diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/xmlobject/Scope.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/xmlobject/Scope.java
index d77870e..bac73c8 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/xmlobject/Scope.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/xmlobject/Scope.java
@@ -17,8 +17,6 @@
 
 package net.shibboleth.idp.saml.xmlobject;
 
-import java.util.regex.Pattern;
-
 import javax.xml.namespace.QName;
 
 import org.opensaml.core.xml.schema.XSBooleanValue;
@@ -65,26 +63,4 @@ public interface Scope extends XSString {
      */
     public void setRegexp(XSBooleanValue newRegexp);
 
-    /**
-     * 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. 
-     * 
-     * <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();
 }
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeImpl.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeImpl.java
index 78e224c..e5789a8 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeImpl.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeImpl.java
@@ -18,16 +18,15 @@
 package net.shibboleth.idp.saml.xmlobject.impl;
 
 import java.util.List;
-import java.util.regex.Pattern;
 
 import javax.annotation.concurrent.NotThreadSafe;
 
-import net.shibboleth.idp.saml.xmlobject.Scope;
-
 import org.opensaml.core.xml.AbstractXMLObject;
 import org.opensaml.core.xml.XMLObject;
 import org.opensaml.core.xml.schema.XSBooleanValue;
 
+import net.shibboleth.idp.saml.xmlobject.Scope;
+
 /** Implementation of {@link Scope}. */
 @NotThreadSafe
 public class ScopeImpl extends AbstractXMLObject implements Scope {
@@ -38,9 +37,6 @@ public class ScopeImpl extends AbstractXMLObject implements Scope {
     /** The string content value. */
     private String scopeValue;
 
-    /** Pattern used to match scopes against criteria. */
-    private Pattern matchPattern;
-
     /**
      * Constructor.
      * 
@@ -54,7 +50,7 @@ public class ScopeImpl extends AbstractXMLObject implements Scope {
     }
 
     /** {@inheritDoc} */
-    public Boolean getRegexp() {
+    @Override public Boolean getRegexp() {
         if (regexp == null) {
             return Boolean.FALSE;
         }
@@ -62,7 +58,7 @@ public class ScopeImpl extends AbstractXMLObject implements Scope {
     }
 
     /** {@inheritDoc} */
-    public void setRegexp(final Boolean newRegexp) {
+    @Override public void setRegexp(final Boolean newRegexp) {
         if (newRegexp != null) {
             regexp = prepareForAssignment(regexp, new XSBooleanValue(newRegexp, false));
         } else {
@@ -71,39 +67,27 @@ public class ScopeImpl extends AbstractXMLObject implements Scope {
     }
 
     /** {@inheritDoc} */
-    public XSBooleanValue getRegexpXSBoolean() {
+    @Override public XSBooleanValue getRegexpXSBoolean() {
         return regexp;
     }
 
     /** {@inheritDoc} */
-    public void setRegexp(final XSBooleanValue newRegexp) {
+    @Override public void setRegexp(final XSBooleanValue newRegexp) {
         regexp = prepareForAssignment(regexp, newRegexp);
     }
 
     /** {@inheritDoc} */
-    public String getValue() {
+    @Override public String getValue() {
         return scopeValue;
     }
 
     /** {@inheritDoc} */
-    public void setValue(final String newScopeValue) {
+    @Override public void setValue(final String newScopeValue) {
         scopeValue = prepareForAssignment(scopeValue, newScopeValue);
-        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;
     }
     
     /** {@inheritDoc} */
-    public List<XMLObject> getOrderedChildren() {
+    @Override public List<XMLObject> getOrderedChildren() {
         return null;
     }
 }
\ No newline at end of file
diff --git a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
index cbc0bdc..9744a1f 100644
--- a/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
+++ b/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/xmlobject/impl/ScopeTest.java
@@ -17,16 +17,14 @@
 
 package net.shibboleth.idp.saml.xmlobject.impl;
 
-import java.util.regex.Pattern;
-
-import net.shibboleth.idp.saml.xmlobject.Scope;
-
 import org.opensaml.core.xml.XMLObjectProviderBaseTestCase;
 import org.opensaml.core.xml.schema.XSBooleanValue;
 import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import net.shibboleth.idp.saml.xmlobject.Scope;
+
 /**
  * Testing shibmd:Scope metadata extension.
  */
@@ -116,35 +114,5 @@ public class ScopeTest extends XMLObjectProviderBaseTestCase {
         Assert.assertEquals(scope.getRegexp(), Boolean.FALSE, "Unexpected default value for boolean attribute found");
         Assert.assertNull(scope.getRegexpXSBoolean(), "XSBooleanValue was not null");
     }
-    
-    /**
-     * Test behavior related to {@link Scope#getMatchPattern()}.
-     */
-    @SuppressWarnings("deprecation")
-    @Test
-    public void testMatchPattern() {
-        Scope scope = (Scope) buildXMLObject(Scope.DEFAULT_ELEMENT_NAME);
-        
-        try {
-            scope.setRegexp(false);
-            scope.setValue("example.org");
-            scope.getMatchPattern();
-            Assert.fail("Non-regex should have failed with IllegalStateException");
-        } catch (IllegalStateException e) {
-            //expected
-        }
-        
-        scope.setRegexp(true);
-        scope.setValue(".*\\.example.org$");
-        Pattern pattern1 = scope.getMatchPattern();
-        Assert.assertNotNull(pattern1);
-        
-        scope.setRegexp(true);
-        scope.setValue(".*\\.foobar.edu$");
-        Pattern pattern2 = scope.getMatchPattern();
-        Assert.assertNotNull(pattern2);
-        
-        Assert.assertFalse(pattern1 == pattern2);
-    }
 
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list