Package org.jose4j.jws

Examples of org.jose4j.jws.JsonWebSignature.verifySignature()


        String jwsJson = jwe.getPlaintextString();
        System.out.println(jwsJson);
        JsonWebSignature jws = new JsonWebSignature();
        jws.setCompactSerialization(jwsJson);
        jws.setKey(ExampleRsaKeyFromJws.PUBLIC_KEY);
        System.out.println(jws.verifySignature());
        System.out.println(jws.getPayload());
        Map<String, Object> claims = JsonUtil.parseJson(jws.getPayload());
        assertEquals("joe", claims.get(ReservedClaimNames.ISSUER));
        assertTrue((Boolean) claims.get("http://example.com/is_root"));
        assertEquals(IntDate.fromSeconds(1300819380), JsonHelp.getIntDate(claims, ReservedClaimNames.EXPIRATION_TIME));
View Full Code Here


        // verify consuming the JWS
        JsonWebSignature jws = new JsonWebSignature();
        jws.setCompactSerialization(jwsCompactSerialization);
        JsonWebKey jwk = JsonWebKey.Factory.newJwk(figure3RsaJwkJsonString);
        jws.setKey(jwk.getKey());
        assertThat(jws.verifySignature(), is(true));
        assertThat(jws.getPayload(), equalTo(jwsPayload));
        assertThat(jws.getKeyIdHeaderValue(), equalTo(jwk.getKeyId()));
        assertThat(alg, equalTo(jws.getAlgorithmHeaderValue()));

        // verify reproducing it (it's just luck that using the setters for the headers results in the exact same
View Full Code Here

                        "6GYmJUAfmWjwZ6oD4ifKo8DYM-X72Eaw";

                JsonWebSignature jws = new JsonWebSignature();
                jws.setCompactSerialization(cs);
                jws.setKey(jwk.getPublicKey());
                assertThat(jws.verifySignature(), is(true));
                assertThat(jws.getPayload(), equalTo(jwsPayload));
                assertThat(jws.getKeyIdHeaderValue(), equalTo(jwk.getKeyId()));
                assertThat(rsaPssUsingSha384, equalTo(jws.getAlgorithmHeaderValue()));

                // can't easily verify reproducing RSA-PSS because "it is probabilistic rather than deterministic,
View Full Code Here

        JsonWebKey jwk = JsonWebKey.Factory.newJwk(jwkJson);

        jws.setKey(jwk.getKey());
        assertThat(jws.getUnverifiedPayload(), equalTo(jwsPayload));

        assertThat(jws.verifySignature(), is(true));
        assertThat(jws.getPayload(), equalTo(jwsPayload));

        assertThat(jws.getKeyIdHeaderValue(), equalTo(jwk.getKeyId()));
        assertThat(alg, equalTo(jws.getAlgorithmHeaderValue()));
View Full Code Here

        // verify consuming the JWS
        JsonWebSignature jws = new JsonWebSignature();
        jws.setCompactSerialization(jwsCompactSerialization);
        JsonWebKey jwk = JsonWebKey.Factory.newJwk(jwkJson);
        jws.setKey(jwk.getKey());
        assertThat(jws.verifySignature(), is(true));
        assertThat(jws.getPayload(), equalTo(jwsPayload));
        assertThat(jws.getKeyIdHeaderValue(), equalTo(jwk.getKeyId()));
        assertThat(alg, equalTo(jws.getAlgorithmHeaderValue()));

        // verify reproducing it
View Full Code Here

        JsonWebSignature jws = new JsonWebSignature();
        jws.setCompactSerialization(detachedCs);
        JsonWebKey jwk = JsonWebKey.Factory.newJwk(jwkJsonString);
        jws.setKey(jwk.getKey());
        jws.setEncodedPayload(encodedJwsPayload);
        assertThat(jws.verifySignature(), is(true));
        assertThat(jws.getPayload(), equalTo(jwsPayload));

        // verify reproducing it (it's just luck that using the setters for the headers results in the exact same
        // JSON representation of the header)
        jws = new JsonWebSignature();
View Full Code Here

                PublicJsonWebKey sigJwk = PublicJsonWebKey.Factory.newPublicJwk(sigJwkJson);

                JsonWebSignature jws = new JsonWebSignature();
                jws.setCompactSerialization(jwePayload);
                jws.setKey(sigJwk.getPublicKey());
                assertTrue(jws.verifySignature());
                String payload = jws.getPayload();
                assertThat(expectedPayload, equalTo(payload));
            }
        });
    }
View Full Code Here

    // Here we use an example from the JWS spec
    PublicKey publicKey = ExampleEcKeysFromJws.PUBLIC_256;
    jws.setKey(publicKey);

    // Check the signature
    boolean signatureVerified = jws.verifySignature();

    // Do something useful with the result of signature verification
    System.out.println("JWS Signature is valid: " + signatureVerified);

    // Get the payload, or signed content, from the JWS
View Full Code Here

    // The verification key on the JWS is the public key from the JWK we pulled from the JWK Set.
    jws.setKey(jwk.getKey());

    // Check the signature
    boolean signatureVerified = jws.verifySignature();

    // Do something useful with the result of signature verification
    System.out.println("JWS Signature is valid: " + signatureVerified);

    // Get the payload, or signed content, from the JWS
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.