[java-idp-oidc] branch main updated: Deleted classes that were moved to commons earlier.
Henri Mikkonen
henri.mikkonen at iki.fi
Fri Jan 27 15:36:49 UTC 2023
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=96531369e78ccc6fca758aa58a7c8e580742e59a
The following commit(s) were added to refs/heads/main by this push:
new 96531369 Deleted classes that were moved to commons earlier.
96531369 is described below
commit 96531369e78ccc6fca758aa58a7c8e580742e59a
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Jan 27 17:36:34 2023 +0200
Deleted classes that were moved to commons earlier.
---
.../impl/FormOutboundKeySetResponseMessage.java | 157 ------------------
.../FormOutboundKeySetResponseMessageTest.java | 178 ---------------------
2 files changed, 335 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessage.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessage.java
deleted file mode 100644
index 765e9a6c..00000000
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessage.java
+++ /dev/null
@@ -1,157 +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 net.shibboleth.idp.plugin.oidc.op.profile.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.function.Function;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.messaging.context.navigate.ChildContextLookup;
-import org.opensaml.profile.action.ActionSupport;
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.security.credential.Credential;
-import org.opensaml.xmlsec.EncryptionConfiguration;
-import org.opensaml.xmlsec.SignatureSigningConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.nimbusds.jose.jwk.JWK;
-import com.nimbusds.jose.jwk.JWKSet;
-
-import net.minidev.json.JSONObject;
-import net.shibboleth.idp.plugin.oidc.op.messaging.impl.KeySetSuccessResponse;
-import net.shibboleth.idp.profile.AbstractProfileAction;
-import net.shibboleth.idp.profile.IdPEventIds;
-import net.shibboleth.idp.profile.config.SecurityConfiguration;
-import net.shibboleth.idp.profile.context.RelyingPartyContext;
-import net.shibboleth.oidc.profile.config.JSONSecurityConfiguration;
-import net.shibboleth.oidc.security.impl.CredentialConversionUtil;
-import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-
-/**
- * Action that forms outbound message containing keyset. Keys of the keyset are located from security configuration.
- * Formed message is set to {@link ProfileRequestContext#getOutboundMessageContext()}.
- */
-public class FormOutboundKeySetResponseMessage extends AbstractProfileAction {
-
- /** Class logger. */
- @Nonnull private Logger log = LoggerFactory.getLogger(FormOutboundKeySetResponseMessage.class);
-
- /**
- * Strategy used to locate the {@link RelyingPartyContext} associated with a given {@link ProfileRequestContext}.
- */
- @Nonnull private Function<ProfileRequestContext, RelyingPartyContext> relyingPartyContextLookupStrategy;
-
- /** Security configuration we look for keys to publish. */
- @Nullable private JSONSecurityConfiguration secConfiguration;
-
- /** Constructor. */
- public FormOutboundKeySetResponseMessage() {
- relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
- }
-
- /**
- * Set the strategy used to locate the {@link RelyingPartyContext} associated with a given
- * {@link ProfileRequestContext}.
- *
- * @param strategy strategy used to locate the {@link RelyingPartyContext} associated with a given
- * {@link ProfileRequestContext}
- */
- public void setRelyingPartyContextLookupStrategy(
- @Nonnull final Function<ProfileRequestContext, RelyingPartyContext> strategy) {
- ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- relyingPartyContextLookupStrategy =
- Constraint.isNotNull(strategy, "RelyingPartyContext lookup strategy cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
- if (!super.doPreExecute(profileRequestContext)) {
- return false;
- }
-
- final RelyingPartyContext rpCtx = relyingPartyContextLookupStrategy.apply(profileRequestContext);
- if (rpCtx == null) {
- log.debug("{} No relying party context associated with this profile request", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CTX);
- return false;
- }
-
- if (rpCtx.getProfileConfig() == null) {
- log.debug("{} No profile configuration associated with this profile request", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_RELYING_PARTY_CTX);
- return false;
- }
-
- final SecurityConfiguration securityConfig =
- rpCtx.getProfileConfig().getSecurityConfiguration(profileRequestContext);
-
- if (!(securityConfig instanceof JSONSecurityConfiguration)) {
- log.debug("{} No security configuration associated with the profile configuration of the profile request",
- getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_SEC_CFG);
- return false;
- }
-
- secConfiguration = (JSONSecurityConfiguration) securityConfig;
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- final List<JWK> publishList = new ArrayList<JWK>();
- final SignatureSigningConfiguration signingConfig = secConfiguration.getSignatureSigningConfiguration();
- if (signingConfig != null) {
- convertAndPublishToList(signingConfig.getSigningCredentials(), publishList);
- }
- final EncryptionConfiguration encryptionConfig = secConfiguration.getEncryptionConfiguration();
- if (encryptionConfig != null) {
- convertAndPublishToList(encryptionConfig.getKeyTransportEncryptionCredentials(), publishList);
- }
- final JWKSet keySet = new JWKSet(publishList);
- final JSONObject keySetJson = new JSONObject(keySet.toJSONObject());
- profileRequestContext.getOutboundMessageContext().setMessage(new KeySetSuccessResponse(keySetJson));
- }
-
- /**
- * Converts the given credentials into JWK and adds all the successfully converted JWKs to the given list.
- *
- * @param credentials The list of credentials to be converted to JWKs.
- * @param publishList The list where the successfully converted JWKs are put.
- */
- protected void convertAndPublishToList(final List<Credential> credentials, final List<JWK> publishList) {
- if (credentials != null) {
- for (final Credential credential : credentials) {
- final JWK jwk = CredentialConversionUtil.credentialToKey(credential);
- if (jwk != null) {
- publishList.add(jwk);
- }
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessageTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessageTest.java
deleted file mode 100644
index 3641f000..00000000
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/FormOutboundKeySetResponseMessageTest.java
+++ /dev/null
@@ -1,178 +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 net.shibboleth.idp.plugin.oidc.op.profile.impl;
-
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.minidev.json.JSONArray;
-import net.minidev.json.JSONObject;
-import net.shibboleth.idp.plugin.oidc.op.messaging.JSONSuccessResponse;
-import net.shibboleth.idp.plugin.oidc.op.profile.spring.factory.BasicJWKCredentialFactoryBean;
-import net.shibboleth.idp.profile.IdPEventIds;
-import net.shibboleth.idp.profile.context.RelyingPartyContext;
-import net.shibboleth.idp.profile.context.navigate.WebflowRequestContextProfileRequestContextLookup;
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-import net.shibboleth.idp.profile.testing.RequestContextBuilder;
-import net.shibboleth.oidc.profile.config.JSONSecurityConfiguration;
-import net.shibboleth.oidc.profile.config.OIDCPublishKeySetConfiguration;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-
-import org.mockito.Mockito;
-import org.opensaml.messaging.context.MessageContext;
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.opensaml.security.credential.Credential;
-import org.opensaml.xmlsec.EncryptionConfiguration;
-import org.opensaml.xmlsec.SignatureSigningConfiguration;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.webflow.execution.Event;
-import org.springframework.webflow.execution.RequestContext;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import com.nimbusds.jose.JOSEException;
-import com.nimbusds.oauth2.sdk.ParseException;
-
-/** {@link FormOutboundKeySetResponseMessage} unit test. */
-public class FormOutboundKeySetResponseMessageTest {
-
- private ProfileRequestContext profileRequestCtx;
-
- private FormOutboundKeySetResponseMessage action;
-
- private RequestContext requestCtx;
-
- private OIDCPublishKeySetConfiguration profileConf;
-
- private RelyingPartyContext rpCtx;
-
- @BeforeMethod
- public void init() throws Exception {
- requestCtx = new RequestContextBuilder().buildRequestContext();
- final MessageContext msgCtx = new MessageContext();
- profileRequestCtx = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
- profileRequestCtx.setOutboundMessageContext(msgCtx);
- rpCtx = profileRequestCtx.getSubcontext(RelyingPartyContext.class, true);
-
- final List<Credential> signCreds = new ArrayList<Credential>();
- BasicJWKCredentialFactoryBean factory = new BasicJWKCredentialFactoryBean();
- factory.setResource(new ClassPathResource("credentials/idp-signing-es.jwk"));
- factory.afterPropertiesSet();
- signCreds.add(factory.getObject());
-
- factory = new BasicJWKCredentialFactoryBean();
- factory.setResource(new ClassPathResource("credentials/idp-signing-rs.jwk"));
- factory.afterPropertiesSet();
- signCreds.add(factory.getObject());
-
- factory = new BasicJWKCredentialFactoryBean();
- factory.setResource(new ClassPathResource("credentials/idp-encryption-rsa.jwk"));
- factory.afterPropertiesSet();
- final List<Credential> encCreds = new ArrayList<>();
- encCreds.add(factory.getObject());
-
- final SignatureSigningConfiguration signConfig = Mockito.mock(SignatureSigningConfiguration.class);
- Mockito.when(signConfig.getSigningCredentials()).thenReturn(signCreds);
- final EncryptionConfiguration decConfig = Mockito.mock(EncryptionConfiguration.class);
- Mockito.when(decConfig.getKeyTransportEncryptionCredentials()).thenReturn(encCreds);
-
- final JSONSecurityConfiguration secConf = new JSONSecurityConfiguration();
- secConf.setSignatureSigningConfiguration(signConfig);
- secConf.setEncryptionConfiguration(decConfig);
-
- profileConf = new OIDCPublishKeySetConfiguration();
- profileConf.setSecurityConfiguration(secConf);
- rpCtx.setProfileConfig(profileConf);
- action = new FormOutboundKeySetResponseMessage();
- action.initialize();
- }
-
- /**
- * Test that action is able to form success message.
- *
- * @throws ComponentInitializationException
- * @throws URISyntaxException
- * @throws java.text.ParseException
- * @throws JOSEException
- */
- @Test
- public void testSuccessMessage() throws ComponentInitializationException, URISyntaxException, ParseException,
- JOSEException, java.text.ParseException {
- final Event event = action.execute(requestCtx);
- ActionTestingSupport.assertProceedEvent(event);
- Assert.assertTrue(profileRequestCtx.getOutboundMessageContext().getMessage() instanceof JSONSuccessResponse);
- final JSONSuccessResponse resp =
- (JSONSuccessResponse) profileRequestCtx.getOutboundMessageContext().getMessage();
- Assert.assertTrue(resp.indicatesSuccess());
- final JSONObject keyset = resp.toHTTPResponse().getContentAsJSONObject();
- final JSONArray keys = (JSONArray) keyset.get("keys");
- //The test for content could be more thorough
- Assert.assertEquals(keys.size(), 3);
- }
-
- /**
- * Test case of no sec conf.
- *
- * @throws ComponentInitializationException
- * @throws URISyntaxException
- * @throws ParseException
- * @throws JOSEException
- */
- @Test
- public void testFailNoSecConf()
- throws ComponentInitializationException, URISyntaxException, ParseException, JOSEException {
- profileConf.setSecurityConfiguration(null);
- final Event event = action.execute(requestCtx);
- ActionTestingSupport.assertEvent(event, EventIds.INVALID_SEC_CFG);
- }
-
- /**
- * Test case of no profile conf.
- *
- * @throws ComponentInitializationException
- * @throws URISyntaxException
- * @throws ParseException
- * @throws JOSEException
- */
- @Test
- public void testFailNoProfileConf()
- throws ComponentInitializationException, URISyntaxException, ParseException, JOSEException {
- rpCtx.setProfileConfig(null);
- final Event event = action.execute(requestCtx);
- ActionTestingSupport.assertEvent(event, IdPEventIds.INVALID_RELYING_PARTY_CTX);
- }
-
- /**
- * Test case of no rp ctx.
- *
- * @throws ComponentInitializationException
- * @throws URISyntaxException
- * @throws ParseException
- * @throws JOSEException
- */
- @Test
- public void testFailNoRPCtx()
- throws ComponentInitializationException, URISyntaxException, ParseException, JOSEException {
- profileRequestCtx.removeSubcontext(RelyingPartyContext.class);
- final Event event = action.execute(requestCtx);
- ActionTestingSupport.assertEvent(event, IdPEventIds.INVALID_RELYING_PARTY_CTX);
- }
-
-}
\ 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