[java-idp-oidc] branch main updated: Move some constructor args back into properties.
Scott Cantor
cantor.2 at osu.edu
Thu Jan 20 20:50:57 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor 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=e55453f13c20ac5bdf25e235ece59bdc1ac3238d
The following commit(s) were added to refs/heads/main by this push:
new e55453f1 Move some constructor args back into properties.
e55453f1 is described below
commit e55453f13c20ac5bdf25e235ece59bdc1ac3238d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 20 15:50:54 2022 -0500
Move some constructor args back into properties.
---
.../FormOutboundIntrospectionResponseMessage.java | 17 +++---
.../oidc/op/oauth2/profile/impl/RevokeToken.java | 21 +++----
.../impl/SetAccessTokenToResponseContext.java | 30 ++++++++--
.../SetAuthorizationCodeToResponseContext.java | 34 ++++++++---
.../oauth2/introspection/introspection-beans.xml | 2 +-
.../flows/oauth2/revocation/revocation-beans.xml | 2 +-
.../idp/flows/oidc/authorize/authorize-beans.xml | 4 +-
.../idp/flows/oidc/token/token-beans.xml | 2 +-
.../op/oauth2/profile/impl/RevokeTokenTest.java | 9 ++-
.../impl/SetAccessTokenToResponseContextTest.java | 6 +-
.../SetAuthorizationCodeToResponseContextTest.java | 65 +++++++++++++++++++---
11 files changed, 144 insertions(+), 48 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/FormOutboundIntrospectionResponseMessage.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/FormOutboundIntrospectionResponseMessage.java
index f62e9251..bfcbf9d6 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/FormOutboundIntrospectionResponseMessage.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/FormOutboundIntrospectionResponseMessage.java
@@ -44,7 +44,6 @@ import net.shibboleth.idp.plugin.oidc.op.storage.RevocationCacheContexts;
import net.shibboleth.idp.plugin.oidc.op.token.support.AccessTokenClaimsSet;
import net.shibboleth.idp.plugin.oidc.op.token.support.RefreshTokenClaimsSet;
import net.shibboleth.idp.plugin.oidc.op.token.support.TokenClaimsSet;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -63,20 +62,21 @@ public class FormOutboundIntrospectionResponseMessage extends AbstractOIDCReques
@Nonnull private Logger log = LoggerFactory.getLogger(FormOutboundIntrospectionResponseMessage.class);
/** Data sealer for unwrapping token. */
- @Nonnull private final DataSealer dataSealer;
+ @NonnullAfterInit private DataSealer dataSealer;
/** Message revocation cache instance to use. */
@NonnullAfterInit private RevocationCache revocationCache;
/**
- * Constructor.
+ * Set the data sealer instance to use.
*
- * @param sealer sealer to decrypt/hmac access token.
+ * @param sealer data sealer to use
*/
- public FormOutboundIntrospectionResponseMessage(@Nonnull @ParameterName(name = "sealer") final DataSealer sealer) {
+ public void setDataSealer(@Nonnull final DataSealer sealer) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
}
-
+
/**
* Set the revocation cache instance to use.
*
@@ -91,7 +91,10 @@ public class FormOutboundIntrospectionResponseMessage extends AbstractOIDCReques
@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- Constraint.isNotNull(revocationCache, "RevocationCache cannot be null");
+
+ if (revocationCache == null || dataSealer == null) {
+ throw new ComponentInitializationException("RevocationCache and DataSealer cannot be null");
+ }
}
/** {@inheritDoc} */
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeToken.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeToken.java
index 842b2f36..b9287039 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeToken.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeToken.java
@@ -31,7 +31,6 @@ import net.shibboleth.idp.plugin.oidc.op.storage.RevocationCacheContexts;
import net.shibboleth.idp.plugin.oidc.op.token.support.AccessTokenClaimsSet;
import net.shibboleth.idp.plugin.oidc.op.token.support.RefreshTokenClaimsSet;
import net.shibboleth.idp.plugin.oidc.op.token.support.TokenClaimsSet;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -53,22 +52,21 @@ public class RevokeToken extends AbstractOIDCRequestAction<TokenRevocationReques
private Logger log = LoggerFactory.getLogger(RevokeToken.class);
/** Data sealer for unwrapping token. */
- @Nonnull
- private final DataSealer dataSealer;
+ @NonnullAfterInit private DataSealer dataSealer;
/** Message revocation cache instance to use. */
- @NonnullAfterInit
- private RevocationCache revocationCache;
+ @NonnullAfterInit private RevocationCache revocationCache;
/**
- * Constructor.
+ * Set the data sealer instance to use.
*
- * @param sealer sealer to decrypt/hmac access token.
+ * @param sealer data sealer to use
*/
- public RevokeToken(@Nonnull @ParameterName(name = "sealer") final DataSealer sealer) {
+ public void setDataSealer(@Nonnull final DataSealer sealer) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
}
-
+
/**
* Set the revocation cache instance to use.
*
@@ -83,7 +81,10 @@ public class RevokeToken extends AbstractOIDCRequestAction<TokenRevocationReques
@Override
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- Constraint.isNotNull(revocationCache, "RevocationCache cannot be null");
+
+ if (revocationCache == null || dataSealer == null) {
+ throw new ComponentInitializationException("RevocationCache and DataSealer cannot be null");
+ }
}
/** {@inheritDoc} */
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContext.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContext.java
index c4d143fd..befe031a 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContext.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContext.java
@@ -52,7 +52,8 @@ import net.shibboleth.oidc.profile.config.navigate.AccessTokenLifetimeLookupFunc
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.logic.FunctionSupport;
@@ -72,7 +73,7 @@ public class SetAccessTokenToResponseContext extends AbstractOIDCResponseAction
@Nonnull private Logger log = LoggerFactory.getLogger(SetAccessTokenToResponseContext.class);
/** Data sealer for handling access token. */
- @Nonnull private final DataSealer dataSealer;
+ @NonnullAfterInit private DataSealer dataSealer;
/** Authorize Code / Refresh Token the access token is based on. */
@Nullable private TokenClaimsSet tokenClaimsSet;
@@ -113,10 +114,8 @@ public class SetAccessTokenToResponseContext extends AbstractOIDCResponseAction
/**
* Constructor.
- *
- * @param sealer sealer to encrypt/hmac access token.
*/
- public SetAccessTokenToResponseContext(@Nonnull @ParameterName(name = "sealer") final DataSealer sealer) {
+ public SetAccessTokenToResponseContext() {
tokenClaimsContextLookupStrategy =
new ChildContextLookup<>(OIDCAuthenticationResponseTokenClaimsContext.class).compose(
new OIDCAuthenticationResponseContextLookupFunction());
@@ -125,11 +124,20 @@ public class SetAccessTokenToResponseContext extends AbstractOIDCResponseAction
new OIDCAuthenticationResponseContextLookupFunction());
accessTokenLifetimeLookupStrategy = new AccessTokenLifetimeLookupFunction();
consentEnabledPredicate = new AttributeConsentFlowEnabledPredicate();
- dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
issuerLookupStrategy = new ResponderIdLookupFunction();
idGeneratorLookupStrategy = FunctionSupport.constant(new SecureRandomIdentifierGenerationStrategy());
}
+ /**
+ * Set the data sealer instance to use.
+ *
+ * @param sealer data sealer to use
+ */
+ public void setDataSealer(@Nonnull final DataSealer sealer) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
+ }
+
/**
* Set the strategy used to locate the {@link OIDCAuthenticationResponseTokenClaimsContext} associated with a given
* {@link ProfileRequestContext}.
@@ -204,6 +212,16 @@ public class SetAccessTokenToResponseContext extends AbstractOIDCResponseAction
Constraint.isNotNull(predicate, "predicate used to check if consent is enabled cannot be null");
}
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (dataSealer == null) {
+ throw new ComponentInitializationException("DataSealer cannot be null");
+ }
+ }
+
// Checkstyle: CyclomaticComplexity OFF
/** {@inheritDoc} */
@Override
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContext.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContext.java
index bf477e4a..a1033fac 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContext.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContext.java
@@ -48,7 +48,8 @@ import net.shibboleth.oidc.profile.config.navigate.AuthzCodeLifetimeLookupFuncti
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.logic.FunctionSupport;
@@ -71,7 +72,7 @@ public class SetAuthorizationCodeToResponseContext extends AbstractOIDCAuthentic
@Nonnull private Function<ProfileRequestContext, String> issuerLookupStrategy;
/** Data sealer for handling authorization code. */
- @Nonnull private final DataSealer dataSealer;
+ @NonnullAfterInit private DataSealer dataSealer;
/** The generator to use. */
@Nullable private IdentifierGenerationStrategy idGenerator;
@@ -112,10 +113,8 @@ public class SetAuthorizationCodeToResponseContext extends AbstractOIDCAuthentic
/**
* Constructor.
- *
- * @param sealer sealer to encrypt/hmac authz code.
*/
- public SetAuthorizationCodeToResponseContext(@Nonnull @ParameterName(name = "sealer") final DataSealer sealer) {
+ public SetAuthorizationCodeToResponseContext() {
codeChallengeLookupStrategy = new DefaultRequestCodeChallengeLookupFunction();
codeChallengeMethodLookupStrategy = new DefaultRequestCodeChallengeMethodLookupFunction();
tokenClaimsContextLookupStrategy =
@@ -127,10 +126,19 @@ public class SetAuthorizationCodeToResponseContext extends AbstractOIDCAuthentic
authzCodeLifetimeLookupStrategy = new AuthzCodeLifetimeLookupFunction();
issuerLookupStrategy = new ResponderIdLookupFunction();
consentEnabledPredicate = new AttributeConsentFlowEnabledPredicate();
- dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
idGeneratorLookupStrategy = FunctionSupport.constant(new SecureRandomIdentifierGenerationStrategy());
}
+ /**
+ * Set the data sealer instance to use.
+ *
+ * @param sealer data sealer to use
+ */
+ public void setDataSealer(@Nonnull final DataSealer sealer) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ dataSealer = Constraint.isNotNull(sealer, "DataSealer cannot be null");
+ }
+
/**
* Set the strategy used to locate the Code Challenge of the request.
*
@@ -225,7 +233,17 @@ public class SetAuthorizationCodeToResponseContext extends AbstractOIDCAuthentic
consentEnabledPredicate =
Constraint.isNotNull(predicate, "predicate used to check if consent is enabled cannot be null");
}
-
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ super.doInitialize();
+
+ if (dataSealer == null) {
+ throw new ComponentInitializationException("DataSealer cannot be null");
+ }
+ }
+
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
@@ -300,7 +318,7 @@ public class SetAuthorizationCodeToResponseContext extends AbstractOIDCAuthentic
.setACR(getOidcResponseContext().getAcr())
.setNonce(new DefaultRequestNonceLookupFunction().apply(profileRequestContext))
.setCodeChallenge(codeChallenge)
- .setClaims(getOidcResponseContext().getRequestedClaims())
+ .setClaimsRequest(getOidcResponseContext().getRequestedClaims())
.setDlClaims(claims)
.setDlClaimsID(claimsID)
.setDlClaimsUI(claimsUI)
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/introspection/introspection-beans.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/introspection/introspection-beans.xml
index e8fe1895..2d15f09e 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/introspection/introspection-beans.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/introspection/introspection-beans.xml
@@ -27,7 +27,7 @@
<bean id="FormOutboundMessage"
class="net.shibboleth.idp.plugin.oidc.op.oauth2.profile.impl.FormOutboundIntrospectionResponseMessage" scope="prototype"
- c:sealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}"
+ p:dataSealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}"
p:revocationCache-ref="shibboleth.RevocationCache" />
<bean id="BuildErrorResponseFromEvent"
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/revocation/revocation-beans.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/revocation/revocation-beans.xml
index 087c1770..18db2847 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/revocation/revocation-beans.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oauth2/revocation/revocation-beans.xml
@@ -26,7 +26,7 @@
scope="prototype" />
<bean id="RevokeToken" class="net.shibboleth.idp.plugin.oidc.op.oauth2.profile.impl.RevokeToken" scope="prototype"
- c:sealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}"
+ p:dataSealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}"
p:revocationCache-ref="shibboleth.RevocationCache" />
<bean id="FormOutboundMessage"
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/authorize/authorize-beans.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/authorize/authorize-beans.xml
index 0785ebe9..ce18b485 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/authorize/authorize-beans.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/authorize/authorize-beans.xml
@@ -228,7 +228,7 @@
<bean id="SetAuthorizationCodeToResponseContext"
class="net.shibboleth.idp.plugin.oidc.op.profile.impl.SetAuthorizationCodeToResponseContext" scope="prototype"
- c:sealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}">
+ p:dataSealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}">
<property name="identifierGeneratorLookupStrategy">
<bean class="net.shibboleth.idp.profile.config.navigate.IdentifierGenerationStrategyLookupFunction"
p:defaultIdentifierGenerationStrategy-ref="shibboleth.DefaultIdentifierGenerationStrategy" />
@@ -240,7 +240,7 @@
<bean id="SetAccessTokenToResponseContext"
class="net.shibboleth.idp.plugin.oidc.op.profile.impl.SetAccessTokenToResponseContext" scope="prototype"
- c:sealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}">
+ p:dataSealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}">
<property name="activationCondition">
<ref bean="AccessTokenRequested" />
</property>
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/token/token-beans.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/token/token-beans.xml
index ea18db2e..02955e6c 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/token/token-beans.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidc/token/token-beans.xml
@@ -196,7 +196,7 @@
<bean id="SetOIDCAccessTokenToResponseContext"
class="net.shibboleth.idp.plugin.oidc.op.profile.impl.SetAccessTokenToResponseContext" scope="prototype"
- c:sealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}" />
+ p:dataSealer-ref="#{'%{idp.oidc.tokenSealer:shibboleth.oidc.TokenSealer}'.trim()}" />
<bean id="SetRefreshTokenToResponseContext"
class="net.shibboleth.idp.plugin.oidc.op.profile.impl.SetRefreshTokenToResponseContext" scope="prototype"
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeTokenTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeTokenTest.java
index db4291c4..dfb24911 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeTokenTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/RevokeTokenTest.java
@@ -45,6 +45,8 @@ import net.shibboleth.utilities.java.support.component.ComponentInitializationEx
import net.shibboleth.utilities.java.support.security.DataSealerException;
import net.shibboleth.utilities.java.support.security.impl.SecureRandomIdentifierGenerationStrategy;
+// Checkstyle: ThrowsCount OFF
+
/**
* Tests for {@link RevokeToken}.
*/
@@ -103,10 +105,11 @@ public class RevokeTokenTest extends BaseTokenClaimsSetTest {
.setRedirectURI(redirectURI)
.setScope(scope).
build();
- atClaimsSet = new AccessTokenClaimsSet(acClaimsSet, scope, dlClaims, dlClaimsUI, iat, exp);
- rfClaimsSet = new RefreshTokenClaimsSet(acClaimsSet, iat, exp);
+ atClaimsSet = new AccessTokenClaimsSet.Builder(acClaimsSet, scope, dlClaims, dlClaimsUI, iat, exp).build();
+ rfClaimsSet = new RefreshTokenClaimsSet.Builder(acClaimsSet, iat, exp).build();
// init action
- action = new RevokeToken(sealer);
+ action = new RevokeToken();
+ action.setDataSealer(sealer);
action.setRevocationCache(revocationCache);
action.initialize();
revokeAccessToken = new TokenRevocationRequest(new URI("https://example.com"), new ClientID(),
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContextTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContextTest.java
index ff0b3726..e6fa6333 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContextTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAccessTokenToResponseContextTest.java
@@ -47,9 +47,12 @@ import com.nimbusds.oauth2.sdk.id.ClientID;
import com.nimbusds.oauth2.sdk.token.RefreshToken;
import com.nimbusds.openid.connect.sdk.claims.ACR;
+// Checkstyle: ThrowsCount OFF
+
/** {@link SetAccessTokenToResponseContext} unit test. */
public class SetAccessTokenToResponseContextTest extends BaseOIDCResponseActionTest {
+ /** Action to test. */
private SetAccessTokenToResponseContext action;
private void init() throws ComponentInitializationException, NoSuchAlgorithmException, URISyntaxException {
@@ -72,7 +75,8 @@ public class SetAccessTokenToResponseContextTest extends BaseOIDCResponseActionT
respCtx.setAuthorizationGrantClaimsSet(claims);
respCtx.setAcr("0");
respCtx.setRedirectURI(new URI("http://example.com"));
- action = new SetAccessTokenToResponseContext(getDataSealer());
+ action = new SetAccessTokenToResponseContext();
+ action.setDataSealer(getDataSealer());
action.initialize();
final SubjectContext subjectCtx = profileRequestCtx.getSubcontext(SubjectContext.class, true);
subjectCtx.setPrincipalName("userPrin");
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContextTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContextTest.java
index 64477c52..7dfa45b6 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContextTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/SetAuthorizationCodeToResponseContextTest.java
@@ -39,9 +39,12 @@ import org.testng.annotations.Test;
import com.nimbusds.oauth2.sdk.Scope;
import com.nimbusds.openid.connect.sdk.AuthenticationRequest;
+// Checkstyle: ThrowsCount OFF
+
/** {@link SetAuthorizationCodeToResponseContext} unit test. */
public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseActionTest {
+ /** Action to test. */
private SetAuthorizationCodeToResponseContext action;
private void init() throws ComponentInitializationException, NoSuchAlgorithmException, URISyntaxException {
@@ -50,7 +53,8 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
respCtx.setAuthTime(Instant.now());
respCtx.setAcr("0");
respCtx.setRedirectURI(new URI("http://example.com"));
- action = new SetAuthorizationCodeToResponseContext(getDataSealer());
+ action = new SetAuthorizationCodeToResponseContext();
+ action.setDataSealer(getDataSealer());
action.initialize();
final SubjectContext subjectCtx = profileRequestCtx.getSubcontext(SubjectContext.class, true);
subjectCtx.setPrincipalName("userPrin");
@@ -58,6 +62,12 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* Basic success case.
+ *
+ * @throws ComponentInitializationException
+ * @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
+ * @throws ParseException
+ * @throws DataSealerException
*/
@Test
public void testSuccess() throws ComponentInitializationException, NoSuchAlgorithmException, URISyntaxException,
@@ -66,13 +76,19 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
final Event event = action.execute(requestCtx);
ActionTestingSupport.assertProceedEvent(event);
Assert.assertNotNull(respCtx.getAuthorizationCode());
- AuthorizeCodeClaimsSet ac =
+ final AuthorizeCodeClaimsSet ac =
AuthorizeCodeClaimsSet.parse(respCtx.getAuthorizationCode().getValue(), getDataSealer());
Assert.assertNotNull(ac);
}
/**
* Basic success case plus consent.
+ *
+ * @throws ComponentInitializationException
+ * @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
+ * @throws ParseException
+ * @throws DataSealerException
*/
@Test
public void testSuccessConsent() throws ComponentInitializationException, NoSuchAlgorithmException,
@@ -91,14 +107,21 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
}
/**
- * Basic success case plus delivery claims
+ * Basic success case plus delivery claims.
+ *
+ * @throws ComponentInitializationException
+ * @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
+ * @throws ParseException
+ * @throws DataSealerException
*/
@Test
public void testSuccessWithTokenDelivery() throws ComponentInitializationException, NoSuchAlgorithmException,
URISyntaxException, ParseException, DataSealerException {
init();
- final OIDCAuthenticationResponseTokenClaimsContext tokenCtx = (OIDCAuthenticationResponseTokenClaimsContext) respCtx
- .addSubcontext(new OIDCAuthenticationResponseTokenClaimsContext());
+ final OIDCAuthenticationResponseTokenClaimsContext tokenCtx =
+ (OIDCAuthenticationResponseTokenClaimsContext) respCtx.addSubcontext(
+ new OIDCAuthenticationResponseTokenClaimsContext());
tokenCtx.getClaims().setClaim("1", "1");
tokenCtx.getIdtokenClaims().setClaim("2", "2");
tokenCtx.getUserinfoClaims().setClaim("3", "3");
@@ -115,6 +138,13 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* Test PKCE with default challenge method.
+ *
+ * @throws ComponentInitializationException
+ * @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
+ * @throws ParseException
+ * @throws DataSealerException
+ * @throws com.nimbusds.oauth2.sdk.ParseException
*/
@Test
public void testSuccessPKCE() throws ComponentInitializationException, NoSuchAlgorithmException, URISyntaxException,
@@ -126,7 +156,7 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
final Event event = action.execute(requestCtx);
ActionTestingSupport.assertProceedEvent(event);
Assert.assertNotNull(respCtx.getAuthorizationCode());
- AuthorizeCodeClaimsSet ac =
+ final AuthorizeCodeClaimsSet ac =
AuthorizeCodeClaimsSet.parse(respCtx.getAuthorizationCode().getValue(), getDataSealer());
Assert.assertNotNull(ac);
Assert.assertEquals(ac.getCodeChallenge(), "S256123456");
@@ -134,6 +164,13 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* Test PKCE with default challenge method.
+ *
+ * @throws ComponentInitializationException
+ * @throws NoSuchAlgorithmException
+ * @throws URISyntaxException
+ * @throws ParseException
+ * @throws DataSealerException
+ * @throws com.nimbusds.oauth2.sdk.ParseException
*/
@Test
public void testSuccessPKCEDefault() throws ComponentInitializationException, NoSuchAlgorithmException,
@@ -145,7 +182,7 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
final Event event = action.execute(requestCtx);
ActionTestingSupport.assertProceedEvent(event);
Assert.assertNotNull(respCtx.getAuthorizationCode());
- AuthorizeCodeClaimsSet ac =
+ final AuthorizeCodeClaimsSet ac =
AuthorizeCodeClaimsSet.parse(respCtx.getAuthorizationCode().getValue(), getDataSealer());
Assert.assertNotNull(ac);
Assert.assertEquals(ac.getCodeChallenge(), "plain123456");
@@ -153,6 +190,10 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* fails as there is no rp ctx.
+ *
+ * @throws NoSuchAlgorithmException
+ * @throws ComponentInitializationException
+ * @throws URISyntaxException
*/
@Test
public void testFailNoRPCtx()
@@ -165,6 +206,10 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* fails as there is no subject ctx.
+ *
+ * @throws NoSuchAlgorithmException
+ * @throws ComponentInitializationException
+ * @throws URISyntaxException
*/
@Test
public void testFailNoSubjectCtx()
@@ -177,12 +222,16 @@ public class SetAuthorizationCodeToResponseContextTest extends BaseOIDCResponseA
/**
* fails as there is no profile conf.
+ *
+ * @throws NoSuchAlgorithmException
+ * @throws ComponentInitializationException
+ * @throws URISyntaxException
*/
@Test
public void testFailNoProfileConf()
throws NoSuchAlgorithmException, ComponentInitializationException, URISyntaxException {
init();
- RelyingPartyContext rpCtx = profileRequestCtx.getSubcontext(RelyingPartyContext.class, false);
+ final RelyingPartyContext rpCtx = profileRequestCtx.getSubcontext(RelyingPartyContext.class, false);
rpCtx.setProfileConfig(null);
final Event event = action.execute(requestCtx);
ActionTestingSupport.assertEvent(event, IdPEventIds.INVALID_PROFILE_CONFIG);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list