[java-opensaml] 01/02: Remove unused classes.
Scott Cantor
cantor.2 at osu.edu
Wed Jun 7 15:46:41 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=db2bbb55769cfd8ef5b01cb0df133657d645244c
commit db2bbb55769cfd8ef5b01cb0df133657d645244c
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jun 7 11:46:08 2023 -0400
Remove unused classes.
---
.../saml/criterion/BindingLocationCriterion.java | 92 ----------
.../BindingResponseLocationCriterion.java | 86 ----------
.../InlineSelfEncryptionParametersStrategy.java | 191 ---------------------
...InlineSelfEncryptionParametersStrategyTest.java | 159 -----------------
4 files changed, 528 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingLocationCriterion.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingLocationCriterion.java
deleted file mode 100644
index 3e6e03c57..000000000
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingLocationCriterion.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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 org.opensaml.saml.criterion;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.resolver.Criterion;
-
-/**
- * {@link Criterion} representing a SAML binding location.
- *
- * <p>There appears to be no use of this class throughout the library, so it is proposed for
- * removal.</p>
- *
- * @deprecated
- */
- at Deprecated(since="4.2.0", forRemoval=true)
-public final class BindingLocationCriterion implements Criterion {
-
- /** The binding location URI. */
- @Nonnull @NotEmpty private final String location;
-
- /**
- * Constructor.
- *
- * @param locationUri the binding location URI
- */
- public BindingLocationCriterion(@Nonnull @NotEmpty final String locationUri) {
- location = Constraint.isNotNull(StringSupport.trimOrNull(locationUri), "Location cannot be null or empty");
- }
-
- /**
- * Get the binding location URI.
- *
- * @return the binding location URI
- */
- @Nonnull @NotEmpty public String getLocation() {
- return location;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("BindingLocation [location=");
- builder.append(location);
- builder.append("]");
- return builder.toString();
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return location.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (obj instanceof BindingLocationCriterion) {
- return location.equals(((BindingLocationCriterion) obj).location);
- }
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingResponseLocationCriterion.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingResponseLocationCriterion.java
deleted file mode 100644
index 9c3c7047b..000000000
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/criterion/BindingResponseLocationCriterion.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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 org.opensaml.saml.criterion;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.shared.resolver.Criterion;
-
-/** {@link Criterion} representing a SAML binding resonse location. */
-public final class BindingResponseLocationCriterion implements Criterion {
-
- /** The binding response location URI. */
- @Nonnull @NotEmpty private final String location;
-
- /**
- * Constructor.
- *
- * @param responseLocationUri the binding response location URI
- */
- public BindingResponseLocationCriterion(@Nonnull @NotEmpty final String responseLocationUri) {
- location =
- Constraint.isNotNull(StringSupport.trimOrNull(responseLocationUri),
- "Response location cannot be null or empty");
- }
-
- /**
- * Get the binding response location URI.
- *
- * @return the binding response location URI
- */
- @Nonnull @NotEmpty public String getLocation() {
- return location;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("BindingResponseLocation [location=");
- builder.append(location);
- builder.append("]");
- return builder.toString();
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return location.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (obj instanceof BindingResponseLocationCriterion) {
- return location.equals(((BindingResponseLocationCriterion) obj).location);
- }
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategy.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategy.java
deleted file mode 100644
index 38cae99f6..000000000
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategy.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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 org.opensaml.saml.security.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Function;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.collection.Pair;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.primitive.LoggerFactory;
-import net.shibboleth.shared.resolver.CriteriaSet;
-import net.shibboleth.shared.resolver.ResolverException;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.security.credential.Credential;
-import org.opensaml.security.credential.CredentialResolver;
-import org.opensaml.security.credential.UsageType;
-import org.opensaml.security.criteria.UsageCriterion;
-import org.opensaml.xmlsec.EncryptionConfiguration;
-import org.opensaml.xmlsec.EncryptionParameters;
-import org.opensaml.xmlsec.EncryptionParametersResolver;
-import org.opensaml.xmlsec.SecurityConfigurationSupport;
-import org.opensaml.xmlsec.criterion.EncryptionConfigurationCriterion;
-import org.opensaml.xmlsec.impl.BasicEncryptionConfiguration;
-import org.slf4j.Logger;
-
-import com.google.common.collect.Iterables;
-
-/**
- * Strategy function for resolving {@link EncryptionParameters} used to encrypt to oneself.
- */
-public class InlineSelfEncryptionParametersStrategy
- implements Function<Pair<ProfileRequestContext, EncryptionParameters>, List<EncryptionParameters>> {
-
- /** Logger. */
- @Nonnull private Logger log = LoggerFactory.getLogger(InlineSelfEncryptionParametersStrategy.class);
-
- /** Credential resolver for self-encryption. */
- @Nonnull private CredentialResolver credentialResolver;
-
- /** Encryption parameters resolver for self-encryption. */
- @Nonnull private EncryptionParametersResolver encParamsresolver;
-
- /** Strategy function for resolving the list of effective base encryption configurations to use. */
- @Nullable private Function<ProfileRequestContext,List<EncryptionConfiguration>> configurationLookupStrategy;
-
- /**
- * Constructor.
- *
- * @param credResolver resolver for self-encryption credentials
- * @param paramsResolver resolver for self-encryption parameters
- */
- public InlineSelfEncryptionParametersStrategy(@Nonnull final CredentialResolver credResolver,
- @Nonnull final EncryptionParametersResolver paramsResolver) {
- this(credResolver, paramsResolver, null);
- }
-
- /**
- * Constructor.
- *
- * @param credResolver resolver for self-encryption credentials
- * @param paramsResolver resolver for self-encryption parameters
- * @param configStrategy strategy for resolving the list of effective base encryption configurations
- */
- public InlineSelfEncryptionParametersStrategy(@Nonnull final CredentialResolver credResolver,
- @Nonnull final EncryptionParametersResolver paramsResolver,
- @Nullable final Function<ProfileRequestContext,List<EncryptionConfiguration>> configStrategy) {
- credentialResolver = Constraint.isNotNull(credResolver, "CredentialResolver was null");
- encParamsresolver = Constraint.isNotNull(paramsResolver, "EncryptionParametersResolver was null");
- configurationLookupStrategy = configStrategy;
- }
-
- /** {@inheritDoc} */
- @Nullable
- public List<EncryptionParameters> apply(@Nullable final Pair<ProfileRequestContext, EncryptionParameters> input) {
-
- final ProfileRequestContext profileRequestContext = input != null ? input.getFirst() : null;
- if (profileRequestContext == null) {
- log.debug("Input Pair or ProfileRequestContext was null, skipping");
- return CollectionSupport.emptyList();
- }
-
- final List<Credential> credentials = resolveCredentials(profileRequestContext);
- if (credentials.isEmpty()) {
- log.debug("No self-encryption credentials were resolved, skipping further processing");
- return CollectionSupport.emptyList();
- }
- log.debug("Resolved {} self-encryption credentials", credentials.size());
-
- final List<EncryptionConfiguration> baseConfigs = resolveBaseConfigurations(profileRequestContext);
- log.debug("Resolved {} base EncryptionConfigurations", baseConfigs.size());
-
- final ArrayList<EncryptionParameters> encParams = new ArrayList<>();
-
- final EncryptionParameters requestParams = input != null ? input.getSecond() : null;
-
- for (final Credential cred : credentials) {
- assert cred != null;
-
- final BasicEncryptionConfiguration selfConfig = new BasicEncryptionConfiguration();
- selfConfig.setKeyTransportEncryptionCredentials(CollectionSupport.singletonList(cred));
- if (requestParams != null) {
- final String dataEncAlg = requestParams.getDataEncryptionAlgorithm();
- if (dataEncAlg != null) {
- selfConfig.setDataEncryptionAlgorithms(CollectionSupport.singletonList(dataEncAlg));
- }
- }
-
- final ArrayList<EncryptionConfiguration> configs = new ArrayList<>();
- configs.add(selfConfig);
- configs.addAll(baseConfigs);
-
- try {
- Iterables.addAll(encParams, encParamsresolver.resolve(
- new CriteriaSet(new EncryptionConfigurationCriterion(configs))));
- } catch (final ResolverException e) {
- log.error("Error resolving self-encryption parameters for Credential '{}', "
- + "params from other Credentials may still succeed", cred, e);
- }
- }
-
- log.debug("Resolved {} self-encryption EncryptionParameters", encParams.size());
-
- return encParams;
- }
-
- /**
- * Resolve the list of self-encryption credentials.
- *
- * @param profileRequestContext the current profile request context
- *
- * @return the resolved credentials
- */
- @Nonnull protected List<Credential> resolveCredentials(
- @Nonnull final ProfileRequestContext profileRequestContext) {
- try {
- final ArrayList<Credential> credentials = new ArrayList<>();
- Iterables.addAll(credentials, credentialResolver.resolve(
- new CriteriaSet(new UsageCriterion(UsageType.ENCRYPTION))));
- return credentials;
- } catch (final ResolverException e) {
- log.error("Error resolving IdP encryption credentials", e);
- return CollectionSupport.emptyList();
- }
- }
-
- /**
- * Resolve the list of effective base {@link EncryptionConfiguration} for self-encryption.
- *
- * @param profileRequestContext the current profile request context
- *
- * @return the resolved configurations
- */
- @Nonnull protected List<EncryptionConfiguration> resolveBaseConfigurations(
- @Nonnull final ProfileRequestContext profileRequestContext) {
- List<EncryptionConfiguration> baseConfigs = null;
- if (configurationLookupStrategy != null) {
- log.debug("Self-encryption EncryptionConfiguration lookup strategy was non-null");
- assert configurationLookupStrategy != null;
- baseConfigs = configurationLookupStrategy.apply(profileRequestContext);
- } else {
- log.debug("Self-encryption EncryptionConfiguration lookup strategy was null");
- }
- if (baseConfigs != null) {
- return baseConfigs;
- }
- log.debug("No self-encryption EncryptionConfigurations were resolved, returning global configuration");
- return CollectionSupport.singletonList(SecurityConfigurationSupport.ensureGlobalEncryptionConfiguration());
- }
-
-}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategyTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategyTest.java
deleted file mode 100644
index 313f9c6c2..000000000
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/security/impl/InlineSelfEncryptionParametersStrategyTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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 org.opensaml.saml.security.impl;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Function;
-
-import javax.annotation.Nullable;
-
-import org.opensaml.core.testing.OpenSAMLInitBaseTestCase;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.profile.testing.RequestContextBuilder;
-import org.opensaml.security.credential.Credential;
-import org.opensaml.security.credential.impl.CollectionCredentialResolver;
-import org.opensaml.xmlsec.EncryptionConfiguration;
-import org.opensaml.xmlsec.EncryptionParameters;
-import org.opensaml.xmlsec.EncryptionParametersResolver;
-import org.opensaml.xmlsec.SecurityConfigurationSupport;
-import org.opensaml.xmlsec.algorithm.AlgorithmSupport;
-import org.opensaml.xmlsec.encryption.support.EncryptionConstants;
-import org.opensaml.xmlsec.encryption.support.RSAOAEPParameters;
-import org.opensaml.xmlsec.impl.BasicEncryptionConfiguration;
-import org.opensaml.xmlsec.impl.BasicEncryptionParametersResolver;
-import org.opensaml.xmlsec.signature.support.SignatureConstants;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import net.shibboleth.shared.collection.CollectionSupport;
-import net.shibboleth.shared.collection.Pair;
-
- at SuppressWarnings({"null", "javadoc"})
-public class InlineSelfEncryptionParametersStrategyTest extends OpenSAMLInitBaseTestCase {
-
- private Credential cred1, cred2;
-
- private List<Credential> resolverCreds;
-
- private CollectionCredentialResolver credResolver;
-
- private EncryptionParametersResolver paramsResolver;
-
- private ProfileRequestContext prc;
-
- @BeforeClass
- public void classSetUp() throws NoSuchAlgorithmException, NoSuchProviderException {
- cred1 = AlgorithmSupport.generateKeyPairAndCredential(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP, 1024, true);
- cred2 = AlgorithmSupport.generateKeyPairAndCredential(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP, 1024, true);
-
- paramsResolver = new BasicEncryptionParametersResolver();
- }
-
- @BeforeMethod
- public void setUp() {
- resolverCreds = new ArrayList<>();
- credResolver = new CollectionCredentialResolver(resolverCreds);
-
- prc = new RequestContextBuilder().buildProfileRequestContext();
- }
-
- @Test
- public void testNoCreds() {
- final InlineSelfEncryptionParametersStrategy strategy = new InlineSelfEncryptionParametersStrategy(credResolver, paramsResolver);
- final List<EncryptionParameters> encParameters = strategy.apply(new Pair<ProfileRequestContext, EncryptionParameters>(prc, null));
- assert encParameters != null;
- Assert.assertTrue(encParameters.isEmpty());
- }
-
- @Test
- public void testSingleCred() {
- resolverCreds.add(cred1);
-
- final InlineSelfEncryptionParametersStrategy strategy = new InlineSelfEncryptionParametersStrategy(credResolver, paramsResolver);
- final List<EncryptionParameters> encParameters = strategy.apply(new Pair<ProfileRequestContext, EncryptionParameters>(prc, null));
-
- assert encParameters != null;
- Assert.assertEquals(encParameters.size(), 1);
- Assert.assertSame(encParameters.get(0).getKeyTransportEncryptionCredential(), cred1);
- Assert.assertEquals(encParameters.get(0).getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP);
-
- final RSAOAEPParameters oaep = encParameters.get(0).getRSAOAEPParameters();
- assert oaep != null;
- Assert.assertEquals(oaep.getDigestMethod(), SignatureConstants.ALGO_ID_DIGEST_SHA1);
- Assert.assertEquals(oaep.getMaskGenerationFunction(), EncryptionConstants.ALGO_ID_MGF1_SHA1);
- }
-
- @Test
- public void testMultipleCreds() {
- resolverCreds.add(cred1);
- resolverCreds.add(cred2);
-
- final InlineSelfEncryptionParametersStrategy strategy = new InlineSelfEncryptionParametersStrategy(credResolver, paramsResolver);
- final List<EncryptionParameters> encParameters = strategy.apply(new Pair<ProfileRequestContext, EncryptionParameters>(prc, null));
-
- assert encParameters != null;
- Assert.assertEquals(encParameters.size(), 2);
- Assert.assertSame(encParameters.get(0).getKeyTransportEncryptionCredential(), cred1);
- Assert.assertEquals(encParameters.get(0).getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP);
-
- final RSAOAEPParameters oaep1 = encParameters.get(0).getRSAOAEPParameters();
- assert oaep1 != null;
- Assert.assertEquals(oaep1.getDigestMethod(), SignatureConstants.ALGO_ID_DIGEST_SHA1);
-
- Assert.assertSame(encParameters.get(1).getKeyTransportEncryptionCredential(), cred2);
- Assert.assertEquals(encParameters.get(1).getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP);
-
- final RSAOAEPParameters oaep2 = encParameters.get(0).getRSAOAEPParameters();
- assert oaep2 != null;
- Assert.assertEquals(oaep2.getDigestMethod(), SignatureConstants.ALGO_ID_DIGEST_SHA1);
- }
-
- @Test
- public void testConfigLookup() {
- resolverCreds.add(cred1);
-
- final Function<ProfileRequestContext, List<EncryptionConfiguration>> configStrategy = new Function<>() {
- public List<EncryptionConfiguration> apply(@Nullable ProfileRequestContext input) {
- final BasicEncryptionConfiguration selfConfig = new BasicEncryptionConfiguration();
- final RSAOAEPParameters rsaParams = new RSAOAEPParameters();
- rsaParams.setDigestMethod(EncryptionConstants.ALGO_ID_DIGEST_SHA256);
- selfConfig.setRSAOAEPParameters(rsaParams);
- selfConfig.setRSAOAEPParametersMerge(true);
- return CollectionSupport.listOf(selfConfig, SecurityConfigurationSupport.ensureGlobalEncryptionConfiguration());
- }};
-
- final InlineSelfEncryptionParametersStrategy strategy = new InlineSelfEncryptionParametersStrategy(credResolver, paramsResolver, configStrategy);
- final List<EncryptionParameters> encParameters = strategy.apply(new Pair<ProfileRequestContext, EncryptionParameters>(prc, null));
-
- assert encParameters != null;
- Assert.assertEquals(encParameters.size(), 1);
- Assert.assertSame(encParameters.get(0).getKeyTransportEncryptionCredential(), cred1);
- Assert.assertEquals(encParameters.get(0).getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP);
-
- final RSAOAEPParameters oaep = encParameters.get(0).getRSAOAEPParameters();
- assert oaep != null;
- Assert.assertEquals(oaep.getDigestMethod(), EncryptionConstants.ALGO_ID_DIGEST_SHA256);
- }
-
-
-}
\ 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