Package com.nimbusds.jwt

Examples of com.nimbusds.jwt.EncryptedJWT


      JwtEncryptionAndDecryptionService encrypter = encrypters.getEncrypter(client.getJwksUri());

      if (encrypter != null) {

        EncryptedJWT idToken = new EncryptedJWT(new JWEHeader(client.getIdTokenEncryptedResponseAlg(), client.getIdTokenEncryptedResponseEnc()), idClaims);

        encrypter.encryptJwt(idToken);

        idTokenEntity.setJwt(idToken);
View Full Code Here


        // if we got here, we're OK, keep processing

      } else if (jwt instanceof EncryptedJWT) {

        EncryptedJWT encryptedJWT = (EncryptedJWT)jwt;

        // decrypt the jwt if we can

        encryptionService.decryptJwt(encryptedJWT);

        // TODO: what if the content is a signed JWT? (#525)

        if (!encryptedJWT.getState().equals(State.DECRYPTED)) {
          throw new InvalidClientException("Unable to decrypt the request object");
        }

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

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

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

    // Optional parameters
    for (Entry<String, String> option : options.entrySet()) {
      claims.setClaim(option.getKey(), option.getValue());
    }

    EncryptedJWT jwt = new EncryptedJWT(new JWEHeader(alg, enc), claims);

    JwtEncryptionAndDecryptionService encryptor = encrypterService.getEncrypter(serverConfig.getJwksUri());

    encryptor.encryptJwt(jwt);

    try {
      URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri());
      uriBuilder.addParameter("request", jwt.serialize());

      // build out the URI
      return uriBuilder.build().toString();
    } catch (URISyntaxException e) {
      throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e);
View Full Code Here

        JwtEncryptionAndDecryptionService encrypter = encrypters.getEncrypter(client.getJwksUri());

        if (encrypter != null) {

          EncryptedJWT encrypted = new EncryptedJWT(new JWEHeader(client.getIdTokenEncryptedResponseAlg(), client.getIdTokenEncryptedResponseEnc()), claims);

          encrypter.encryptJwt(encrypted);


          Writer out = response.getWriter();
          out.write(encrypted.serialize());

        } else {
          logger.error("Couldn't find encrypter for client: " + client.getClientId());
        }
      } else {
View Full Code Here

    assertEquals(RSAkid,service.getDefaultEncryptionKeyId());
    assertEquals(RSAkid,service.getDefaultDecryptionKeyId());

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A256GCM);

    EncryptedJWT jwt = new EncryptedJWT(header, claimsSet);

    service.encryptJwt(jwt);
    String serialized = jwt.serialize();

    EncryptedJWT encryptedJwt = EncryptedJWT.parse(serialized);
    assertThat(encryptedJwt.getJWTClaimsSet(), nullValue());
    service.decryptJwt(encryptedJwt);

    ReadOnlyJWTClaimsSet resultClaims = encryptedJwt.getJWTClaimsSet();

    assertEquals(claimsSet.getIssuer(), resultClaims.getIssuer());
    assertEquals(claimsSet.getSubject(), resultClaims.getSubject());
  }
View Full Code Here

    assertEquals(RSAkid,service.getDefaultEncryptionKeyId());
    assertEquals(RSAkid,service.getDefaultDecryptionKeyId());

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A256GCM);

    EncryptedJWT jwt = new EncryptedJWT(header, claimsSet);

    service.encryptJwt(jwt);
    String serialized = jwt.serialize();

    EncryptedJWT encryptedJwt = EncryptedJWT.parse(serialized);
    assertThat(encryptedJwt.getJWTClaimsSet(), nullValue());
    service.decryptJwt(encryptedJwt);

    ReadOnlyJWTClaimsSet resultClaims = encryptedJwt.getJWTClaimsSet();

    assertEquals(claimsSet.getIssuer(), resultClaims.getIssuer());
    assertEquals(claimsSet.getSubject(), resultClaims.getSubject());
  }
View Full Code Here

    service_2.setDefaultEncryptionKeyId(null);
    assertEquals(null, service_2.getDefaultEncryptionKeyId());

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A256GCM);

    EncryptedJWT jwt = new EncryptedJWT(header, claimsSet);

    service_2.encryptJwt(jwt);
    assertEquals(null, service_2.getDefaultEncryptionKeyId());
  }
View Full Code Here

    assertEquals(RSAkid, service_2.getDefaultEncryptionKeyId());
    assertEquals(null, service_2.getDefaultDecryptionKeyId());

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A256GCM);

    EncryptedJWT jwt = new EncryptedJWT(header, claimsSet);
    service_2.encryptJwt(jwt);
    String serialized = jwt.serialize();

    EncryptedJWT encryptedJwt = EncryptedJWT.parse(serialized);
    assertThat(encryptedJwt.getJWTClaimsSet(), nullValue());

    assertEquals(null, service_2.getDefaultDecryptionKeyId());
    service_2.decryptJwt(encryptedJwt);
  }
View Full Code Here

     
      return verify(signedJWT);

    } else if (jwt instanceof EncryptedJWT) {
   
      EncryptedJWT encryptedJWT = (EncryptedJWT)jwt;
     
      return decrypt(encryptedJWT);
     
    } else {
   
View Full Code Here

TOP

Related Classes of com.nimbusds.jwt.EncryptedJWT

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.