Package com.nimbusds.jose

Examples of com.nimbusds.jose.JWSObject.sign()


    // Create HMAC signer
    JWSSigner signer = new MACSigner(SHARED_KEY.getBytes());

    try {
      jwsObject.sign(signer);
    } catch(com.nimbusds.jose.JOSEException e) {
      System.err.println("Error signing JWT: " + e.getMessage());
      return;
    }
View Full Code Here



    MACSigner signer = new MACSigner(sharedSecret);
    assertEquals("Shared secret check", sharedSecret, signer.getSharedSecret());

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());


    MACVerifier verifier = new MACVerifier(sharedSecret);
View Full Code Here

    // Prepare JWS object with "Hello, world!" payload
    JWSObject jwsObject = new JWSObject(new JWSHeader(JWSAlgorithm.HS256), new Payload("Hello, world!"));

    // Apply the HMAC
    jwsObject.sign(signer);

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

    // To serialize to compact form, produces something like
    // eyJhbGciOiJIUzI1NiJ9.SGVsbG8sIHdvcmxkIQ.onO9Ihudz3WkiauDO2Uhyuz0Y18UASXlSc1eS0NkWyA
View Full Code Here


    MACSigner signer = new MACSigner(stringSecret);
    assertEquals("Shared secret string check", stringSecret, signer.getSharedSecretString());

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());


    MACVerifier verifier = new MACVerifier(stringSecret);
View Full Code Here

    JWSObject jwsObject = new JWSObject(header, payload);

    MACSigner signer = new MACSigner(stringSecret);

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());

    MACVerifier verifier = new MACVerifier(stringSecret);
    verifier.getIgnoredCriticalHeaderParameters().add("exp");
View Full Code Here

    JWSObject jwsObject = new JWSObject(header, payload);

    MACSigner signer = new MACSigner(stringSecret);

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());

    MACVerifier verifier = new MACVerifier(stringSecret);
View Full Code Here


    RSASSASigner signer = new RSASSASigner(PRIVATE_KEY);
    assertNotNull("Private key check", signer.getPrivateKey());

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());


    RSASSAVerifier verifier = new RSASSAVerifier(PUBLIC_KEY);
View Full Code Here

    JWSObject jwsObject = new JWSObject(header, PAYLOAD);

    assertEquals("State check", JWSObject.State.UNSIGNED, jwsObject.getState());

    jwsObject.sign(signer);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());

    assertTrue("Verify signature", jwsObject.verify(verifier));
View Full Code Here

    // Prepare JWS object with simple string as payload
    JWSObject jwsObject = new JWSObject(new JWSHeader(JWSAlgorithm.RS256), new Payload("In RSA we trust!"));

    // Compute the RSA signature
    jwsObject.sign(signer);

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

    // To serialize to compact form, produces something like
    // eyJhbGciOiJSUzI1NiJ9.SW4gUlNBIHdlIHRydXN0IQ.IRMQENi4nJyp4er2L
View Full Code Here

    RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)keyPair.getPrivate();

    // Create signer from raw Java RSA key
    JWSObject jwsObject1 = new JWSObject(new JWSHeader(JWSAlgorithm.RS256), new Payload("test123"));
    JWSSigner signer = new RSASSASigner(rsaPrivateKey);
    jwsObject1.sign(signer);
    Base64URL sig1 = jwsObject1.getSignature();

    // Create signer from JWK representation
    RSAKey rsaJWK = new RSAKey.Builder(rsaPublicKey).privateKey(rsaPrivateKey).build();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.