[java-idp-plugin-duo] branch main updated: Add named constructor parameter to issuer lookup strategy
Phil Smart
philip.smart at jisc.ac.uk
Wed Mar 10 15:38:45 UTC 2021
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=59405a27700b3263694629cb65de81c26beab692
The following commit(s) were added to refs/heads/main by this push:
new 59405a2 Add named constructor parameter to issuer lookup strategy
59405a2 is described below
commit 59405a27700b3263694629cb65de81c26beab692
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Mar 10 15:38:43 2021 +0000
Add named constructor parameter to issuer lookup strategy
- Add named constructor injection to the beans
---
.../duo/impl/DuoIssuerClaimLookupStrategy.java | 37 ++++++++--------------
.../flows/authn/DuoOIDC/duo-oidc-authn-beans.xml | 4 +--
.../duo/impl/DuoIssuerClaimLookupStrategyTest.java | 5 ++-
3 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategy.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategy.java
index 1034fa8..67a86bc 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategy.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategy.java
@@ -31,6 +31,7 @@ import com.nimbusds.jwt.JWTClaimsSet;
import net.shibboleth.idp.authn.context.AuthenticationContext;
import net.shibboleth.idp.plugin.authn.duo.DuoOIDCIntegration;
import net.shibboleth.idp.plugin.authn.duo.context.DuoOIDCAuthenticationContext;
+import net.shibboleth.utilities.java.support.annotation.ParameterName;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -38,11 +39,10 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
* Find the issuer from the {@link DuoOIDCIntegration}. An issuer contains the scheme, host, and optionally, port
* and path components that identify the id_token issuer. Returns null if not found.
*
- * <p>Is effectively immutable if {@link #setIssuerPath(String)} is only be called during initialisation e.g.
- * by spring, otherwise it can mutate, but in thread-safe way.</p>
+ * <p>Is effectively immutable once published. Can be safely shared amongst threads.</p>
*/
@ThreadSafe
-public class DuoIssuerClaimLookupStrategy implements BiFunction<ProfileRequestContext, JWTClaimsSet, String> {
+public final class DuoIssuerClaimLookupStrategy implements BiFunction<ProfileRequestContext, JWTClaimsSet, String> {
/** HTTPS scheme protocol.*/
@Nonnull @NotEmpty public static final String HTTPS = "https://";
@@ -51,29 +51,20 @@ public class DuoIssuerClaimLookupStrategy implements BiFunction<ProfileRequestCo
@Nonnull @NotEmpty public static final String DEFAULT_ISSUER_PATH = "/oauth/v1/token";
/** The URL path component of the issuer.*/
- @Nonnull @NotEmpty @GuardedBy("this") private String issuerPath;
-
- /** Constructor.*/
- public DuoIssuerClaimLookupStrategy() {
- issuerPath = DEFAULT_ISSUER_PATH;
- }
-
- /**
- * Sets the issuer URL path component.
- *
- * @param path the issuer path
- */
- public synchronized void setIssuerPath(@Nonnull @NotEmpty final String path) {
- issuerPath = Constraint.isNotEmpty(path, "Issuer URL path cannot be null or empty");
- }
+ @Nonnull @NotEmpty @GuardedBy("this") private final String issuerPath;
/**
- * Internal, synchronized, method for returning the issuerPath.
*
- * @return the issuer path.
+ * Constructor.
+ *
+ * @param path the issuer path.
*/
- @Nonnull @NotEmpty private synchronized String getIssuerPath() {
- return issuerPath;
+ public DuoIssuerClaimLookupStrategy(@Nullable @ParameterName(name = "issuerPath") final String path) {
+ if (path == null) {
+ issuerPath = DEFAULT_ISSUER_PATH;
+ } else {
+ issuerPath = Constraint.isNotEmpty(path, "Issuer URL path cannot be null or empty");
+ }
}
/** {@inheritDoc} */
@@ -93,7 +84,7 @@ public class DuoIssuerClaimLookupStrategy implements BiFunction<ProfileRequestCo
if (duoIntegration == null) {
return null;
}
- return HTTPS+duoIntegration.getAPIHost()+getIssuerPath();
+ return HTTPS+duoIntegration.getAPIHost()+issuerPath;
}
}
diff --git a/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml b/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
index 4e7ec04..bc5688a 100644
--- a/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
+++ b/idp-duo-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/DuoOIDC/duo-oidc-authn-beans.xml
@@ -116,7 +116,7 @@
<bean id="shibboleth.authn.DuoOIDC.RedirectURICreationStrategy"
class="net.shibboleth.idp.plugin.authn.duo.impl.DefaultRedirectURICreationStrategy"
- c:_0="#{getObject('shibboleth.authn.DuoOIDC.externalServletPath')}#{T(net.shibboleth.idp.plugin.authn.duo.DuoOIDCAuthAPI).CALLBACK_PATH_SEGMENT}"
+ c:callbackPath="#{getObject('shibboleth.authn.DuoOIDC.externalServletPath')}#{T(net.shibboleth.idp.plugin.authn.duo.DuoOIDCAuthAPI).CALLBACK_PATH_SEGMENT}"
/>
<bean id="HealthCheckDuoOIDCAuthAPI" scope="prototype"
@@ -199,7 +199,7 @@
<bean id="shibboleth.authn.DuoOIDC.jwt.DefaultIssuerLookupStrategy"
class="net.shibboleth.idp.plugin.authn.duo.impl.DuoIssuerClaimLookupStrategy"
- p:issuerPath="%{idp.duo.oidc.jwt.verifier.issuerPath:/oauth/v1/token}"/>
+ c:issuerPath="%{idp.duo.oidc.jwt.verifier.issuerPath:/oauth/v1/token}"/>
<bean id="shibboleth.authn.DuoOIDC.jwt.DefaultNonceLookupStrategy"
class="net.shibboleth.idp.plugin.authn.duo.impl.DuoNonceClaimLookupStrategy"/>
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategyTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategyTest.java
index fa7d7ed..6d1166e 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategyTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/impl/DuoIssuerClaimLookupStrategyTest.java
@@ -44,15 +44,14 @@ public class DuoIssuerClaimLookupStrategyTest extends AbstractDuoActionTest{
*/
@BeforeMethod public void beforeMethod() throws ComponentInitializationException {
super.setup();
- strategy = new DuoIssuerClaimLookupStrategy();
+ strategy = new DuoIssuerClaimLookupStrategy("/oauth/v2/token");
}
@Test
- public void applySuccess() {
+ public void applySuccess() throws ComponentInitializationException {
addDuoContext();
addDuoIntegrationToContext();
//set a different path for testing.
- strategy.setIssuerPath("/oauth/v2/token");
final String issuer = strategy.apply(prc,new JWTClaimsSet.Builder().build());
assertEquals(issuer, "https://"+dc.getIntegration().getAPIHost()+"/oauth/v2/token");
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list