Search in sources :

Example 1 with JwtUtils

use of org.hisp.dhis.webapi.security.utils.JwtUtils in project dhis2-core by dhis2.

the class JwtBearerTokenTest method setUpClass.

@BeforeAll
static void setUpClass() throws JOSEException {
    DhisWebApiWebSecurityConfig.setApiContextPath("");
    JWKSource<SecurityContext> jwkSource = (jwkSelector, securityContext) -> jwkSelector.select(new JWKSet(ImmutableList.of(RSA_KEY)));
    jwsEncoder = new JwtUtils(jwkSource);
    jwtDecoder = NimbusJwtDecoder.withPublicKey(RSA_KEY.toRSAPublicKey()).build();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) SecurityContext(com.nimbusds.jose.proc.SecurityContext) ConfigurationKey(org.hisp.dhis.external.conf.ConfigurationKey) NimbusJwtDecoder(org.springframework.security.oauth2.jwt.NimbusJwtDecoder) Contracts.assertNotNull(org.hibernate.validator.internal.util.Contracts.assertNotNull) JOSEException(com.nimbusds.jose.JOSEException) Autowired(org.springframework.beans.factory.annotation.Autowired) DhisOidcProviderRepository(org.hisp.dhis.security.oidc.DhisOidcProviderRepository) JWKSet(com.nimbusds.jose.jwk.JWKSet) JwtClaimsSet(org.hisp.dhis.webapi.security.utils.JwtClaimsSet) TestJwks(org.hisp.dhis.webapi.security.utils.TestJwks) TestJwtClaimsSets(org.hisp.dhis.webapi.security.utils.TestJwtClaimsSets) Dhis2JwtAuthenticationManagerResolver(org.hisp.dhis.security.jwt.Dhis2JwtAuthenticationManagerResolver) ImmutableList(com.google.common.collect.ImmutableList) BeforeAll(org.junit.jupiter.api.BeforeAll) JsonError(org.hisp.dhis.webapi.json.domain.JsonError) DhisWebApiWebSecurityConfig(org.hisp.dhis.webapi.security.config.DhisWebApiWebSecurityConfig) JoseHeaderNames(org.hisp.dhis.webapi.security.utils.JoseHeaderNames) User(org.hisp.dhis.user.User) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) JwtTokenHeader(org.hisp.dhis.webapi.WebClient.JwtTokenHeader) Jwt(org.springframework.security.oauth2.jwt.Jwt) JsonUser(org.hisp.dhis.webapi.json.domain.JsonUser) JWKSource(com.nimbusds.jose.jwk.source.JWKSource) Properties(java.util.Properties) TestJoseHeaders(org.hisp.dhis.webapi.security.utils.TestJoseHeaders) JoseHeader(org.hisp.dhis.webapi.security.utils.JoseHeader) DhisControllerWithJwtTokenAuthTest(org.hisp.dhis.webapi.DhisControllerWithJwtTokenAuthTest) GenericOidcProviderConfigParser(org.hisp.dhis.security.oidc.GenericOidcProviderConfigParser) Test(org.junit.jupiter.api.Test) HttpStatus(org.springframework.http.HttpStatus) RSAKey(com.nimbusds.jose.jwk.RSAKey) JwtUtils(org.hisp.dhis.webapi.security.utils.JwtUtils) DhisOidcClientRegistration(org.hisp.dhis.security.oidc.DhisOidcClientRegistration) GoogleProvider(org.hisp.dhis.security.oidc.provider.GoogleProvider) JWKSet(com.nimbusds.jose.jwk.JWKSet) SecurityContext(com.nimbusds.jose.proc.SecurityContext) JwtUtils(org.hisp.dhis.webapi.security.utils.JwtUtils) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 JOSEException (com.nimbusds.jose.JOSEException)1 JWKSet (com.nimbusds.jose.jwk.JWKSet)1 RSAKey (com.nimbusds.jose.jwk.RSAKey)1 JWKSource (com.nimbusds.jose.jwk.source.JWKSource)1 SecurityContext (com.nimbusds.jose.proc.SecurityContext)1 Properties (java.util.Properties)1 Contracts.assertNotNull (org.hibernate.validator.internal.util.Contracts.assertNotNull)1 ConfigurationKey (org.hisp.dhis.external.conf.ConfigurationKey)1 Dhis2JwtAuthenticationManagerResolver (org.hisp.dhis.security.jwt.Dhis2JwtAuthenticationManagerResolver)1 DhisOidcClientRegistration (org.hisp.dhis.security.oidc.DhisOidcClientRegistration)1 DhisOidcProviderRepository (org.hisp.dhis.security.oidc.DhisOidcProviderRepository)1 GenericOidcProviderConfigParser (org.hisp.dhis.security.oidc.GenericOidcProviderConfigParser)1 GoogleProvider (org.hisp.dhis.security.oidc.provider.GoogleProvider)1 User (org.hisp.dhis.user.User)1 DhisControllerWithJwtTokenAuthTest (org.hisp.dhis.webapi.DhisControllerWithJwtTokenAuthTest)1 JwtTokenHeader (org.hisp.dhis.webapi.WebClient.JwtTokenHeader)1 JsonError (org.hisp.dhis.webapi.json.domain.JsonError)1 JsonUser (org.hisp.dhis.webapi.json.domain.JsonUser)1 DhisWebApiWebSecurityConfig (org.hisp.dhis.webapi.security.config.DhisWebApiWebSecurityConfig)1