Package com.nimbusds.oauth2.sdk.id

Examples of com.nimbusds.oauth2.sdk.id.Subject


      }
    }


    // Parse optional state third
    State state = State.parse(params.get("state"));


    // Parse mandatory response type
    v = params.get("response_type");
View Full Code Here


  public void testParseSuccess()
    throws Exception {

    URI redirectURI = new URI("https://example.com/in");
    AuthorizationCode code = new AuthorizationCode("123");
    State state = new State("xyz");

    AuthenticationSuccessResponse successResponse = new AuthenticationSuccessResponse(redirectURI, code, null, null, state);

    HTTPResponse httpResponse = successResponse.toHTTPResponse();
View Full Code Here

  public void testParseError()
    throws Exception {

    URI redirectURI = new URI("https://example.com/in");
    ResponseType rt = new ResponseType(ResponseType.Value.CODE);
    State state = new State("xyz");

    AuthenticationErrorResponse errorResponse = new AuthenticationErrorResponse(redirectURI, OAuth2Error.ACCESS_DENIED, rt, state);

    HTTPResponse httpResponse = errorResponse.toHTTPResponse();
View Full Code Here

    if (clientID == null)
      throw new IllegalArgumentException("The client ID must not be null");

    iss = new Issuer(clientID.getValue());

    sub = new Subject(clientID.getValue());

   
    if (aud == null)
      throw new IllegalArgumentException("The audience must not be null");
View Full Code Here

  public static JWTAuthenticationClaimsSet parse(final JSONObject jsonObject)
    throws ParseException {
   
    // Parse required claims
    Issuer iss = new Issuer(JSONObjectUtils.getString(jsonObject, "iss"));
    Subject sub = new Subject(JSONObjectUtils.getString(jsonObject, "sub"));

    Audience aud;

    if (jsonObject.get("aud") instanceof String) {

      aud = new Audience(JSONObjectUtils.getString(jsonObject, "aud"));

    } else {
      String[] audList = JSONObjectUtils.getStringArray(jsonObject, "aud");

      if (audList.length > 1)
        throw new ParseException("Multiple audiences (aud) not supported");

      aud = new Audience(audList[0]);
    }

    Date exp = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "exp"));


    // Parse optional claims

    Date nbf = null;

    if (jsonObject.containsKey("nbf"))
      nbf = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "nbf"));

    Date iat = null;

    if (jsonObject.containsKey("iat"))
      iat = DateUtils.fromSecondsSinceEpoch(JSONObjectUtils.getLong(jsonObject, "iat"));

    JWTID jti = null;

    if (jsonObject.containsKey("jti"))
      jti = new JWTID(JSONObjectUtils.getString(jsonObject, "jti"));


    // Check client ID

    if (! iss.getValue().equals(sub.getValue()))
      throw new ParseException("JWT issuer and subject must have the same client ID");

    ClientID clientID = new ClientID(iss.getValue());

    return new JWTAuthenticationClaimsSet(clientID, aud, exp, nbf, iat, jti);
View Full Code Here

    HashingSubjectIdentifierGenerator gen = new HashingSubjectIdentifierGenerator(salt);

    assertEquals(salt, new String(gen.saltBytes(), Charset.forName("UTF-8")));

    String sectorID = "example.com";
    Subject localSubject = new Subject("alice");

    Subject pairWiseSubject = gen.generate(sectorID, localSubject);

    System.out.println("Pairwise subject: " + pairWiseSubject);

    assertEquals("Consistency check", pairWiseSubject.toString(), gen.generate(sectorID, localSubject).toString());
  }
View Full Code Here

  }


  public void testConstructor() {

    Subject subject = new Subject("alice");

    UserInfo userInfo = new UserInfo(subject);

    assertEquals(subject.getValue(), userInfo.getSubject().getValue());
    assertNull(userInfo.getName());
    assertNull(userInfo.getGivenName());
    assertNull(userInfo.getFamilyName());
    assertNull(userInfo.getMiddleName());
    assertNull(userInfo.getNickname());
View Full Code Here


  public void testGettersAndSetters()
    throws Exception {

    UserInfo userInfo = new UserInfo(new Subject("sub"));

    userInfo.setName("name");
    userInfo.setGivenName("given_name");
    userInfo.setFamilyName("family_name");
    userInfo.setMiddleName("middle_name");
View Full Code Here


  public void testLanguageTaggedGettersAndSetters()
    throws Exception {

    UserInfo userInfo = new UserInfo(new Subject("sub"));

    userInfo.setName("name#en", LangTag.parse("en"));
    userInfo.setName("name#bg", LangTag.parse("bg"));

    userInfo.setGivenName("given_name#en", LangTag.parse("en"));
View Full Code Here


  public void testPutAll()
    throws Exception {

    Subject alice = new Subject("alice");

    UserInfo userInfo = new UserInfo(alice);
    userInfo.setGivenName("Alice");

    UserInfo other = new UserInfo(alice);
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.id.Subject

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.