Search in sources :

Example 1 with OidcProfile

use of org.pac4j.oidc.profile.OidcProfile in project pac4j by pac4j.

the class RunCasOidcWrapper method verifyProfile.

@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals(getLogin(), profile.getId());
    assertNotNull(profile.getIdToken());
    assertEquals("http://localhost:8080/cas/oidc", profile.getIssuer());
    assertEquals(CLIENT_ID, profile.getAttribute("preferred_username"));
    assertNotNull(profile.getAccessToken());
    assertEquals(CLIENT_ID, profile.getAudience().get(0));
    assertNotNull(profile.getNotBefore());
    assertNotNull(profile.getAuthTime());
    assertNotNull(profile.getAttribute("state"));
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAttribute("jti"));
    assertEquals(13, profile.getAttributes().size());
}
Also used : OidcProfile(org.pac4j.oidc.profile.OidcProfile)

Example 2 with OidcProfile

use of org.pac4j.oidc.profile.OidcProfile in project pac4j by pac4j.

the class RunIdentityServer4 method verifyProfile.

@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals("818727", profile.getId());
    assertNotNull(profile.getIdToken());
    assertEquals("test", profile.getAudience().get(0));
    assertNotNull(profile.getNotBefore());
    assertEquals("idsvr", profile.getAttribute("idp"));
    assertNotNull(profile.getAuthTime());
    assertEquals("http://localhost:1941", profile.getIssuer());
    assertEquals("Alice Smith", profile.getDisplayName());
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAttribute("sid"));
    if (flow == Flow.IMPLICIT_FLOW || flow == Flow.IMPLICIT_FLOW_CLIENT_SIDE) {
        assertNull(profile.getAccessToken());
        assertEquals(12, profile.getAttributes().size());
    } else if (flow == Flow.AUTHORIZATION_CODE) {
        assertNotNull(profile.getAccessToken());
        assertEquals(12, profile.getAttributes().size());
    } else if (flow == Flow.HYBRID_FLOW) {
        assertNotNull(profile.getAccessToken());
        assertEquals(13, profile.getAttributes().size());
    }
}
Also used : OidcProfile(org.pac4j.oidc.profile.OidcProfile)

Example 3 with OidcProfile

use of org.pac4j.oidc.profile.OidcProfile in project pac4j by pac4j.

the class RunKeycloakOidcClient method verifyProfile.

@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals(IDENTIFIER, profile.getId());
    assertNotNull(profile.getIdToken());
    assertNotNull(profile.getNotBefore());
    assertEquals(ISSUER, profile.getIssuer());
    assertEquals(NAME_VALUE, profile.getDisplayName());
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAccessToken());
    assertEquals(GIVEN_NAME, profile.getAttribute("given_name"));
    assertEquals(FAMILY_NAME, profile.getAttribute("family_name"));
    assertEquals(PREFERRED_USERNAME, profile.getAttribute("preferred_username"));
    assertEquals(EMAIL_VALUE, profile.getAttribute("email"));
}
Also used : OidcProfile(org.pac4j.oidc.profile.OidcProfile)

Example 4 with OidcProfile

use of org.pac4j.oidc.profile.OidcProfile in project pac4j by pac4j.

the class RunOkta method verifyProfile.

@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals("00u5h0czw1aIjTQtM0h7", profile.getId());
    assertEquals(OidcProfile.class.getName() + CommonProfile.SEPARATOR + "00u5h0czw1aIjTQtM0h7", profile.getTypedId());
    assertNotNull(profile.getAccessToken());
    assertNotNull(profile.getIdToken());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), OidcProfile.class));
    assertNotNull(profile.getIdTokenString());
    assertCommonProfile(profile, getLogin(), "Test", "pac4j", "Test pac4j", "testpac4j@gmail.com", Gender.UNSPECIFIED, new Locale("en", "US"), null, null, "America/Los_Angeles");
    assertTrue((Boolean) profile.getAttribute("email_verified"));
    assertNotNull(profile.getAttribute("at_hash"));
    assertEquals("1", profile.getAttribute("ver").toString());
    assertNotNull(profile.getAmr());
    assertEquals("https://dev-425954.oktapreview.com", profile.getIssuer());
    assertEquals("ZuxDX1Gw2Kvx4gFyDNWC", profile.getAudience().get(0));
    assertEquals("00o5gxpohzF1JWEXZ0h7", profile.getAttribute("idp"));
    assertNotNull(profile.getAuthTime());
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAttribute("jti"));
    assertEquals(22, profile.getAttributes().size());
}
Also used : Locale(java.util.Locale) OidcProfile(org.pac4j.oidc.profile.OidcProfile)

Example 5 with OidcProfile

use of org.pac4j.oidc.profile.OidcProfile in project ddf by codice.

the class OidcLogoutActionProviderTest method setup.

@Before
public void setup() {
    oidcLogoutActionBuilder = mock(OidcLogoutActionBuilder.class);
    OidcHandlerConfiguration handlerConfiguration = mock(OidcHandlerConfiguration.class);
    when(handlerConfiguration.getOidcLogoutActionBuilder()).thenReturn(oidcLogoutActionBuilder);
    oidcLogoutActionProvider = new OidcLogoutActionProvider(handlerConfiguration);
    oidcLogoutActionProvider.setSubjectOperations(new SubjectUtils());
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    subject = mock(Subject.class);
    HttpSession session = mock(HttpSession.class);
    PrincipalHolder principalHolderMock = mock(PrincipalHolder.class);
    SimplePrincipalCollection principalCollection = new SimplePrincipalCollection();
    SecurityAssertion securityAssertion = mock(SecurityAssertion.class);
    OidcProfile profile = mock(OidcProfile.class);
    when(securityAssertion.getToken()).thenReturn(profile);
    when(securityAssertion.getTokenType()).thenReturn(SecurityAssertionJwt.JWT_TOKEN_TYPE);
    when(subject.getPrincipals()).thenReturn(principalCollection);
    when(principalHolderMock.getPrincipals()).thenReturn(principalCollection);
    principalCollection.add(securityAssertion, "oidc");
    when(session.getAttribute(SecurityConstants.SECURITY_TOKEN_KEY)).thenReturn(principalHolderMock);
    when(request.getSession(false)).thenReturn(session);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) OidcHandlerConfiguration(org.codice.ddf.security.handler.api.OidcHandlerConfiguration) SubjectUtils(ddf.security.service.impl.SubjectUtils) OidcLogoutActionBuilder(org.pac4j.oidc.logout.OidcLogoutActionBuilder) HttpSession(javax.servlet.http.HttpSession) HttpServletResponse(javax.servlet.http.HttpServletResponse) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) OidcProfile(org.pac4j.oidc.profile.OidcProfile) SecurityAssertion(ddf.security.assertion.SecurityAssertion) PrincipalHolder(ddf.security.common.PrincipalHolder) Subject(ddf.security.Subject) Before(org.junit.Before)

Aggregations

OidcProfile (org.pac4j.oidc.profile.OidcProfile)10 WebContext (org.pac4j.core.context.WebContext)3 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)2 SecurityAssertion (ddf.security.assertion.SecurityAssertion)2 PrincipalHolder (ddf.security.common.PrincipalHolder)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 HttpSession (javax.servlet.http.HttpSession)2 AuthenticationException (org.apache.shiro.authc.AuthenticationException)2 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)2 OidcLogoutActionBuilder (org.pac4j.oidc.logout.OidcLogoutActionBuilder)2 JWT (com.nimbusds.jwt.JWT)1 PlainJWT (com.nimbusds.jwt.PlainJWT)1 AccessToken (com.nimbusds.oauth2.sdk.token.AccessToken)1 RefreshToken (com.nimbusds.oauth2.sdk.token.RefreshToken)1 OIDCProviderMetadata (com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata)1 ActionImpl (ddf.action.impl.ActionImpl)1 Subject (ddf.security.Subject)1 SubjectUtils (ddf.security.service.impl.SubjectUtils)1 MalformedURLException (java.net.MalformedURLException)1