[java-shib-profile] branch main updated: JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
Scott Cantor
cantor.2 at osu.edu
Tue Feb 21 15:08:28 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-profile.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-profile.git;a=commit;h=00b93566d285839e75d41b9aceb79d4e8a2797d3
The following commit(s) were added to refs/heads/main by this push:
new 00b9356 JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
00b9356 is described below
commit 00b93566d285839e75d41b9aceb79d4e8a2797d3
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Feb 21 10:08:22 2023 -0500
JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
https://shibboleth.atlassian.net/browse/JSPROF-1
Move ArtifactProducing interfaces and class out of IdP.
---
.../config/BasicSAMLArtifactConfiguration.java | 103 +++++++++++++++++++++
.../SAMLArtifactAwareProfileConfiguration.java | 37 ++++++++
.../profile/config/SAMLArtifactConfiguration.java | 50 ++++++++++
.../config/BasicSAMLArtifactConfigurationTest.java | 63 +++++++++++++
4 files changed, 253 insertions(+)
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfiguration.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfiguration.java
new file mode 100644
index 0000000..8975f1f
--- /dev/null
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfiguration.java
@@ -0,0 +1,103 @@
+/*
+ * 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.saml.profile.config;
+
+import java.nio.ByteBuffer;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.shared.logic.ConstraintViolationException;
+import net.shibboleth.shared.primitive.StringSupport;
+
+/**
+ * Interface for outbound SAML artifact configuration.
+ *
+ * <p>While sufficient for known SAML 1 and 2 artifact types, the interface
+ * may be extended if necessary to carry type-specific additions.</p>
+ */
+public class BasicSAMLArtifactConfiguration implements SAMLArtifactConfiguration {
+
+ /** The artifact type code. */
+ @Nullable private byte[] artifactType;
+
+ /** The artifact resolution URL. */
+ @Nullable private String artifactResolutionURL;
+
+ /** The artifact resolution index. */
+ @Nullable private Integer artifactResolutionIndex;
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable public byte[] getArtifactType() {
+ return artifactType;
+ }
+
+ /**
+ * Set the type code of the artifact to use.
+ *
+ * @param type type code of artifact
+ */
+ public void setArtifactType(@Nullable final Integer type) {
+ if (type == null) {
+ artifactType = null;
+ } else {
+ if (type <= 0) {
+ throw new ConstraintViolationException("Artifact type code must be positive");
+ } else if (type > 32767) {
+ throw new ConstraintViolationException("Artifact type code must fit in two bytes");
+ }
+
+ final byte[] typeCode = ByteBuffer.allocate(4).putInt(type).array();
+ final byte[] atype = new byte[2];
+ atype[0] = typeCode[2];
+ atype[1] = typeCode[3];
+ artifactType = atype;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable public String getArtifactResolutionServiceURL() {
+ return artifactResolutionURL;
+ }
+
+ /**
+ * Set the location, as a URL, of the issuer's resolution service endpoint.
+ *
+ * @param url location of the resolution service endpoint
+ */
+ public void setArtifactResolutionServiceURL(@Nullable final String url) {
+ artifactResolutionURL = StringSupport.trimOrNull(url);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nullable public Integer getArtifactResolutionServiceIndex() {
+ return artifactResolutionIndex;
+ }
+
+ /**
+ * Set the index of the issuer's resolution service endpoint, corresponding to its metadata.
+ *
+ * @param index index of resolution service endpoint
+ */
+ public void setArtifactResolutionServiceIndex(@Nullable final Integer index) {
+ artifactResolutionIndex = index;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactAwareProfileConfiguration.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactAwareProfileConfiguration.java
new file mode 100644
index 0000000..ea6e664
--- /dev/null
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactAwareProfileConfiguration.java
@@ -0,0 +1,37 @@
+/*
+ * 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.saml.profile.config;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/** Common interface for SAML profile configurations involving artifact production. */
+public interface SAMLArtifactAwareProfileConfiguration extends SAMLProfileConfiguration {
+
+ /**
+ * Get the associated {@link SAMLArtifactConfiguration} for the profile, if any.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return an associated artifact configuration, or null
+ */
+ @Nullable SAMLArtifactConfiguration getArtifactConfiguration(
+ @Nullable final ProfileRequestContext profileRequestContext);
+
+}
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactConfiguration.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactConfiguration.java
new file mode 100644
index 0000000..cf5fcb9
--- /dev/null
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/profile/config/SAMLArtifactConfiguration.java
@@ -0,0 +1,50 @@
+/*
+ * 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.saml.profile.config;
+
+import javax.annotation.Nullable;
+
+/**
+ * Interface for outbound SAML artifact configuration.
+ *
+ * <p>While sufficient for known SAML 1 and 2 artifact types, the interface
+ * may be extended if necessary to carry type-specific additions.</p>
+ */
+public interface SAMLArtifactConfiguration {
+
+ /**
+ * Get the type code of the artifact to use.
+ *
+ * @return the artifact type code
+ */
+ @Nullable byte[] getArtifactType();
+
+ /**
+ * Get the location, as a URL, of the issuer's resolution service endpoint.
+ *
+ * @return location of resolution service endpoint
+ */
+ @Nullable String getArtifactResolutionServiceURL();
+
+ /**
+ * Get the index of the issuer's resolution service endpoint, corresponding to its metadata.
+ *
+ * @return index of resolution service endpoint in metadata
+ */
+ @Nullable Integer getArtifactResolutionServiceIndex();
+}
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/test/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfigurationTest.java b/shib-saml-profile-api/src/test/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfigurationTest.java
new file mode 100644
index 0000000..d220171
--- /dev/null
+++ b/shib-saml-profile-api/src/test/java/net/shibboleth/saml/profile/config/BasicSAMLArtifactConfigurationTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.saml.profile.config;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/** Unit test for {@link BasicSAMLArtifactConfiguration}. */
+ at SuppressWarnings("javadoc")
+public class BasicSAMLArtifactConfigurationTest {
+
+ @Test public void testArtifactType() {
+ BasicSAMLArtifactConfiguration config = new BasicSAMLArtifactConfiguration();
+
+ Assert.assertNull(config.getArtifactType());
+
+ config.setArtifactType(1);
+ Assert.assertEquals(config.getArtifactType(), new byte[] {0x0, 0x1});
+
+ config.setArtifactType(null);
+ Assert.assertNull(config.getArtifactType());
+ }
+
+ @Test public void testURL() {
+ BasicSAMLArtifactConfiguration config = new BasicSAMLArtifactConfiguration();
+
+ Assert.assertNull(config.getArtifactResolutionServiceURL());
+
+ config.setArtifactResolutionServiceURL("https://idp.example.org/artifact");
+ Assert.assertEquals(config.getArtifactResolutionServiceURL(), "https://idp.example.org/artifact");
+
+ config.setArtifactResolutionServiceURL(" ");
+ Assert.assertNull(config.getArtifactResolutionServiceURL());
+ }
+
+ @Test public void testIndex() {
+ BasicSAMLArtifactConfiguration config = new BasicSAMLArtifactConfiguration();
+
+ Assert.assertNull(config.getArtifactResolutionServiceIndex());
+
+ config.setArtifactResolutionServiceIndex(1);
+ Assert.assertEquals(config.getArtifactResolutionServiceIndex(), Integer.valueOf(1));
+
+ config.setArtifactResolutionServiceIndex(null);
+ Assert.assertNull(config.getArtifactResolutionServiceIndex());
+ }
+
+}
\ 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