Package com.nimbusds.jose

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


    JWSObject jwsObject = createInitialJWSObject(JWSAlgorithm.ES256);

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

    jwsObject.sign(signer);

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

    // Initialise verifier
    BigInteger x = publicKey.getW().getAffineX();
View Full Code Here


    JWSObject jwsObject = createInitialJWSObject(JWSAlgorithm.ES384);

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

    jwsObject.sign(signer);

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

    // Initialise verifier
    BigInteger x = publicKey.getW().getAffineX();
View Full Code Here

    JWSObject jwsObject = createInitialJWSObject(JWSAlgorithm.ES512);

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

    jwsObject.sign(signer);

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

    // Initialise verifier
    BigInteger x = publicKey.getW().getAffineX();
View Full Code Here

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

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

    jwsObject.sign(signer);

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

    BigInteger x = publicKey.getW().getAffineX();
    BigInteger y = publicKey.getW().getAffineY();
View Full Code Here

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

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

    jwsObject.sign(signer);

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

    BigInteger x = publicKey.getW().getAffineX();
    BigInteger y = publicKey.getW().getAffineY();
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

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

    JWSObject jwsObject2 = new JWSObject(new JWSHeader(JWSAlgorithm.RS256), new Payload("test123"));
    signer = new RSASSASigner(rsaJWK.toRSAPrivateKey());
    jwsObject2.sign(signer);
    Base64URL sig2 = jwsObject2.getSignature();

    assertTrue("Signature comparison", sig1.equals(sig2));

    // Verifier from raw Java RSA key
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.