Package com.nimbusds.jose

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


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

    JWSVerifier verifier = new RSASSAVerifier(PUBLIC_KEY);

    boolean verified = jwsObject.verify(verifier);

    assertFalse("Signature check", verified);
  }

View Full Code Here


    jwsObject.sign(signer);

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

    assertTrue("Verify signature", jwsObject.verify(verifier));

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

    // Verify from serialised and then parsed JWS
    jwsObject = JWSObject.parse(jwsObject.serialize());
View Full Code Here

    // Verify from serialised and then parsed JWS
    jwsObject = JWSObject.parse(jwsObject.serialize());

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

    assertTrue("Verify signature", jwsObject.verify(verifier));

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

View Full Code Here

    // To parse the JWS and verify it, e.g. on client-side
    jwsObject = JWSObject.parse(s);

    JWSVerifier verifier = new RSASSAVerifier(publicKey);

    assertTrue(jwsObject.verify(verifier));

    assertEquals("In RSA we trust!", jwsObject.getPayload().toString());
  }

View Full Code Here

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

    // Verifier from raw Java RSA key
    JWSVerifier verifier = new RSASSAVerifier(rsaPublicKey);
    assertTrue(jwsObject1.verify(verifier));
    assertTrue(jwsObject2.verify(verifier));

    // Verifier from JWK representation
    verifier = new RSASSAVerifier(rsaJWK.toRSAPublicKey());
    assertTrue(jwsObject1.verify(verifier));
    assertTrue(jwsObject2.verify(verifier));
View Full Code Here

    assertTrue(jwsObject2.verify(verifier));

    // Verifier from JWK representation
    verifier = new RSASSAVerifier(rsaJWK.toRSAPublicKey());
    assertTrue(jwsObject1.verify(verifier));
    assertTrue(jwsObject2.verify(verifier));
  }


  public void testRS256CookbookExample()
    throws Exception {
View Full Code Here

    assertEquals(JWSAlgorithm.RS256, jwsObject.getHeader().getAlgorithm());
    assertEquals("bilbo.baggins@hobbiton.example", jwsObject.getHeader().getKeyID());

    JWSVerifier verifier = new RSASSAVerifier(jwk.toRSAPublicKey());

    assertTrue(jwsObject.verify(verifier));

    assertEquals("SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IH" +
      "lvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBk" +
      "b24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcm" +
      "UgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4", jwsObject.getPayload().toBase64URL().toString());
View Full Code Here

    assertEquals(JWSAlgorithm.PS384, jwsObject.getHeader().getAlgorithm());
    assertEquals("bilbo.baggins@hobbiton.example", jwsObject.getHeader().getKeyID());

    JWSVerifier verifier = new RSASSAVerifier(jwk.toRSAPublicKey());

    assertTrue(jwsObject.verify(verifier));

    assertEquals("SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IH" +
      "lvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBk" +
      "b24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcm" +
      "UgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4", jwsObject.getPayload().toBase64URL().toString());
View Full Code Here

    jwsObject.sign(signer);

    RSASSAVerifier verifier = new RSASSAVerifier(PUBLIC_KEY);
    verifier.getIgnoredCriticalHeaderParameters().add("exp");

    boolean verified = jwsObject.verify(verifier);

    assertTrue("Verified signature", verified);

    assertEquals("State check", JWSObject.State.VERIFIED, jwsObject.getState());
  }
View Full Code Here

    jwsObject.sign(signer);

    RSASSAVerifier verifier = new RSASSAVerifier(PUBLIC_KEY);

    boolean verified = jwsObject.verify(verifier);

    assertFalse("Verified signature", verified);

    assertEquals("State check", JWSObject.State.SIGNED, jwsObject.getState());
  }
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.