[java-oidc-common] branch main updated: JCOMOIDC-8 Move OIDC attribute handling from the OIDC plugin
Henri Mikkonen
henri.mikkonen at iki.fi
Fri Jan 29 11:24:41 UTC 2021
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
http://git.shibboleth.net/view/?p=java-oidc-common.git;a=commit;h=155ee580d613a2ef484f5576cc75e46befc2291b
The following commit(s) were added to refs/heads/main by this push:
new 155ee58 JCOMOIDC-8 Move OIDC attribute handling from the OIDC plugin
155ee58 is described below
commit 155ee580d613a2ef484f5576cc75e46befc2291b
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Jan 29 13:23:09 2021 +0200
JCOMOIDC-8 Move OIDC attribute handling from the OIDC plugin
https://issues.shibboleth.net/jira/browse/JCOMOIDC-8
Imported Spring namespace-handling for encoders and their unit tests
from java-idp-oidc.
---
oidc-common-attribute-impl/pom.xml | 16 ++++
.../enc/impl/AttributeEncoderNamespaceHandler.java | 41 ++++++++
.../enc/impl/BaseOIDCAttributeEncoderParser.java | 67 +++++++++++++
.../spring/enc/impl/OIDCByteEncoderParser.java | 43 +++++++++
.../enc/impl/OIDCScopedStringEncoderParser.java | 60 ++++++++++++
.../spring/enc/impl/OIDCStringEncoderParser.java | 60 ++++++++++++
.../resolver/spring/enc/impl/package-info.java | 19 ++++
.../src/main/resources/META-INF/spring.handlers | 1 +
.../src/main/resources/META-INF/spring.schemas | 1 +
.../schema/shibboleth-attribute-encoder-oidc.xsd | 104 +++++++++++++++++++++
.../spring/enc/impl/OIDCByteEncoderParserTest.java | 43 +++++++++
.../impl/OIDCScopedStringEncoderParserTest.java | 44 +++++++++
.../enc/impl/OIDCStringEncoderParserTest.java | 45 +++++++++
.../idp/attribute/resolver/spring/customBean.xml | 39 ++++++++
.../idp/attribute/resolver/spring/enc/oidcbyte.xml | 10 ++
.../resolver/spring/enc/oidcscopedstring.xml | 10 ++
.../attribute/resolver/spring/enc/oidcstring.xml | 12 +++
17 files changed, 615 insertions(+)
diff --git a/oidc-common-attribute-impl/pom.xml b/oidc-common-attribute-impl/pom.xml
index 1ba52e9..7258dfd 100644
--- a/oidc-common-attribute-impl/pom.xml
+++ b/oidc-common-attribute-impl/pom.xml
@@ -30,6 +30,16 @@
<artifactId>idp-attribute-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>net.shibboleth.ext</groupId>
+ <artifactId>spring-extensions</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.shibboleth.idp</groupId>
+ <artifactId>idp-attribute-resolver-spring</artifactId>
+ <scope>provided</scope>
+ </dependency>
<!-- Test Dependencies -->
<dependency>
@@ -50,6 +60,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>net.shibboleth.ext</groupId>
<artifactId>spring-extensions</artifactId>
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/AttributeEncoderNamespaceHandler.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/AttributeEncoderNamespaceHandler.java
new file mode 100644
index 0000000..8ae63a4
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/AttributeEncoderNamespaceHandler.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.ext.spring.util.BaseSpringNamespaceHandler;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/** Namespace handler for the oidc attribute resolver. */
+public class AttributeEncoderNamespaceHandler extends BaseSpringNamespaceHandler {
+
+ /** Namespace for this handler. */
+ @Nonnull
+ @NotEmpty
+ public static final String NAMESPACE = "urn:mace:shibboleth:2.0:resolver:oidc";
+
+ /** {@inheritDoc} */
+ @Override
+ public void init() {
+ registerBeanDefinitionParser(OIDCStringEncoderParser.TYPE_NAME, new OIDCStringEncoderParser());
+ registerBeanDefinitionParser(OIDCScopedStringEncoderParser.TYPE_NAME, new OIDCScopedStringEncoderParser());
+ registerBeanDefinitionParser(OIDCByteEncoderParser.TYPE_NAME, new OIDCByteEncoderParser());
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/BaseOIDCAttributeEncoderParser.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/BaseOIDCAttributeEncoderParser.java
new file mode 100644
index 0000000..aba8ff0
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/BaseOIDCAttributeEncoderParser.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+import net.shibboleth.idp.attribute.resolver.spring.enc.BaseAttributeEncoderParser;
+import net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Base class for Spring bean definition parser for OIDC attribute encoders.
+ */
+public abstract class BaseOIDCAttributeEncoderParser extends BaseAttributeEncoderParser {
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
+ @Nonnull final Map<String,Object> rule) {
+
+ if (config.hasAttributeNS(null, "name")) {
+ rule.put(OIDCAttributeTranscoder.PROP_NAME,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "name")));
+ }
+
+ if (config.hasAttributeNS(null, "asArray")) {
+ rule.put(OIDCAttributeTranscoder.PROP_ASARRAY,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "asArray")));
+ }
+
+ if (config.hasAttributeNS(null, "asInt")) {
+ rule.put(OIDCAttributeTranscoder.PROP_ASINTEGER,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "asInt")));
+ }
+
+ if (config.hasAttributeNS(null, "asBoolean")) {
+ rule.put(OIDCAttributeTranscoder.PROP_ASBOOLEAN,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "asBoolean")));
+ }
+
+ if (config.hasAttributeNS(null, "stringDelimiter")) {
+ rule.put(OIDCAttributeTranscoder.PROP_STRING_DELIMITER,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "stringDelimiter")));
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParser.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParser.java
new file mode 100644
index 0000000..1791237
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParser.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import javax.annotation.Nonnull;
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCByteAttributeTranscoder;
+
+/**
+ * Spring bean definition parser for {@link OIDCByteAttributeTranscoder}.
+ */
+public class OIDCByteEncoderParser extends BaseOIDCAttributeEncoderParser {
+
+ /** Schema type name:. */
+ @Nonnull
+ public static final QName TYPE_NAME = new QName(AttributeEncoderNamespaceHandler.NAMESPACE, "OIDCByte");
+
+ /** {@inheritDoc} */
+ @Override
+ protected BeanReference buildTranscoder() {
+ return new RuntimeBeanReference("OIDCByteTranscoder");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParser.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParser.java
new file mode 100644
index 0000000..980e80e
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParser.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCScopedStringAttributeTranscoder;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Spring bean definition parser for {@link OIDCScopedStringAttributeTranscoder}.
+ */
+public class OIDCScopedStringEncoderParser extends BaseOIDCAttributeEncoderParser {
+
+ /** Schema type name. */
+ @Nonnull
+ public static final QName TYPE_NAME = new QName(AttributeEncoderNamespaceHandler.NAMESPACE, "OIDCScopedString");
+
+ /** {@inheritDoc} */
+ @Override protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
+ @Nonnull final Map<String,Object> rule) {
+ super.doParse(config, parserContext, rule);
+
+ if (config.hasAttributeNS(null, "scopeDelimiter")) {
+ rule.put(OIDCScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "scopeDelimiter")));
+ }
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected BeanReference buildTranscoder() {
+ return new RuntimeBeanReference("OIDCScopedStringTranscoder");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParser.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParser.java
new file mode 100644
index 0000000..100a80c
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParser.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+import javax.xml.namespace.QName;
+
+import org.springframework.beans.factory.config.BeanReference;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCStringAttributeTranscoder;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+/**
+ * Spring bean definition parser for {@link OIDCStringAttributeTranscoder}.
+ */
+public class OIDCStringEncoderParser extends BaseOIDCAttributeEncoderParser {
+
+ /** Schema type name:. */
+ @Nonnull
+ public static final QName TYPE_NAME = new QName(AttributeEncoderNamespaceHandler.NAMESPACE, "OIDCString");
+
+ /** {@inheritDoc} */
+ @Override protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
+ @Nonnull final Map<String,Object> rule) {
+ super.doParse(config, parserContext, rule);
+
+ if (config.hasAttributeNS(null, "asObject")) {
+ rule.put(OIDCStringAttributeTranscoder.PROP_ASOBJECT,
+ StringSupport.trimOrNull(config.getAttributeNS(null, "asObject")));
+ }
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected BeanReference buildTranscoder() {
+ return new RuntimeBeanReference("OIDCStringTranscoder");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/package-info.java b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/package-info.java
new file mode 100644
index 0000000..b5e522c
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** Attribute encoder namespace implementations.*/
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/main/resources/META-INF/spring.handlers b/oidc-common-attribute-impl/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000..46123af
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+urn\:mace\:shibboleth\:2.0\:resolver\:oidc = net.shibboleth.oidc.attribute.resolver.spring.enc.impl.AttributeEncoderNamespaceHandler
diff --git a/oidc-common-attribute-impl/src/main/resources/META-INF/spring.schemas b/oidc-common-attribute-impl/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000..ea55f5b
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+classpath\:/schema/idp-oidc-extension-attribute-encoder.xsd = schema/shibboleth-attribute-encoder-oidc.xsd
diff --git a/oidc-common-attribute-impl/src/main/resources/schema/shibboleth-attribute-encoder-oidc.xsd b/oidc-common-attribute-impl/src/main/resources/schema/shibboleth-attribute-encoder-oidc.xsd
new file mode 100644
index 0000000..9c268cd
--- /dev/null
+++ b/oidc-common-attribute-impl/src/main/resources/schema/shibboleth-attribute-encoder-oidc.xsd
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:encoder="urn:mace:shibboleth:2.0:attribute:encoder"
+ xmlns:resolver="urn:mace:shibboleth:2.0:resolver" xmlns:oidcresolver="urn:mace:shibboleth:2.0:resolver:oidc"
+ targetNamespace="urn:mace:shibboleth:2.0:resolver:oidc" elementFormDefault="qualified">
+
+ <import namespace="urn:mace:shibboleth:2.0:resolver"
+ schemaLocation="http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd" />
+
+ <!-- Encoders that produce OIDC Attributes -->
+
+ <complexType name="OIDCString">
+ <annotation>
+ <documentation>Defines a encoder for a string attribute.
+ </documentation>
+ </annotation>
+ <complexContent>
+ <extension base="oidcresolver:BaseAttributeEncoderType">
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="OIDCByte">
+ <annotation>
+ <documentation>Defines a base64 encoder for a byte attribute.
+ </documentation>
+ </annotation>
+ <complexContent>
+ <extension base="oidcresolver:BaseAttributeEncoderType">
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="OIDCScopedString">
+ <annotation>
+ <documentation>Defines a OIDC string encoder for a scoped string
+ attribute.
+ </documentation>
+ </annotation>
+ <complexContent>
+ <extension base="oidcresolver:BaseAttributeEncoderType">
+ <attribute name="scopeDelimiter" type="string" use="optional">
+ <annotation>
+ <documentation>
+ This is the delimeter used between the attribute
+ value and
+ scope.
+ </documentation>
+ </annotation>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <element name="OIDCAttributeEncoder" type="oidcresolver:BaseAttributeEncoderType">
+ <annotation>
+ <documentation>Defines a encoder (to JSON Object) for an attribute.
+ </documentation>
+ </annotation>
+ </element>
+ <complexType name="BaseAttributeEncoderType">
+ <complexContent>
+ <extension base="resolver:BaseAttributeEncoderType">
+ <attribute name="asObject" type="string" use="optional">
+ <annotation>
+ <documentation>
+ Wrap encoded values into JSON Object.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="asBoolean" type="string" use="optional">
+ <annotation>
+ <documentation>
+ Encode values as boolean.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="asArray" type="string" use="optional">
+ <annotation>
+ <documentation>
+ Encode values into array.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="asInt" type="string" use="optional">
+ <annotation>
+ <documentation>
+ Convert value to integer if possible.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="stringDelimiter" type="string" use="optional">
+ <annotation>
+ <documentation>
+ Delimeter used when catenating multiple attribute
+ values to one.
+ </documentation>
+ </annotation>
+ </attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParserTest.java b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParserTest.java
new file mode 100644
index 0000000..3b6c739
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCByteEncoderParserTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import static org.testng.Assert.*;
+
+import net.shibboleth.idp.attribute.resolver.spring.testing.BaseEncoderDefinitionParserTest;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoder;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
+import net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder;
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCByteAttributeTranscoder;
+
+public class OIDCByteEncoderParserTest extends BaseEncoderDefinitionParserTest {
+
+ protected void testWithProperties(final boolean activation, final Boolean encodeType) {
+
+ final TranscodingRule rule =
+ getAttributeTranscoderRule("oidcbyte.xml", activation, encodeType);
+
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER, AttributeTranscoder.class) instanceof OIDCByteAttributeTranscoder);
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_NAME, String.class), "OIDCByte_ATTRIBUTE_NAME");
+ assertTrue(rule.get(OIDCAttributeTranscoder.PROP_ASARRAY, Boolean.class));
+ assertFalse(rule.get(OIDCAttributeTranscoder.PROP_ASINTEGER, Boolean.class));
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_STRING_DELIMITER, String.class), "|");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParserTest.java b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParserTest.java
new file mode 100644
index 0000000..55f4677
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCScopedStringEncoderParserTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import static org.testng.Assert.*;
+
+import net.shibboleth.idp.attribute.resolver.spring.testing.BaseEncoderDefinitionParserTest;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoder;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
+import net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder;
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCScopedStringAttributeTranscoder;
+
+public class OIDCScopedStringEncoderParserTest extends BaseEncoderDefinitionParserTest {
+
+ protected void testWithProperties(final boolean activation, final Boolean encodeType) {
+
+ final TranscodingRule rule =
+ getAttributeTranscoderRule("oidcscopedstring.xml", activation, encodeType);
+
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER, AttributeTranscoder.class) instanceof OIDCScopedStringAttributeTranscoder);
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_NAME, String.class), "OIDCScopedString_ATTRIBUTE_NAME");
+ assertTrue(rule.get(OIDCAttributeTranscoder.PROP_ASARRAY, Boolean.class));
+ assertNull(rule.get(OIDCAttributeTranscoder.PROP_ASINTEGER, Boolean.class));
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_STRING_DELIMITER, String.class), "|");
+ assertEquals(rule.get(OIDCScopedStringAttributeTranscoder.PROP_SCOPE_DELIMITER, String.class), "|");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParserTest.java b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParserTest.java
new file mode 100644
index 0000000..5c8398f
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/java/net/shibboleth/oidc/attribute/resolver/spring/enc/impl/OIDCStringEncoderParserTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.attribute.resolver.spring.enc.impl;
+
+import static org.testng.Assert.*;
+
+import net.shibboleth.idp.attribute.resolver.spring.testing.BaseEncoderDefinitionParserTest;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoder;
+import net.shibboleth.idp.attribute.transcoding.AttributeTranscoderRegistry;
+import net.shibboleth.idp.attribute.transcoding.TranscodingRule;
+import net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder;
+import net.shibboleth.oidc.attribute.transcoding.impl.OIDCStringAttributeTranscoder;
+
+public class OIDCStringEncoderParserTest extends BaseEncoderDefinitionParserTest {
+
+ protected void testWithProperties(final boolean activation, final Boolean encodeType) {
+
+ final TranscodingRule rule =
+ getAttributeTranscoderRule("oidcstring.xml", activation, encodeType);
+
+ assertTrue(rule.get(AttributeTranscoderRegistry.PROP_TRANSCODER, AttributeTranscoder.class) instanceof OIDCStringAttributeTranscoder);
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_NAME, String.class), "OIDCString_ATTRIBUTE_NAME");
+ assertTrue(rule.get(OIDCAttributeTranscoder.PROP_ASARRAY, Boolean.class));
+ assertTrue(rule.get(OIDCStringAttributeTranscoder.PROP_ASOBJECT, Boolean.class));
+ assertTrue(rule.get(OIDCAttributeTranscoder.PROP_ASBOOLEAN, Boolean.class));
+ assertFalse(rule.get(OIDCAttributeTranscoder.PROP_ASINTEGER, Boolean.class));
+ assertEquals(rule.get(OIDCAttributeTranscoder.PROP_STRING_DELIMITER, String.class), "|");
+ }
+
+}
\ No newline at end of file
diff --git a/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml
new file mode 100644
index 0000000..02c898d
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/customBean.xml
@@ -0,0 +1,39 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+
+ default-init-method="initialize"
+ default-destroy-method="destroy">
+
+ <util:map id="shibboleth.CustomScriptObject">
+ <entry key="foo" value="bar"/>
+ </util:map>
+
+ <util:map id="other.CustomScriptObject">
+ <entry key="bar" value="foo"/>
+ </util:map>
+
+ <bean id="shibboleth.Predicate" class="com.google.common.base.Predicates" factory-method="alwaysFalse"/>
+
+ <bean id="shibboleth.PropertySourcesPlaceholderConfigurer"
+ class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+ p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+ <!-- Necessary for encoder parsing to function, normally part of registry wiring. -->
+
+ <bean id="OIDCByteTranscoder"
+ class="net.shibboleth.oidc.attribute.transcoding.impl.OIDCByteAttributeTranscoder" />
+
+ <bean id="OIDCStringTranscoder"
+ class="net.shibboleth.oidc.attribute.transcoding.impl.OIDCStringAttributeTranscoder" />
+
+ <bean id="OIDCScopedStringTranscoder"
+ class="net.shibboleth.oidc.attribute.transcoding.impl.OIDCScopedStringAttributeTranscoder" />
+
+</beans>
diff --git a/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcbyte.xml b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcbyte.xml
new file mode 100644
index 0000000..1e8ab2d
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcbyte.xml
@@ -0,0 +1,10 @@
+<AttributeEncoder
+ xsi:type="oidcext:OIDCByte"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:mace:shibboleth:2.0:resolver"
+ xmlns:oidcext="urn:mace:shibboleth:2.0:resolver:oidc"
+ name="OIDCByte_ATTRIBUTE_NAME"
+ asArray="true"
+ asInt="false"
+ stringDelimiter="|"
+ xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd urn:mace:shibboleth:2.0:resolver:oidc classpath:/schema/idp-oidc-extension-attribute-encoder.xsd" />
diff --git a/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcscopedstring.xml b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcscopedstring.xml
new file mode 100644
index 0000000..81f16ed
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcscopedstring.xml
@@ -0,0 +1,10 @@
+<AttributeEncoder
+ xsi:type="oidcext:OIDCScopedString"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:mace:shibboleth:2.0:resolver"
+ xmlns:oidcext="urn:mace:shibboleth:2.0:resolver:oidc"
+ name="OIDCScopedString_ATTRIBUTE_NAME"
+ asArray="true"
+ stringDelimiter="|"
+ scopeDelimiter="|"
+ xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd urn:mace:shibboleth:2.0:resolver:oidc classpath:/schema/idp-oidc-extension-attribute-encoder.xsd" />
diff --git a/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcstring.xml b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcstring.xml
new file mode 100644
index 0000000..6fee8ee
--- /dev/null
+++ b/oidc-common-attribute-impl/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/enc/oidcstring.xml
@@ -0,0 +1,12 @@
+<AttributeEncoder
+ xsi:type="oidcext:OIDCString"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:mace:shibboleth:2.0:resolver"
+ xmlns:oidcext="urn:mace:shibboleth:2.0:resolver:oidc"
+ name="OIDCString_ATTRIBUTE_NAME"
+ asArray="true"
+ asBoolean="true"
+ asInt="false"
+ asObject="true"
+ stringDelimiter="|"
+ xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd urn:mace:shibboleth:2.0:resolver:oidc classpath:/schema/idp-oidc-extension-attribute-encoder.xsd" />
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list