diff --git a/pom.xml b/pom.xml index 9d8e397..4724939 100644 --- a/pom.xml +++ b/pom.xml @@ -26,23 +26,23 @@ THE SOFTWARE. net.shibboleth parent - 11.3.3 + 17.0.2 fi.mpass idp-authn-impl-jwt - 1.1 + 1.2 jar UTF-8 - 11 - 11 + 17 + 17 9.23 - 4.2.1 + 5.0.0 mpassid-checkstyle.xml fi.mpass.authn.jwt.impl org.opensaml - 4.2.0 + 5.0.0 @@ -94,8 +94,8 @@ THE SOFTWARE. - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api provided @@ -104,10 +104,9 @@ THE SOFTWARE. ${opensaml.groupId} - opensaml-core + opensaml-core-impl ${opensaml.version} test - test-jar ${opensaml.groupId} @@ -116,12 +115,24 @@ THE SOFTWARE. test test-jar + + ${opensaml.groupId} + opensaml-testing + ${opensaml.version} + test + ${opensaml.groupId} opensaml-security-impl ${opensaml.version} test + + net.shibboleth.idp + idp-testing + ${shib.idp.version} + test + net.shibboleth.idp idp-profile-api diff --git a/src/main/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthentication.java b/src/main/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthentication.java index fdd12ff..3f346a4 100644 --- a/src/main/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthentication.java +++ b/src/main/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthentication.java @@ -26,8 +26,7 @@ import javax.annotation.Nonnull; import javax.security.auth.Subject; -//import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.opensaml.profile.action.ActionSupport; import org.opensaml.profile.action.EventIds; @@ -44,11 +43,10 @@ import net.shibboleth.idp.authn.AuthnEventIds; import net.shibboleth.idp.authn.context.AuthenticationContext; import net.shibboleth.idp.authn.principal.UsernamePrincipal; -import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty; -import net.shibboleth.utilities.java.support.component.ComponentSupport; -import net.shibboleth.utilities.java.support.logic.Constraint; -import net.shibboleth.utilities.java.support.logic.ConstraintViolationException; -import net.shibboleth.utilities.java.support.primitive.StringSupport; +import net.shibboleth.shared.annotation.constraint.NotEmpty; +import net.shibboleth.shared.logic.Constraint; +import net.shibboleth.shared.logic.ConstraintViolationException; +import net.shibboleth.shared.primitive.StringSupport; /** * An action that checks for incoming JWT token and produces an @@ -127,7 +125,7 @@ public String getUsernameId() { * @param username The attribute name containing the user identifier. */ public void setUsernameId(String username) { - ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); + ifInitializedThrowUnmodifiabledComponentException(); Constraint.isNotEmpty(username, "Username cannot be null"); usernameId = username; } diff --git a/src/main/resources/flows/authn/jwt/jwt-beans.xml b/src/main/resources/flows/authn/jwt/jwt-beans.xml index 4cf5f89..739c7a8 100644 --- a/src/main/resources/flows/authn/jwt/jwt-beans.xml +++ b/src/main/resources/flows/authn/jwt/jwt-beans.xml @@ -14,7 +14,7 @@ diff --git a/src/test/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthenticationTest.java b/src/test/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthenticationTest.java index b429112..fcbcd7c 100644 --- a/src/test/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthenticationTest.java +++ b/src/test/java/fi/mpass/shibboleth/authn/impl/ValidateJwtTokenAuthenticationTest.java @@ -25,7 +25,9 @@ import java.security.Principal; import java.util.Set; -import javax.servlet.http.HttpServletRequest; +import javax.annotation.Nonnull; + +import jakarta.servlet.http.HttpServletRequest; import org.opensaml.profile.action.EventIds; import org.springframework.mock.web.MockHttpServletRequest; @@ -46,8 +48,9 @@ import net.shibboleth.idp.authn.context.AuthenticationContext; import net.shibboleth.idp.authn.impl.testing.BaseAuthenticationContextTest; import net.shibboleth.idp.profile.testing.ActionTestingSupport; -import net.shibboleth.utilities.java.support.component.ComponentInitializationException; -import net.shibboleth.utilities.java.support.logic.ConstraintViolationException; +import net.shibboleth.shared.component.ComponentInitializationException; +import net.shibboleth.shared.logic.ConstraintViolationException; +import net.shibboleth.shared.primitive.NonnullSupplier; /** * Unit tests for {@link ValidateJwtTokenAuthentication}. @@ -80,8 +83,18 @@ public class ValidateJwtTokenAuthenticationTest extends BaseAuthenticationContex action = new ValidateJwtTokenAuthentication(sharedSecret, jwtParameterName); action.setUsernameId(uidConfig); Assert.assertEquals(uidConfig, action.getUsernameId()); - action.setHttpServletRequest((HttpServletRequest) src.getExternalContext().getNativeRequest()); + + action.setHttpServletRequestSupplier(new NonnullSupplier() { + + @Override + public MockHttpServletRequest get() { + return (MockHttpServletRequest) src.getExternalContext().getNativeRequest(); + } + + }); + } + /** * Runs action without attempted flow. @@ -114,7 +127,15 @@ public void testInvalidSecret() throws Exception { * Runs action without {@link HttpServletRequest}. */ @Test public void testMissingServlet() throws Exception { - action.setHttpServletRequest(null); + action.setHttpServletRequestSupplier(new NonnullSupplier() { + + @Override + @Nonnull + public HttpServletRequest get() { + return null; + } + + }); action.initialize(); prc.getSubcontext(AuthenticationContext.class, false).setAttemptedFlow(authenticationFlows.get(0)); final Event event = action.execute(src);