Package com.nimbusds.openid.connect.sdk.claims

Examples of com.nimbusds.openid.connect.sdk.claims.UserInfo



  public void testPlain()
    throws Exception {

    UserInfo claims = new UserInfo(new Subject("alice"));
    claims.setName("Alice Adams");
    claims.setEmail(new InternetAddress("alice@wonderland.net"));
    claims.setEmailVerified(true);

    UserInfoSuccessResponse response = new UserInfoSuccessResponse(claims);

    assertEquals(claims, response.getUserInfo());
    assertEquals("application/json; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfoJWT());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = UserInfoSuccessResponse.parse(httpResponse);

    assertEquals("application/json; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfoJWT());

    claims = response.getUserInfo();

    assertEquals("alice", claims.getSubject().getValue());
    assertEquals("Alice Adams", claims.getName());
    assertEquals("alice@wonderland.net", claims.getEmail().toString());
    assertTrue(claims.getEmailVerified());
  }
View Full Code Here



  public void testJWT()
    throws Exception {

    UserInfo claims = new UserInfo(new Subject("alice"));
    claims.setName("Alice Adams");
    claims.setEmail(new InternetAddress("alice@wonderland.net"));
    claims.setEmailVerified(true);

    JWTClaimsSet claimsSet = claims.toJWTClaimsSet();

    Secret secret = new Secret();

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);

    jwt.sign(new MACSigner(secret.getValueBytes()));

    UserInfoSuccessResponse response = new UserInfoSuccessResponse(jwt);

    assertEquals(jwt, response.getUserInfoJWT());
    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());

    HTTPResponse httpResponse = response.toHTTPResponse();

    response = UserInfoSuccessResponse.parse(httpResponse);

    assertEquals("application/jwt; charset=UTF-8", response.getContentType().toString());
    assertNull(response.getUserInfo());

    jwt = (SignedJWT)response.getUserInfoJWT();

    assertTrue(jwt.getState().equals(JWSObject.State.SIGNED));

    claims = new UserInfo(response.getUserInfoJWT().getJWTClaimsSet().toJSONObject());

    assertEquals("alice", claims.getSubject().getValue());
    assertEquals("Alice Adams", claims.getName());
    assertEquals("alice@wonderland.net", claims.getEmail().toString());
    assertTrue(claims.getEmailVerified());
  }
View Full Code Here

   
    UserInfoSuccessResponse response;
   
    if (ct.match(CommonContentTypes.APPLICATION_JSON)) {
   
      UserInfo claimsSet;
     
      try {
        claimsSet = new UserInfo(httpResponse.getContentAsJSONObject());
       
      } catch (Exception e) {
       
        throw new ParseException("Couldn't parse UserInfo claims: " +
                           e.getMessage(), e);
View Full Code Here

TOP

Related Classes of com.nimbusds.openid.connect.sdk.claims.UserInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.