Package com.nimbusds.jose

Examples of com.nimbusds.jose.Payload


    KeyPair keyPair = createECKeyPair(EC512SPEC);
    ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
    ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();

    JWSObject jwsObject = new JWSObject(header, new Payload("Hello world!"));

    JWSSigner signer = new ECDSASigner(privateKey.getS());

    jwsObject.sign(signer);
View Full Code Here


  public void testWithA192GCM()
    throws Exception {

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A192GCM);
    Payload payload = new Payload("Hello world!");

    JWEObject jweObject = new JWEObject(header, payload);

    assertEquals("State check", JWEObject.State.UNENCRYPTED, jweObject.getState());

    JWEEncrypter encrypter = new RSAEncrypter(publicKey);

    assertEquals(publicKey, ((RSAEncrypter)encrypter).getPublicKey());

    jweObject.encrypt(encrypter);

    assertEquals("State check", JWEObject.State.ENCRYPTED, jweObject.getState());

    String jweString = jweObject.serialize();

    jweObject = JWEObject.parse(jweString);

    JWEDecrypter decrypter = new RSADecrypter(privateKey);

    assertEquals(privateKey, ((RSADecrypter)decrypter).getPrivateKey());

    jweObject.decrypt(decrypter);

    assertEquals("State check", JWEObject.State.DECRYPTED, jweObject.getState());

    payload = jweObject.getPayload();

    assertEquals("Hello world!", payload.toString());
  }
View Full Code Here

  public void testWithA256GCM()
    throws Exception {

    JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP, EncryptionMethod.A256GCM);
    Payload payload = new Payload("I think therefore I am.");

    JWEObject jweObject = new JWEObject(header, payload);

    assertEquals("State check", JWEObject.State.UNENCRYPTED, jweObject.getState());

    JWEEncrypter encrypter = new RSAEncrypter(publicKey);

    assertEquals(publicKey, ((RSAEncrypter)encrypter).getPublicKey());

    jweObject.encrypt(encrypter);

    assertEquals("State check", JWEObject.State.ENCRYPTED, jweObject.getState());

    String jweString = jweObject.serialize();

    jweObject = JWEObject.parse(jweString);

    assertEquals("State check", JWEObject.State.ENCRYPTED, jweObject.getState());

    JWEDecrypter decrypter = new RSADecrypter(privateKey);

    assertEquals(privateKey, ((RSADecrypter)decrypter).getPrivateKey());

    jweObject.decrypt(decrypter);

    assertEquals("State check", JWEObject.State.DECRYPTED, jweObject.getState());

    payload = jweObject.getPayload();

    assertEquals("I think therefore I am.", payload.toString());
  }
View Full Code Here

    jweObject.decrypt(decrypter);

    assertEquals("State check", JWEObject.State.DECRYPTED, jweObject.getState());

    Payload payload = jweObject.getPayload();

    assertEquals("The true sign of intelligence is not knowledge but imagination.", payload.toString());
  }
View Full Code Here

  public static void main(final String[] args) {

    // Create payload
    String message = "Hello world!";
   
    Payload payload = new Payload(message);
   
    System.out.println("JWS payload message: " + message);
   
   
    // Create JWS header with HS256 algorithm
View Full Code Here

   * @param header    The JWS header. Must not be {@code null}.
   * @param claimsSet The JWT claims set. Must not be {@code null}.
   */
  public SignedJWT(final JWSHeader header, final ReadOnlyJWTClaimsSet claimsSet) {

    super(header, new Payload(claimsSet.toJSONObject()));
  }
View Full Code Here

   *
   * @param claimsSet The JWT claims set. Must not be {@code null}.
   */
  public PlainJWT(final JWTClaimsSet claimsSet) {

    super(new Payload(claimsSet.toJSONObject()));
  }
View Full Code Here

   * @param header    The plain header. Must not be {@code null}.
   * @param claimsSet The JWT claims set. Must not be {@code null}.
   */
  public PlainJWT(final PlainHeader header, final ReadOnlyJWTClaimsSet claimsSet) {

    super(header, new Payload(claimsSet.toJSONObject()));
  }
View Full Code Here

  private static JWSObject createInitialJWSObject(final JWSAlgorithm alg) {

    JWSHeader header = new JWSHeader(alg);
    header.setContentType("text/plain");

    return new JWSObject(header, new Payload("Hello world!"));
  }
View Full Code Here

    KeyPair keyPair = createECKeyPair(EC512SPEC);
    ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
    ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();

    JWSObject jwsObject = new JWSObject(header, new Payload("Hello world!"));

    JWSSigner signer = new ECDSASigner(privateKey.getS());

    jwsObject.sign(signer);
View Full Code Here

TOP

Related Classes of com.nimbusds.jose.Payload

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.