[java-shib-profile] branch main updated: New package for copies of IdP ProfileConfiguration base classes.
Scott Cantor
cantor.2 at osu.edu
Thu Feb 9 19:48:07 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=8ef002026736b0b91c85e10e729079e0eefa74ad
The following commit(s) were added to refs/heads/main by this push:
new 8ef0020 New package for copies of IdP ProfileConfiguration base classes.
8ef0020 is described below
commit 8ef002026736b0b91c85e10e729079e0eefa74ad
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Feb 9 14:48:04 2023 -0500
New package for copies of IdP ProfileConfiguration base classes.
---
pom.xml | 6 +-
.../AbstractConditionalProfileConfiguration.java | 68 ++++++++++
.../config/AbstractProfileConfiguration.java | 144 +++++++++++++++++++++
.../AttributeResolvingProfileConfiguration.java | 40 ++++++
.../config/ConditionalProfileConfiguration.java | 40 ++++++
.../OverriddenIssuerProfileConfiguration.java | 42 ++++++
.../profile/config/ProfileConfiguration.java | 65 ++++++++++
.../shibboleth/profile/config/package-info.java | 22 ++++
shib-profile-bom/pom.xml | 2 +
9 files changed, 426 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index f1a613f..dd9604e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,10 +22,10 @@
<modules>
<module>shib-profile-api</module>
- <module>shib-saml-profile-api</module>
+<!-- <module>shib-saml-profile-api</module>-->
- <module>shib-profile-impl</module>
- <module>shib-saml-profile-impl</module>
+<!-- <module>shib-profile-impl</module>-->
+<!-- <module>shib-saml-profile-impl</module>-->
<module>shib-profile-bom</module>
</modules>
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractConditionalProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractConditionalProfileConfiguration.java
new file mode 100644
index 0000000..04b81a7
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractConditionalProfileConfiguration.java
@@ -0,0 +1,68 @@
+/*
+ * 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.profile.config;
+
+import java.util.function.Predicate;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.PredicateSupport;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * Base class for {@link ConditionalProfileConfiguration} implementations.
+ *
+ * @since 3.4.0
+ */
+public abstract class AbstractConditionalProfileConfiguration extends AbstractProfileConfiguration
+ implements ConditionalProfileConfiguration {
+
+ /** Activation condition. */
+ @Nonnull private Predicate<ProfileRequestContext> activationCondition;
+
+ /**
+ * Constructor.
+ *
+ * @param id ID of the communication profile, never null or empty
+ */
+ public AbstractConditionalProfileConfiguration(@Nonnull @NotEmpty @ParameterName(name="id") final String id) {
+ super(id);
+
+ activationCondition = PredicateSupport.alwaysTrue();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull public Predicate<ProfileRequestContext> getActivationCondition() {
+ return activationCondition;
+ }
+
+ /**
+ * Set an activation condition to control this profile.
+ *
+ * @param condition condition to apply
+ */
+ public void setActivationCondition(@Nonnull final Predicate<ProfileRequestContext> condition) {
+ activationCondition = Constraint.isNotNull(condition, "Activation condition cannot be null");
+ }
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractProfileConfiguration.java
new file mode 100644
index 0000000..bcd4aa3
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AbstractProfileConfiguration.java
@@ -0,0 +1,144 @@
+/*
+ * 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.profile.config;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
+import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.FunctionSupport;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.security.config.SecurityConfiguration;
+
+/** Base class for {@link ProfileConfiguration} implementations. */
+public abstract class AbstractProfileConfiguration extends AbstractIdentifiableInitializableComponent
+ implements ProfileConfiguration {
+
+ /** Default value for disallowedFeatures property. */
+ @Nonnull public static final Integer DEFAULT_DISALLOWED_FEATURES = 0;
+
+ /** Lookup function to supply securityConfiguration property. */
+ @Nonnull private Function<ProfileRequestContext,SecurityConfiguration> securityConfigurationLookupStrategy;
+
+ /** Lookup function to return a bitmask of request features to disallow. */
+ @Nonnull private Function<ProfileRequestContext,Integer> disallowedFeaturesLookupStrategy;
+
+ /**
+ * Constructor.
+ *
+ * @param id ID of the communication profile, never null or empty
+ */
+ public AbstractProfileConfiguration(@Nonnull @NotEmpty @ParameterName(name="id") final String id) {
+ setId(id);
+ securityConfigurationLookupStrategy = FunctionSupport.constant(null);
+ disallowedFeaturesLookupStrategy = FunctionSupport.constant(DEFAULT_DISALLOWED_FEATURES);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public SecurityConfiguration getSecurityConfiguration(
+ @Nullable final ProfileRequestContext profileRequestContext) {
+ return securityConfigurationLookupStrategy.apply(profileRequestContext);
+ }
+
+ /**
+ * Sets the security configuration for this profile.
+ *
+ * @param configuration security configuration for this profile
+ */
+ public void setSecurityConfiguration(@Nullable final SecurityConfiguration configuration) {
+ securityConfigurationLookupStrategy = FunctionSupport.constant(configuration);
+ }
+
+ /**
+ * Set a lookup strategy for the security configuration.
+ *
+ * @param strategy lookup strategy
+ *
+ * @since 3.3.0
+ */
+ public void setSecurityConfigurationLookupStrategy(
+ @Nonnull final Function<ProfileRequestContext,SecurityConfiguration> strategy) {
+ securityConfigurationLookupStrategy = Constraint.isNotNull(strategy, "Lookup strategy cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ public boolean isFeatureDisallowed(@Nullable final ProfileRequestContext profileRequestContext, final int feature) {
+ return (getDisallowedFeatures(profileRequestContext) & feature) == feature;
+ }
+
+ /** {@inheritDoc} */
+ public int getDisallowedFeatures(@Nullable final ProfileRequestContext profileRequestContext) {
+ final Integer mask = disallowedFeaturesLookupStrategy.apply(profileRequestContext);
+ return mask != null ? mask : DEFAULT_DISALLOWED_FEATURES;
+ }
+
+ /**
+ * Set a bitmask of disallowed features to block.
+ *
+ * @param mask a bitmask of features to block
+ *
+ * @since 3.3.0
+ */
+ public void setDisallowedFeatures(final int mask) {
+ disallowedFeaturesLookupStrategy = FunctionSupport.constant(mask);
+ }
+
+ /**
+ * Set a lookup strategy for the bitmask of disallowed features to block.
+ *
+ * @param strategy lookup strategy
+ *
+ * @since 3.3.0
+ */
+ public void setDisallowedFeaturesLookupStrategy(@Nonnull final Function<ProfileRequestContext,Integer> strategy) {
+ disallowedFeaturesLookupStrategy = Constraint.isNotNull(strategy, "Lookup strategy cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ return getId().hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof AbstractProfileConfiguration)) {
+ return false;
+ }
+
+ final AbstractProfileConfiguration other = (AbstractProfileConfiguration) obj;
+ return Objects.equals(getId(), other.getId());
+ }
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/AttributeResolvingProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AttributeResolvingProfileConfiguration.java
new file mode 100644
index 0000000..6270225
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/AttributeResolvingProfileConfiguration.java
@@ -0,0 +1,40 @@
+/*
+ * 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.profile.config;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * {@link ProfileConfiguration} with optional resolution of attributes.
+ *
+ * @since 4.2.0
+ */
+public interface AttributeResolvingProfileConfiguration extends ProfileConfiguration {
+
+ /**
+ * Get whether to resolve attributes.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return true iff resolution should be done
+ */
+ boolean isResolveAttributes(@Nullable final ProfileRequestContext profileRequestContext);
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/ConditionalProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/ConditionalProfileConfiguration.java
new file mode 100644
index 0000000..3849dbb
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/ConditionalProfileConfiguration.java
@@ -0,0 +1,40 @@
+/*
+ * 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.profile.config;
+
+import java.util.function.Predicate;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * A {@link ProfileConfiguration} supporting an activation condition.
+ *
+ * @since 3.4.0
+ */
+public interface ConditionalProfileConfiguration extends ProfileConfiguration {
+
+ /**
+ * Get the condition controlling enablement of this profile.
+ *
+ * @return condition controlling enablement of this profile
+ */
+ @Nonnull Predicate<ProfileRequestContext> getActivationCondition();
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/OverriddenIssuerProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/OverriddenIssuerProfileConfiguration.java
new file mode 100644
index 0000000..dac6bdb
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/OverriddenIssuerProfileConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * 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.profile.config;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
+/**
+ * {@link ProfileConfiguration} with optional override of issuer setting.
+ *
+ * @since 3.0.0
+ */
+public interface OverriddenIssuerProfileConfiguration extends ProfileConfiguration {
+
+ /**
+ * Get overridden issuer value.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return issuer or null to use usual default
+ */
+ @Nullable @NotEmpty String getIssuer(@Nullable final ProfileRequestContext profileRequestContext);
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/ProfileConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/ProfileConfiguration.java
new file mode 100644
index 0000000..4ec38cc
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/ProfileConfiguration.java
@@ -0,0 +1,65 @@
+/*
+ * 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.profile.config;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.security.config.SecurityConfiguration;
+
+import net.shibboleth.shared.component.IdentifiedComponent;
+
+/** Represents the configuration of a particular communication profile. */
+public interface ProfileConfiguration extends IdentifiedComponent {
+
+ /**
+ * Get the {@link SecurityConfiguration} to use with this profile.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return security configuration to use with this profile
+ */
+ @Nullable SecurityConfiguration getSecurityConfiguration(
+ @Nullable final ProfileRequestContext profileRequestContext);
+
+ /**
+ * Get a bitmask of disallowed features to block.
+ *
+ * <p>Individual profiles define their own feature constants.</p>
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return bitmask of features to block
+ *
+ * @since 5.0.0
+ */
+ public int getDisallowedFeatures(@Nullable final ProfileRequestContext profileRequestContext);
+
+ /**
+ * Return true iff the input feature constant is disallowed.
+ *
+ * @param profileRequestContext current profile request context
+ * @param feature a bit constant
+ *
+ * @return true iff the input feature constant is disallowed
+ *
+ * @since 5.0.0
+ */
+ public boolean isFeatureDisallowed(@Nullable final ProfileRequestContext profileRequestContext, final int feature);
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/package-info.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/package-info.java
new file mode 100644
index 0000000..b3599a5
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * Classes pertaining to request-time profile configuration options.
+ */
+
+package net.shibboleth.profile.config;
\ No newline at end of file
diff --git a/shib-profile-bom/pom.xml b/shib-profile-bom/pom.xml
index a86666d..f231d5e 100644
--- a/shib-profile-bom/pom.xml
+++ b/shib-profile-bom/pom.xml
@@ -27,6 +27,7 @@
<artifactId>shib-profile-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <!--
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>shib-profile-impl</artifactId>
@@ -42,6 +43,7 @@
<artifactId>shib-saml-profile-impl</artifactId>
<version>${project.version}</version>
</dependency>
+ -->
</dependencies>
</dependencyManagement>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list