Search in sources :

Example 1 with AuthenticationMethod

use of se.inera.intyg.infra.security.common.model.AuthenticationMethod in project webcert by sklintyg.

the class ElegAuthenticationMethodResolverTest method testMobiltBankID.

@Test
public void testMobiltBankID() {
    when(elegAuthenticationAttributeHelper.getAttribute(any(SAMLCredential.class), anyString())).thenReturn(MOBILT_BANK_ID_LOGIN_METHOD);
    AuthenticationMethod authMetod = testee.resolveAuthenticationMethod(buildPrivatlakareSamlCredential());
    assertEquals(AuthenticationMethod.MOBILT_BANK_ID, authMetod);
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) AuthenticationMethod(se.inera.intyg.infra.security.common.model.AuthenticationMethod) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 2 with AuthenticationMethod

use of se.inera.intyg.infra.security.common.model.AuthenticationMethod in project webcert by sklintyg.

the class CommonFakeAuthenticationProvider method applyAuthenticationMethod.

private void applyAuthenticationMethod(Authentication token, Object details) {
    if (details instanceof IntygUser) {
        if (token.getCredentials() != null && ((FakeCredentials) token.getCredentials()).getOrigin() != null) {
            String authenticationMethod = ((FakeCredentials) token.getCredentials()).getAuthenticationMethod();
            try {
                if (authenticationMethod != null && !authenticationMethod.isEmpty()) {
                    IntygUser user = (IntygUser) details;
                    AuthenticationMethod newAuthMethod = AuthenticationMethod.valueOf(authenticationMethod);
                    user.setAuthenticationMethod(newAuthMethod);
                }
            } catch (IllegalArgumentException e) {
                String allowedTypes = Arrays.asList(AuthenticationMethod.values()).stream().map(val -> val.name()).collect(Collectors.joining(", "));
                throw new AuthoritiesException("Could not set authenticationMethod '" + authenticationMethod + "'. Unknown, allowed types are " + allowedTypes);
            }
        }
    }
}
Also used : FakeCredentials(se.inera.intyg.webcert.web.auth.fake.FakeCredentials) AuthenticationMethod(se.inera.intyg.infra.security.common.model.AuthenticationMethod) AuthoritiesException(se.inera.intyg.infra.security.authorities.AuthoritiesException) IntygUser(se.inera.intyg.infra.security.common.model.IntygUser)

Example 3 with AuthenticationMethod

use of se.inera.intyg.infra.security.common.model.AuthenticationMethod in project webcert by sklintyg.

the class ElegAuthenticationMethodResolverTest method testNetID.

@Test
public void testNetID() {
    when(elegAuthenticationAttributeHelper.getAttribute(any(SAMLCredential.class), anyString())).thenReturn(NET_ID_LOGIN_METHOD);
    AuthenticationMethod authMetod = testee.resolveAuthenticationMethod(buildPrivatlakareSamlCredential());
    assertEquals(AuthenticationMethod.NET_ID, authMetod);
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) AuthenticationMethod(se.inera.intyg.infra.security.common.model.AuthenticationMethod) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Example 4 with AuthenticationMethod

use of se.inera.intyg.infra.security.common.model.AuthenticationMethod in project webcert by sklintyg.

the class ElegAuthenticationMethodResolverTest method testBankID.

@Test
public void testBankID() {
    when(elegAuthenticationAttributeHelper.getAttribute(any(SAMLCredential.class), anyString())).thenReturn(BANK_ID_LOGIN_METHOD);
    AuthenticationMethod authMetod = testee.resolveAuthenticationMethod(buildPrivatlakareSamlCredential());
    assertEquals(AuthenticationMethod.BANK_ID, authMetod);
}
Also used : SAMLCredential(org.springframework.security.saml.SAMLCredential) AuthenticationMethod(se.inera.intyg.infra.security.common.model.AuthenticationMethod) BaseSAMLCredentialTest(se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest) Test(org.junit.Test)

Aggregations

AuthenticationMethod (se.inera.intyg.infra.security.common.model.AuthenticationMethod)4 Test (org.junit.Test)3 SAMLCredential (org.springframework.security.saml.SAMLCredential)3 BaseSAMLCredentialTest (se.inera.intyg.webcert.web.auth.common.BaseSAMLCredentialTest)3 AuthoritiesException (se.inera.intyg.infra.security.authorities.AuthoritiesException)1 IntygUser (se.inera.intyg.infra.security.common.model.IntygUser)1 FakeCredentials (se.inera.intyg.webcert.web.auth.fake.FakeCredentials)1