Package com.nimbusds.jwt

Examples of com.nimbusds.jwt.PlainJWT


     
      JWT idToken;
     
      if (signingAlg.equals(JWSAlgorithm.NONE)) {
        // unsigned ID token
        idToken = new PlainJWT(idClaims);

      } else {

        // signed ID token
        idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
View Full Code Here


        }


      } else if (jwt instanceof PlainJWT) {
        PlainJWT plainJwt = (PlainJWT)jwt;

        // need to check clientId first so that we can load the client to check other fields
        if (request.getClientId() == null) {
          request.setClientId(plainJwt.getJWTClaimsSet().getStringClaim("client_id"));
        }

        ClientDetailsEntity client = clientDetailsService.loadClientByClientId(request.getClientId());

        if (client == null) {
View Full Code Here

        // set a random identifier
        refreshClaims.setJWTID(UUID.randomUUID().toString());

        // TODO: add issuer fields, signature to JWT

        PlainJWT refreshJwt = new PlainJWT(refreshClaims);
        refreshToken.setJwt(refreshJwt);

        //Add the authentication
        refreshToken.setAuthenticationHolder(authHolder);
        refreshToken.setClient(client);
View Full Code Here

    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setSubject("alice");

    JWT assertion = new PlainJWT(claimsSet);

    JWTBearerGrant grant = new JWTBearerGrant(assertion);

    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion, grant.getJWTAssertion());
    assertEquals(assertion.serialize(), grant.getAssertion());

    Map<String,String> params = grant.toParameters();
    assertEquals(GrantType.JWT_BEARER.getValue(), params.get("grant_type"));
    assertEquals(assertion.serialize(), params.get("assertion"));
    assertEquals(2, params.size());

    grant = JWTBearerGrant.parse(params);
    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion.serialize(), grant.getAssertion());
  }
View Full Code Here

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setSubject("alice");

    Map<String,String> params = new HashMap<>();
    params.put("grant_type", "invalid-grant");
    params.put("assertion", new PlainJWT(claimsSet).serialize());

    try {
      JWTBearerGrant.parse(params);
      fail();
    } catch (ParseException e) {
View Full Code Here

    throws Exception {

    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setSubject("alice");

    JWT assertion = new PlainJWT(claimsSet);

    Map<String,String> params = new HashMap<>();
    params.put("grant_type", GrantType.JWT_BEARER.getValue());
    params.put("assertion", assertion.serialize());

    JWTBearerGrant grant = (JWTBearerGrant)AuthorizationGrant.parse(params);

    assertEquals(GrantType.JWT_BEARER, grant.getType());
    assertEquals(assertion.serialize(), grant.getAssertion());
  }
View Full Code Here

  public ReadOnlyJWTClaimsSet decodeJWT(final JWT jwt)
    throws JOSEException, ParseException {
   
    if (jwt instanceof PlainJWT) {
   
      PlainJWT plainJWT = (PlainJWT)jwt;
     
      return plainJWT.getJWTClaimsSet();
   
    } else if (jwt instanceof SignedJWT) {
   
      SignedJWT signedJWT = (SignedJWT)jwt;
     
View Full Code Here

TOP

Related Classes of com.nimbusds.jwt.PlainJWT

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.