Package com.nimbusds.oauth2.sdk.id

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


  public void testConstructorWithClientID()
    throws Exception {

    URI uri = new URI("https://c2id.com/token");
    ClientID clientID = new ClientID("123");
    AuthorizationCodeGrant grant = new AuthorizationCodeGrant(new AuthorizationCode("abc"), new URI("http://example.com/in"));

    TokenRequest request = new TokenRequest(uri, clientID, grant, null);

    assertEquals(uri, request.getEndpointURI());
View Full Code Here


  public void testConstructorWithClientIDAndNoScope()
    throws Exception {

    URI uri = new URI("https://c2id.com/token");
    ClientID clientID = new ClientID("123");
    AuthorizationCodeGrant grant = new AuthorizationCodeGrant(new AuthorizationCode("abc"), new URI("http://example.com/in"));

    TokenRequest request = new TokenRequest(uri, clientID, grant);

    assertEquals(uri, request.getEndpointURI());
View Full Code Here

  public void testConstructorMissingClientID()
    throws Exception {

    URI uri = new URI("https://c2id.com/token");
    ClientID clientID = null;
    AuthorizationCodeGrant grant = new AuthorizationCodeGrant(new AuthorizationCode("abc"), new URI("http://example.com/in"));

    try {
      new TokenRequest(uri, clientID, grant, null);
      fail();
View Full Code Here

    throws Exception {

    AuthorizationCode code = new AuthorizationCode();
    URI endpointUri = new URI("https://token.endpoint.uri/token");
    URI redirectUri = new URI("https://arbitrary.redirect.uri/");
    ClientID clientId = new ClientID("client");
    Secret secret = new Secret("secret");
    ClientSecretPost clientAuthentication = new ClientSecretPost(clientId,secret);
    AuthorizationGrant grant = new AuthorizationCodeGrant(code,redirectUri);
    TokenRequest request = new TokenRequest(endpointUri,clientAuthentication,grant);
View Full Code Here

    // Test vectors from OAuth 2.0 RFC
   
    final String id = "s6BhdRkqt3";
    final String pw = "7Fjfp0ZBr1KtDRbnfVdmIw";
   
    ClientID clientID = new ClientID(id);
    Secret secret = new Secret(pw);
   
    ClientSecretBasic csb = new ClientSecretBasic(clientID, secret);
   
    assertEquals(ClientAuthenticationMethod.CLIENT_SECRET_BASIC, csb.getMethod());
View Full Code Here

   
    BearerAccessToken accessToken = BearerAccessToken.parse(httpRequest.getAuthorization());
   
    JSONObject jsonObject = httpRequest.getQueryAsJSONObject();
   
    ClientID id = new ClientID(JSONObjectUtils.getString(jsonObject, "client_id"));

    ClientMetadata metadata = ClientMetadata.parse(jsonObject);
   
    Secret clientSecret = null;
   
View Full Code Here


  public void testRun()
    throws Exception {

    ClientID clientID = new ClientID("http://client.com");
    Audience audience = new Audience("http://idp.com");
    Date exp = DateUtils.fromSecondsSinceEpoch(new Date().getTime() / 1000 + 3600);
    Date nbf = DateUtils.fromSecondsSinceEpoch(new Date().getTime() / 1000);
    Date iat = DateUtils.fromSecondsSinceEpoch(new Date().getTime() / 1000);
    JWTID jti = new JWTID();

    JWTAuthenticationClaimsSet assertion = new JWTAuthenticationClaimsSet(clientID, audience, exp, nbf, iat, jti);

    System.out.println("Client secret JWT claims set: " + assertion.toJSONObject());


    JWSHeader jwsHeader = new JWSHeader(JWSAlgorithm.HS256);

    SignedJWT jwt = new SignedJWT(jwsHeader, assertion.toJWTClaimsSet());

    Secret secret = new Secret();

    MACSigner signer = new MACSigner(secret.getValueBytes());

    jwt.sign(signer);

    ClientSecretJWT clientSecretJWT = new ClientSecretJWT(jwt);

    Map<String,String> params = clientSecretJWT.toParameters();
    params.put("client_id", clientID.getValue()); // add optional client_id to test parser

    System.out.println("Client secret JWT: " + params);

    clientSecretJWT = ClientSecretJWT.parse(params);

    assertEquals("http://client.com", clientSecretJWT.getClientID().getValue());

    jwt = clientSecretJWT.getClientAssertion();

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

    MACVerifier verifier = new MACVerifier(secret.getValueBytes());

    boolean verified = jwt.verify(verifier);

    assertTrue(verified);

    assertion = clientSecretJWT.getJWTAuthenticationClaimsSet();

    assertEquals(clientID.getValue(), assertion.getClientID().getValue());
    assertEquals(clientID.getValue(), assertion.getIssuer().getValue());
    assertEquals(clientID.getValue(), assertion.getSubject().getValue());
    assertEquals(audience.getValue(), assertion.getAudience().getValue());
    assertEquals(exp.getTime(), assertion.getExpirationTime().getTime());
    assertEquals(nbf.getTime(), assertion.getNotBeforeTime().getTime());
    assertEquals(iat.getTime(), assertion.getIssueTime().getTime());
    assertEquals(jti.getValue(), assertion.getJWTID().getValue());
View Full Code Here


  public void testParseSuccess()
    throws Exception {

    ClientID id = new ClientID("123");
    OIDCClientMetadata metadata = new OIDCClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/cb"));
    URI regURI = new URI("https://c2id.com/client-reg/123");
    BearerAccessToken accessToken = new BearerAccessToken();
    metadata.setName("My app");
View Full Code Here

    // Test vectors from OAuth 2.0 RFC

    final String id = "s6BhdRkqt3";
    final String pw = "7Fjfp0ZBr1KtDRbnfVdmIw";

    ClientID clientID = new ClientID(id);
    Secret secret = new Secret(pw);

    ClientSecretPost csp = new ClientSecretPost(clientID, secret);

    assertEquals(ClientAuthenticationMethod.CLIENT_SECRET_POST, csp.getMethod());
View Full Code Here

    throws Exception {

    GeneralException e = new GeneralException(
      "message",
      OAuth2Error.INVALID_REQUEST,
      new ClientID("abc"),
      new URI("https://redirect.com"),
      new State("123"));

    assertEquals("message", e.getMessage());
    assertEquals(OAuth2Error.INVALID_REQUEST, e.getErrorObject());
View Full Code Here

TOP

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

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.