[java-shib-profile] branch main updated: JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
Scott Cantor
cantor.2 at osu.edu
Thu Mar 2 15:35:22 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=d01a4b9a218f3f2cad373c476c3c876a20def4d8
The following commit(s) were added to refs/heads/main by this push:
new d01a4b9 JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
d01a4b9 is described below
commit d01a4b9a218f3f2cad373c476c3c876a20def4d8
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Mar 2 10:35:15 2023 -0500
JSPROF-1 - Move RelyingParty "layer" into java-shib-profile
https://shibboleth.atlassian.net/browse/JSPROF-1
Move in formerly IdP-specific RelyingPartyConfiguration additions.
---
.../config/logic/DetailedErrorsPredicate.java | 48 ++++
.../navigate/ResponderIdLookupFunction.java | 64 ++++++
.../relyingparty/RelyingPartyConfiguration.java | 74 ++++++-
.../RelyingPartyCredentialResolver.java | 3 +-
.../impl/CriteriaSelfEntityIDResolver.java | 243 +++++++++++++++++++++
.../RelyingPartyConfigurationSupport.java | 64 +-----
6 files changed, 442 insertions(+), 54 deletions(-)
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/config/logic/DetailedErrorsPredicate.java b/shib-profile-api/src/main/java/net/shibboleth/profile/config/logic/DetailedErrorsPredicate.java
new file mode 100644
index 0000000..b1cd8b3
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/config/logic/DetailedErrorsPredicate.java
@@ -0,0 +1,48 @@
+/*
+ * 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.logic;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.profile.context.logic.AbstractRelyingPartyPredicate;
+import net.shibboleth.profile.relyingparty.RelyingPartyConfiguration;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * Predicate to determine whether a relying party should see detailed error information.
+ */
+public class DetailedErrorsPredicate extends AbstractRelyingPartyPredicate {
+
+ /** {@inheritDoc} */
+ public boolean test(@Nullable final ProfileRequestContext input) {
+ if (input != null) {
+ final RelyingPartyContext rpc = getRelyingPartyContext(input);
+ if (rpc != null) {
+ final RelyingPartyConfiguration config = rpc.getConfiguration();
+ if (config != null) {
+ return config.isDetailedErrors(input);
+ }
+ }
+ }
+
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/context/navigate/ResponderIdLookupFunction.java b/shib-profile-api/src/main/java/net/shibboleth/profile/context/navigate/ResponderIdLookupFunction.java
new file mode 100644
index 0000000..d35739e
--- /dev/null
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/context/navigate/ResponderIdLookupFunction.java
@@ -0,0 +1,64 @@
+/*
+ * 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.context.navigate;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.profile.config.OverriddenIssuerProfileConfiguration;
+import net.shibboleth.profile.config.ProfileConfiguration;
+import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.profile.relyingparty.RelyingPartyConfiguration;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+/**
+ * A function that returns {@link net.shibboleth.profile.relyingparty.RelyingPartyConfiguration#getResponderId}() if
+ * available from a {@link RelyingPartyContext} obtained via a lookup function, by default a child of the
+ * {@link ProfileRequestContext}.
+ *
+ * <p>A special case applies if an active {@link OverriddenIssuerProfileConfiguration} is in effect, allowing the
+ * profile to override the usual value.</p>
+ *
+ * <p>If a specific setting is unavailable, a null value is returned.</p>
+ */
+public class ResponderIdLookupFunction extends AbstractRelyingPartyLookupFunction<String> {
+
+ /** {@inheritDoc} */
+ @Nullable public String apply(@Nullable final ProfileRequestContext input) {
+ if (input != null) {
+ final RelyingPartyContext rpc = getRelyingPartyContextLookupStrategy().apply(input);
+ if (rpc != null) {
+ final ProfileConfiguration pc = rpc.getProfileConfig();
+ if (pc instanceof OverriddenIssuerProfileConfiguration) {
+ final String issuer = ((OverriddenIssuerProfileConfiguration) pc).getIssuer(input);
+ if (issuer != null) {
+ return issuer;
+ }
+ }
+
+ final RelyingPartyConfiguration rpConfig = rpc.getConfiguration();
+ if (rpConfig != null) {
+ return rpConfig.getResponderId(input);
+ }
+ }
+ }
+
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyConfiguration.java b/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyConfiguration.java
index a802c6e..6ce80dc 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyConfiguration.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyConfiguration.java
@@ -31,6 +31,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
import net.shibboleth.profile.config.ProfileConfiguration;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
@@ -52,6 +53,12 @@ import net.shibboleth.shared.primitive.StringSupport;
public class RelyingPartyConfiguration extends AbstractIdentifiableInitializableComponent implements
IdentifiedComponent, Predicate<ProfileRequestContext> {
+ /** Lookup function to supply <code>responderId</code> property. */
+ @Nonnull private Function<ProfileRequestContext,String> responderIdLookupStrategy;
+
+ /** Controls whether detailed information about errors should be exposed. */
+ @Nonnull private Predicate<ProfileRequestContext> detailedErrorsPredicate;
+
/** Lookup function to supply <code>profileConfigurations</code> property. */
@Nonnull
private Function<ProfileRequestContext,Map<String,ProfileConfiguration>> profileConfigurationsLookupStrategy;
@@ -62,8 +69,73 @@ public class RelyingPartyConfiguration extends AbstractIdentifiableInitializable
/** Constructor. */
public RelyingPartyConfiguration() {
activationCondition = PredicateSupport.alwaysTrue();
+ responderIdLookupStrategy = FunctionSupport.constant(null);
+ detailedErrorsPredicate = PredicateSupport.alwaysFalse();
profileConfigurationsLookupStrategy = FunctionSupport.constant(null);
}
+
+ /**
+ * Get the self-referential ID to use when responding to requests.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return ID to use when responding
+ */
+ @Nullable @NotEmpty public String getResponderId(@Nullable final ProfileRequestContext profileRequestContext) {
+ return responderIdLookupStrategy.apply(profileRequestContext);
+ }
+
+ /**
+ * Set the self-referential ID to use when responding to messages.
+ *
+ * @param responder ID to use when responding to messages
+ */
+ public void setResponderId(@Nonnull @NotEmpty final String responder) {
+ checkSetterPreconditions();
+ final String id =
+ Constraint.isNotNull(StringSupport.trimOrNull(responder), "ResponderId cannot be null or empty");
+ responderIdLookupStrategy = FunctionSupport.constant(id);
+ }
+
+ /**
+ * Set a lookup strategy for the <code>responderId</code> property.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setResponderIdLookupStrategy(@Nonnull final Function<ProfileRequestContext,String> strategy) {
+ checkSetterPreconditions();
+ responderIdLookupStrategy = Constraint.isNotNull(strategy, "Lookup strategy cannot be null");
+ }
+
+ /**
+ * Get whether detailed information about errors should be exposed.
+ *
+ * @param profileRequestContext current profile request context
+ *
+ * @return true iff it is acceptable to expose detailed error information
+ */
+ public boolean isDetailedErrors(@Nullable final ProfileRequestContext profileRequestContext) {
+ return detailedErrorsPredicate.test(profileRequestContext);
+ }
+
+ /**
+ * Set whether detailed information about errors should be exposed.
+ *
+ * @param flag flag to set
+ */
+ public void setDetailedErrors(final boolean flag) {
+ checkSetterPreconditions();
+ detailedErrorsPredicate = PredicateSupport.constant(flag);
+ }
+
+ /**
+ * Set a condition to determine whether detailed information about errors should be exposed.
+ *
+ * @param condition condition to set
+ */
+ public void setDetailedErrorsPredicate(@Nonnull final Predicate<ProfileRequestContext> condition) {
+ detailedErrorsPredicate = Constraint.isNotNull(condition, "Condition cannot be null");
+ }
/**
* Get the unmodifiable set of profile configurations for this relying party.
@@ -147,7 +219,7 @@ public class RelyingPartyConfiguration extends AbstractIdentifiableInitializable
activationCondition =
Constraint.isNotNull(condition, "Relying party configuration activation condition cannot be null");
}
-
+
/** {@inheritDoc} */
public boolean test(@Nullable final ProfileRequestContext input) {
checkComponentActive();
diff --git a/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyCredentialResolver.java b/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyCredentialResolver.java
index 6f1b900..3cb5560 100644
--- a/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyCredentialResolver.java
+++ b/shib-profile-api/src/main/java/net/shibboleth/profile/relyingparty/RelyingPartyCredentialResolver.java
@@ -90,7 +90,8 @@ public class RelyingPartyCredentialResolver implements CredentialResolver, Ident
final UsageCriterion usage = criteria != null ? criteria.get(UsageCriterion.class) : null;
- try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
+ try (final ServiceableComponent<RelyingPartyConfigurationResolver> component =
+ service.getServiceableComponent()) {
final RelyingPartyConfigurationResolver resolver = component.getComponent();
if (usage != null) {
diff --git a/shib-profile-impl/src/main/java/net/shibboleth/profile/relyingparty/impl/CriteriaSelfEntityIDResolver.java b/shib-profile-impl/src/main/java/net/shibboleth/profile/relyingparty/impl/CriteriaSelfEntityIDResolver.java
new file mode 100644
index 0000000..a2f379e
--- /dev/null
+++ b/shib-profile-impl/src/main/java/net/shibboleth/profile/relyingparty/impl/CriteriaSelfEntityIDResolver.java
@@ -0,0 +1,243 @@
+/*
+ * 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.relyingparty.impl;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.core.criterion.EntityIdCriterion;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.profile.criterion.ProfileRequestContextCriterion;
+import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
+import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
+import org.opensaml.saml.criterion.RoleDescriptorCriterion;
+import org.opensaml.saml.saml2.metadata.EntityDescriptor;
+import org.opensaml.saml.saml2.metadata.RoleDescriptor;
+import org.slf4j.Logger;
+
+import net.shibboleth.profile.context.RelyingPartyContext;
+import net.shibboleth.profile.relyingparty.RelyingPartyConfiguration;
+import net.shibboleth.profile.relyingparty.RelyingPartyConfigurationResolver;
+import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.component.IdentifiableComponent;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.resolver.CriteriaSet;
+import net.shibboleth.shared.resolver.Resolver;
+import net.shibboleth.shared.resolver.ResolverException;
+import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
+import net.shibboleth.shared.service.ServiceableComponent;
+
+/**
+ * Resolver which uses an instance of {@link RelyingPartyConfigurationResolver} to
+ * resolve our own entityID.
+ *
+ * <p>
+ * The required and allowed criteria are the same as the {@link RelyingPartyConfigurationResolver}
+ * implementation in use.
+ * </p>
+ */
+public class CriteriaSelfEntityIDResolver extends AbstractIdentifiedInitializableComponent
+ implements Resolver<String, CriteriaSet>, IdentifiableComponent {
+
+ /** Logger. */
+ @Nonnull private Logger log = LoggerFactory.getLogger(CriteriaSelfEntityIDResolver.class);
+
+ /** The RelyingPartyConfigurationResolver to which to delegate. */
+ @NonnullAfterInit private ReloadableService<RelyingPartyConfigurationResolver> rpcResolver;
+
+ /**
+ * Set the {@link RelyingPartyConfigurationResolver} instance to which to delegate.
+ *
+ * @param resolver the relying party resolver
+ */
+ public void setRelyingPartyConfigurationResolver(
+ @Nullable final ReloadableService<RelyingPartyConfigurationResolver> resolver) {
+ checkSetterPreconditions();
+
+ rpcResolver = resolver;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setId(@Nonnull @NotEmpty final String componentId) {
+ super.setId(componentId);
+ }
+
+ /** {@inheritDoc} */
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (rpcResolver == null) {
+ throw new ComponentInitializationException("RelyingPartyConfigurationResolver cannot be null");
+ }
+ }
+
+ /** {@inheritDoc} */
+ protected void doDestroy() {
+ rpcResolver = null;
+ super.doDestroy();
+ }
+
+ /** {@inheritDoc} */
+ @Nonnull @NonnullElements public Iterable<String> resolve(@Nullable final CriteriaSet criteria)
+ throws ResolverException {
+ checkComponentActive();
+ final String entityID = resolveSingle(criteria);
+ if (entityID != null) {
+ return CollectionSupport.singletonList(entityID);
+ }
+ return CollectionSupport.emptyList();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public String resolveSingle(@Nullable final CriteriaSet criteria) throws ResolverException {
+ checkComponentActive();
+
+ final ProfileRequestContext prc = buildContext(criteria);
+ if (prc == null) {
+ log.error("Unable to extract or build ProfileRequestContext for resolution");
+ return null;
+ }
+
+ final CriteriaSet prcSet = new CriteriaSet(new ProfileRequestContextCriterion(prc));
+
+ try (final ServiceableComponent<RelyingPartyConfigurationResolver> resolver =
+ rpcResolver.getServiceableComponent()) {
+ final RelyingPartyConfiguration rpc = resolver.getComponent().resolveSingle(prcSet);
+ if (rpc != null) {
+ return rpc.getResponderId(prc);
+ } else {
+ log.error("RelyingPartyConfigurationResolver returned null configuration");
+ }
+ } catch (final ResolverException e) {
+ log.error("RelyingPartyConfigurationResolver did not resolve a RelyingPartyConfiguration: {}", e.getMessage());
+ } catch (final ServiceException e) {
+ log.error("RelyingPartyConfiguration resolver unvailable: {}", e.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Build and populate the synthetic instance of {@link ProfileRequestContext} which will be used
+ * in the resolution call to the delegate as well as to resolve the entityID setting.
+ *
+ * @param criteria the input criteria
+ * @return the synthetic context instance, or null if required data is not supplied
+ */
+ @Nullable private ProfileRequestContext buildContext(@Nullable final CriteriaSet criteria) {
+ if (criteria == null) {
+ return null;
+ }
+
+ final ProfileRequestContextCriterion prcCriterion = criteria.get(ProfileRequestContextCriterion.class);
+ if (prcCriterion != null) {
+ return prcCriterion.getProfileRequestContext();
+ }
+
+ final String entityID = resolveEntityID(criteria);
+ log.debug("Resolved effective entityID from criteria: {}", entityID);
+
+ final EntityDescriptor entityDescriptor = resolveEntityDescriptor(criteria);
+ log.debug("Resolved effective entity descriptor from criteria: {}", entityDescriptor);
+
+ final RoleDescriptor roleDescriptor = resolveRoleDescriptor(criteria);
+ log.debug("Resolved effective role descriptor from criteria: {}", roleDescriptor);
+
+ if (entityID != null || entityDescriptor != null || roleDescriptor != null) {
+ final ProfileRequestContext prc = new ProfileRequestContext();
+ final RelyingPartyContext rpc = prc.getOrCreateSubcontext(RelyingPartyContext.class);
+ rpc.setVerified(true);
+
+ rpc.setRelyingPartyId(entityID);
+
+ if (entityDescriptor != null || roleDescriptor != null) {
+ final SAMLPeerEntityContext peerContext = prc.getOrCreateSubcontext(SAMLPeerEntityContext.class);
+ rpc.setRelyingPartyIdContextTree(peerContext);
+
+ peerContext.setEntityId(entityID);
+
+ if (roleDescriptor != null) {
+ peerContext.setRole(roleDescriptor.getSchemaType() != null
+ ? roleDescriptor.getSchemaType() : roleDescriptor.getElementQName());
+ }
+
+ final SAMLMetadataContext metadataContext = peerContext.getOrCreateSubcontext(SAMLMetadataContext.class);
+ metadataContext.setEntityDescriptor(entityDescriptor);
+ metadataContext.setRoleDescriptor(roleDescriptor);
+ }
+ return prc;
+ }
+ return null;
+ }
+
+ /**
+ * Resolve the entityID from the criteria.
+ *
+ * @param criteria the input criteria
+ * @return the input entityID criterion or null if could not be resolved
+ */
+ @Nullable private String resolveEntityID(@Nonnull final CriteriaSet criteria) {
+ final EntityIdCriterion eic = criteria.get(EntityIdCriterion.class);
+ if (eic != null) {
+ return eic.getEntityId();
+ }
+
+ final EntityDescriptor ed = resolveEntityDescriptor(criteria);
+ if (ed != null) {
+ return ed.getEntityID();
+ }
+
+ return null;
+ }
+
+ /**
+ * Resolve the EntityDescriptor from the criteria.
+ *
+ * @param criteria the input criteria
+ * @return the input entity descriptor criterion, or null if could not be resolved
+ */
+ @Nullable private EntityDescriptor resolveEntityDescriptor(@Nonnull final CriteriaSet criteria) {
+ final RoleDescriptor rd = resolveRoleDescriptor(criteria);
+ if (rd != null && rd.getParent() != null && rd.getParent() instanceof EntityDescriptor) {
+ return (EntityDescriptor)rd.getParent();
+ }
+
+ return null;
+ }
+
+ /**
+ * Resolve the RoleDescriptor from the criteria.
+ *
+ * @param criteria the input criteria
+ * @return the input role descriptor criterion or null if could not be resolved
+ */
+ @Nullable private RoleDescriptor resolveRoleDescriptor(@Nonnull final CriteriaSet criteria) {
+ final RoleDescriptorCriterion rdc = criteria.get(RoleDescriptorCriterion.class);
+ if (rdc != null) {
+ return rdc.getRole();
+ }
+
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/relyingparty/RelyingPartyConfigurationSupport.java b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/relyingparty/RelyingPartyConfigurationSupport.java
index 1297825..c83d0bf 100644
--- a/shib-saml-profile-api/src/main/java/net/shibboleth/saml/relyingparty/RelyingPartyConfigurationSupport.java
+++ b/shib-saml-profile-api/src/main/java/net/shibboleth/saml/relyingparty/RelyingPartyConfigurationSupport.java
@@ -55,26 +55,16 @@ public final class RelyingPartyConfigurationSupport {
*
* <p>If a single ID is supplied, then the ID is also set as the identifier for the configuration.</p>
*
- * @param <T> type of configuration to manufacture
- *
- * @param claz class type to manufacture
* @param relyingPartyIds the relying parties for which the configuration should be active
*
* @return a default-constructed configuration with the appropriate condition set
- *
- * @throws Exception if the object cannot be constructed via a default constructor
*/
- @Nonnull public static <T extends RelyingPartyConfiguration> T byName(@Nonnull final Class<T> claz,
- @Nonnull @NonnullElements final Collection<String> relyingPartyIds) throws Exception {
+ @Nonnull public static RelyingPartyConfiguration byName(
+ @Nonnull @NonnullElements final Collection<String> relyingPartyIds) {
Constraint.isNotNull(relyingPartyIds, "Relying Party ID list cannot be null");
- final T config;
- try {
- config = claz.getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- throw e;
- }
+ final RelyingPartyConfiguration config = new RelyingPartyConfiguration();
config.setActivationCondition(new RelyingPartyIdPredicate(relyingPartyIds));
final StringBuffer name = new StringBuffer("EntityNames[");
@@ -92,19 +82,14 @@ public final class RelyingPartyConfigurationSupport {
* one or more {@link org.opensaml.saml.saml2.metadata.EntitiesDescriptor} groups, and optionally via
* {@link org.opensaml.saml.saml2.metadata.AffiliationDescriptor} lookup.
*
- * @param <T> type of configuration to manufacture
- *
- * @param claz class type to manufacture
* @param groupNames the group names
* @param resolver optional metadata source for affiliation lookup
*
* @return a default-constructed configuration with the appropriate condition set
- *
- * @throws Exception if the object cannot be constructed via a default constructor
*/
- @Nonnull public static <T extends RelyingPartyConfiguration> T byGroup(@Nonnull final Class<T> claz,
+ @Nonnull public static RelyingPartyConfiguration byGroup(
@Nonnull @NonnullElements final Collection<String> groupNames,
- @Nullable final MetadataResolver resolver) throws Exception {
+ @Nullable final MetadataResolver resolver) {
Constraint.isNotNull(groupNames, "Group name list cannot be null");
// We adapt an OpenSAML Predicate applying to an EntityDescriptor by indirecting the lookup of the
@@ -115,12 +100,7 @@ public final class RelyingPartyConfigurationSupport {
new EntityDescriptorLookupFunction().compose(new SAMLMetadataContextLookupFunction()),
new EntityGroupNamePredicate(groupNames, resolver));
- final T config;
- try {
- config = claz.getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- throw e;
- }
+ final RelyingPartyConfiguration config = new RelyingPartyConfiguration();
config.setActivationCondition(indirectPredicate);
final StringBuffer name = new StringBuffer("EntityGroups[");
@@ -138,20 +118,15 @@ public final class RelyingPartyConfigurationSupport {
* A shorthand method for constructing a {@link RelyingPartyConfiguration} with an activation condition based on
* an {@link EntityAttributesPredicate}.
*
- * @param <T> type of configuration to manufacture
- *
- * @param claz class type to manufacture
* @param candidates the candidate rules
* @param trim true iff tag values in metadata should be trimmed before comparison
* @param matchAll true iff all the candidate rules are required to match
*
* @return a default-constructed configuration with the appropriate condition set
- *
- * @throws Exception if the object cannot be constructed via a default constructor
*/
- @Nonnull public static <T extends RelyingPartyConfiguration> T byTag(@Nonnull final Class<T> claz,
+ @Nonnull public static RelyingPartyConfiguration byTag(
@Nonnull @NonnullElements final Collection<Candidate> candidates, final boolean trim,
- final boolean matchAll) throws Exception {
+ final boolean matchAll) {
Constraint.isNotNull(candidates, "Candidate list cannot be null");
// We adapt an OpenSAML Predicate applying to an EntityDescriptor by indirecting the lookup of the
@@ -162,12 +137,7 @@ public final class RelyingPartyConfigurationSupport {
new EntityDescriptorLookupFunction().compose(new SAMLMetadataContextLookupFunction()),
new EntityAttributesPredicate(candidates, trim, matchAll));
- final T config;
- try {
- config = claz.getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- throw e;
- }
+ final RelyingPartyConfiguration config = new RelyingPartyConfiguration();
config.setActivationCondition(indirectPredicate);
return config;
@@ -177,20 +147,15 @@ public final class RelyingPartyConfigurationSupport {
* A shorthand method for constructing a {@link RelyingPartyConfiguration} with an activation condition based on
* a {@link MappedEntityAttributesPredicate}.
*
- * @param <T> type of configuration to manufacture
- *
- * @param claz class type to manufacture
* @param candidates the candidate rules
* @param trim true iff tag values in metadata should be trimmed before comparison
* @param matchAll true iff all the candidate rules are required to match
*
* @return a default-constructed configuration with the appropriate condition set
- *
- * @throws Exception if the object cannot be constructed via a default constructor
*/
- @Nonnull public static <T extends RelyingPartyConfiguration> T byMappedTag(@Nonnull final Class<T> claz,
+ @Nonnull public static RelyingPartyConfiguration byMappedTag(
@Nonnull @NonnullElements final Collection<Candidate> candidates, final boolean trim,
- final boolean matchAll) throws Exception {
+ final boolean matchAll) {
Constraint.isNotNull(candidates, "Candidate list cannot be null");
// We adapt an OpenSAML Predicate applying to an EntityDescriptor by indirecting the lookup of the
@@ -201,12 +166,7 @@ public final class RelyingPartyConfigurationSupport {
new EntityDescriptorLookupFunction().compose(new SAMLMetadataContextLookupFunction()),
new MappedEntityAttributesPredicate(candidates, trim, matchAll));
- final T config;
- try {
- config = claz.getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- throw e;
- }
+ final RelyingPartyConfiguration config = new RelyingPartyConfiguration();
config.setActivationCondition(indirectPredicate);
return config;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list