Package com.nimbusds.oauth2.sdk

Examples of com.nimbusds.oauth2.sdk.AuthorizationCode


  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 testCodeIDTokenResponse()
    throws Exception {

    AuthorizationCode code = new AuthorizationCode();

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setIssuer("https://c2id.com");
    claimsSet.setAudience(Arrays.asList("https://client.com"));
    claimsSet.setSubject("alice");
View Full Code Here


  public void testCodeResponse()
    throws Exception {

    AuthorizationCode code = new AuthorizationCode();

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, code, null, null, new State("abc"));

    assertEquals(REDIRECT_URI, response.getRedirectionURI());
View Full Code Here

public class CodeHashTest extends TestCase {


  public void testComputeAgainstSpecExample() {

    AuthorizationCode code = new AuthorizationCode("Qcb0Orv1zh30vL1MPRsbm-diHiMwcLyZvn1arpZv-Jxf_11jnpEX3Tgfvk");

    CodeHash computedHash = CodeHash.compute(code, JWSAlgorithm.RS256);

    CodeHash expectedHash = new CodeHash("LDktKdoQak3Pk0cnXxCltA");
View Full Code Here

  }


  public void testEquality() {

    AuthorizationCode code = new AuthorizationCode();

    CodeHash hash1 = CodeHash.compute(code, JWSAlgorithm.HS512);

    CodeHash hash2 = CodeHash.compute(code, JWSAlgorithm.HS512);
View Full Code Here

  }


  public void testUnsupportedJWSAlg() {

    AuthorizationCode code = new AuthorizationCode();

    assertNull(CodeHash.compute(code, new JWSAlgorithm("no-such-alg")));
  }
View Full Code Here

    } 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

    throws ParseException {
 
    String clientIDString = params.get("client_id");
   
    if (clientIDString == null)
      throw new ParseException("Missing \"client_id\" parameter");
   
    String secretValue = params.get("client_secret");
   
    if (secretValue == null)
      throw new ParseException("Missing \"client_secret\" parameter");
   
    return new ClientSecretPost(new ClientID(clientIDString), new Secret(secretValue));
  }
View Full Code Here

    try {
      privateKeyJWT = new PrivateKeyJWT(clientAssertion);

    }catch (IllegalArgumentException e) {

      throw new ParseException(e.getMessage(), e);
    }

    // Check that the top level client_id matches the assertion subject + issuer

    ClientID clientID = JWTAuthentication.parseClientID(params);

    if (clientID != null) {

      if (! clientID.equals(privateKeyJWT.getClientID()))
        throw new ParseException("The client identifier doesn't match the client assertion subject / issuer");
    }

    return privateKeyJWT;
  }
View Full Code Here

    try {
      clientSecretJWT = new ClientSecretJWT(clientAssertion);

    } catch (IllegalArgumentException e) {

      throw new ParseException(e.getMessage(), e);
    }

    // Check that the top level client_id matches the assertion subject + issuer
   
    ClientID clientID = JWTAuthentication.parseClientID(params);

    if (clientID != null) {

      if (! clientID.equals(clientSecretJWT.getClientID()))
        throw new ParseException("The client identifier doesn't match the client assertion subject / issuer");
    }

    return clientSecretJWT;
  }
View Full Code Here

TOP

Related Classes of com.nimbusds.oauth2.sdk.AuthorizationCode

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.