[java-shib-attribute] branch main updated: Get rid of inline XMLObject classes for Scope.

Scott Cantor cantor.2 at osu.edu
Tue Nov 22 17:23:48 UTC 2022


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

scantor pushed a commit to branch main
in repository java-shib-attribute.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=fd9bb7a46c31297ce066795f38993c176d83edb4

The following commit(s) were added to refs/heads/main by this push:
     new fd9bb7a46 Get rid of inline XMLObject classes for Scope.
fd9bb7a46 is described below

commit fd9bb7a46c31297ce066795f38993c176d83edb4
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 22 12:23:45 2022 -0500

    Get rid of inline XMLObject classes for Scope.
---
 shib-saml-attribute-api/pom.xml                    |   6 +
 .../transcoding/SAMLEncoderSupportTest.java        | 141 +--------------------
 2 files changed, 7 insertions(+), 140 deletions(-)

diff --git a/shib-saml-attribute-api/pom.xml b/shib-saml-attribute-api/pom.xml
index 11b93cd51..2425f0b99 100644
--- a/shib-saml-attribute-api/pom.xml
+++ b/shib-saml-attribute-api/pom.xml
@@ -56,6 +56,12 @@
         <!-- Runtime Dependencies -->
 
         <!-- Test Dependencies -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>shib-metadata-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
         <dependency>
             <groupId>${opensaml.groupId}</groupId>
             <artifactId>opensaml-testing</artifactId>
diff --git a/shib-saml-attribute-api/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/SAMLEncoderSupportTest.java b/shib-saml-attribute-api/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/SAMLEncoderSupportTest.java
index baab6d056..b1f96df05 100644
--- a/shib-saml-attribute-api/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/SAMLEncoderSupportTest.java
+++ b/shib-saml-attribute-api/src/test/java/net/shibboleth/idp/saml/attribute/transcoding/SAMLEncoderSupportTest.java
@@ -20,7 +20,6 @@ package net.shibboleth.idp.saml.attribute.transcoding;
 import java.util.List;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.xml.namespace.QName;
 
 import net.shibboleth.idp.attribute.IdPAttribute;
@@ -30,28 +29,17 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.codec.Base64Support;
 import net.shibboleth.shared.codec.DecodingException;
 import net.shibboleth.shared.codec.EncodingException;
-import net.shibboleth.shared.xml.ElementSupport;
 
 import org.opensaml.core.testing.OpenSAMLInitBaseTestCase;
-import org.opensaml.core.xml.AbstractXMLObjectBuilder;
 import org.opensaml.core.xml.XMLObject;
 import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
-import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
-import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
-import org.opensaml.core.xml.io.MarshallingException;
-import org.opensaml.core.xml.io.UnmarshallingException;
 import org.opensaml.core.xml.schema.XSAny;
 import org.opensaml.core.xml.schema.XSBase64Binary;
 import org.opensaml.core.xml.schema.XSString;
-import org.opensaml.core.xml.schema.impl.XSAnyImpl;
 import org.opensaml.saml.common.SAMLObjectBuilder;
 import org.opensaml.saml.saml2.core.NameID;
 import org.testng.Assert;
 import org.testng.annotations.Test;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-import com.google.common.base.Strings;
 
 /**
  * Test for {@link SAMLEncoderSupport}.
@@ -125,9 +113,6 @@ public class SAMLEncoderSupportTest  extends OpenSAMLInitBaseTestCase {
 
     @Test public void encodeScopedStringValueAttribute() {
         
-        XMLObjectProviderRegistrySupport.registerObjectProvider(ScopedValue.TYPE_NAME,
-                new ScopedValueBuilder(), new ScopedValueMarshaller(), new ScopedValueUnmarshaller());
-        
         Assert.assertNull(SAMLEncoderSupport.encodeScopedStringValueAttribute(ATTR, QNAME, null, SCOPE_ATTRIBUTE_NAME, true));
         
         final XMLObject obj = SAMLEncoderSupport.encodeScopedStringValueAttribute(ATTR, QNAME, SCOPEDVAL, SCOPE_ATTRIBUTE_NAME, true);
@@ -151,130 +136,6 @@ public class SAMLEncoderSupportTest  extends OpenSAMLInitBaseTestCase {
         final XSString str = (XSString) obj;
         
         Assert.assertEquals(str.getValue(), STRING_VALUE + DELIMITER + STRING_SCOPE);
-        
-        
-        }
-    
-    //
-    // The rest of this function is cut and paste from the real providers in idp-saml-imp
-    //
-    
-    private class ScopedValueBuilder extends AbstractXMLObjectBuilder<ScopedValue> {
-
-        @Nonnull public ScopedValue buildObject(@Nullable final String namespaceURI,
-                @Nonnull @NotEmpty final String localName, @Nullable final String namespacePrefix) {
-            return new ScopedValueImpl(namespaceURI, localName, namespacePrefix);
-        }
-    }
-
-    private class ScopedValueImpl extends XSAnyImpl implements ScopedValue {
-
-        /** Scope of this string element. */
-        private String scope;
-
-        /** Scope attribute name for this element. */
-        private String scopeAttributeName;
-
-        /**
-         * Constructor.
-         * 
-         * @param namespaceURI the namespace the element is in
-         * @param elementLocalName the local name of the XML element this Object represents
-         * @param namespacePrefix the prefix for the given namespace
-         */
-        protected ScopedValueImpl(@Nullable final String namespaceURI,
-                @Nonnull @NotEmpty final String localName, @Nullable final String namespacePrefix) {
-            super(namespaceURI, localName, namespacePrefix);
-        }
-
-        /** {@inheritDoc} */
-        public String getScope() {
-            return scope;
-        }
-
-        /** {@inheritDoc} */
-        public String getScopeAttributeName() {
-            return scopeAttributeName;
-        }
-
-        /** {@inheritDoc} */
-        public void setScope(String newScope) {
-            scope = prepareForAssignment(scope, newScope);
-            if (scope != null && scopeAttributeName != null) {
-                getUnknownAttributes().put(new QName(scopeAttributeName), scope);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public void setScopeAttributeName(String newScopeAttributeName) {
-            if (scopeAttributeName != null) {
-                final QName oldName = new QName(scopeAttributeName);
-                if (getUnknownAttributes().containsKey(oldName)) {
-                    getUnknownAttributes().remove(oldName);
-                }
-            }
-
-            scopeAttributeName = prepareForAssignment(scopeAttributeName, newScopeAttributeName);
-
-            if (scope != null) {
-                getUnknownAttributes().put(new QName(scopeAttributeName), scope);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public String getValue() {
-            return getTextContent();
-        }
-
-        /** {@inheritDoc} */
-        public void setValue(String newValue) {
-            setTextContent(newValue);
-        }
-        
     }
-    
-    private class ScopedValueMarshaller extends AbstractXMLObjectMarshaller {
-
-        /** {@inheritDoc} */
-        protected void marshallAttributes(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
-                throws MarshallingException {
-            final ScopedValue scopedValue = (ScopedValue) xmlObject;
-
-            if (null != scopedValue.getScopeAttributeName()) {
-                domElement.setAttributeNS(null, scopedValue.getScopeAttributeName(), scopedValue.getScope());
-            }
-
-        }
-
-        /** {@inheritDoc} */
-        protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
-                throws MarshallingException {
-            final ScopedValue scopedValue = (ScopedValue) xmlObject;
 
-            ElementSupport.appendTextContent(domElement, scopedValue.getValue());
-        }
-    }
-    
-    private class ScopedValueUnmarshaller extends AbstractXMLObjectUnmarshaller {
-
-        /** {@inheritDoc} */
-        protected void processAttribute(@Nonnull final XMLObject xmlObject, @Nonnull final Attr attribute)
-                throws UnmarshallingException {
-            final ScopedValue sv = (ScopedValue) xmlObject;
-
-            if (Strings.isNullOrEmpty(sv.getScopeAttributeName())) {
-                sv.setScopeAttributeName(attribute.getName());
-                sv.setScope(attribute.getValue());
-            }
-
-        }
-
-        /** {@inheritDoc} */
-        protected void processElementContent(@Nonnull final XMLObject xmlObject,
-                @Nonnull @NotEmpty final String elementContent) {
-            final ScopedValue sv = (ScopedValue) xmlObject;
-
-            sv.setValue(elementContent);
-        }
-    }
-}
+}
\ 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