Examples of JWSHeader


Examples of com.nimbusds.jose.JWSHeader

  }


  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

Examples of com.nimbusds.jose.JWSHeader


  public void testCritHeaderParamIgnore()
    throws Exception {

    JWSHeader header = new JWSHeader(JWSAlgorithm.ES512);
    header.setCustomParameter("exp", "2014-04-24");
    header.setCriticalHeaders(new HashSet<String>(Arrays.asList("exp")));

    KeyPair keyPair = createECKeyPair(EC512SPEC);
    ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
    ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader


  public void testCritHeaderParamReject()
    throws Exception {

    JWSHeader header = new JWSHeader(JWSAlgorithm.ES512);
    header.setCustomParameter("exp", "2014-04-24");
    header.setCriticalHeaders(new HashSet<String>(Arrays.asList("exp")));

    KeyPair keyPair = createECKeyPair(EC512SPEC);
    ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
    ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader


  public void testSignAndVerify()
    throws Exception {

    JWSHeader header = JWSHeader.parse(B64_HEADER);

    assertEquals("RS256 alg check", JWSAlgorithm.RS256, header.getAlgorithm());

    JWSObject jwsObject = new JWSObject(header, PAYLOAD);

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

Examples of com.nimbusds.jose.JWSHeader


  public void testSignWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(B64_HEADER);

    JWSSigner signer = new RSASSASigner(PRIVATE_KEY);

    Base64URL b64sigComputed = signer.sign(header, SIGNABLE);
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader


  public void testVerifyWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(B64_HEADER);

    JWSVerifier verifier = new RSASSAVerifier(PUBLIC_KEY);

    boolean verified = verifier.verify(header, SIGNABLE, B64_SIG);
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader


  public void testSignAndVerifyCycle(final JWSAlgorithm alg, final JWSSigner signer, final JWSVerifier verifier)
    throws Exception {

    JWSHeader header = new JWSHeader(alg);

    JWSObject jwsObject = new JWSObject(header, PAYLOAD);

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

Examples of com.nimbusds.jose.JWSHeader

    // Create RSA-signer with the private key
    JWSSigner signer = new RSASSASigner(privateKey);

    // 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));
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader

    KeyPair keyPair = keyGen.genKeyPair();
    RSAPublicKey rsaPublicKey = (RSAPublicKey)keyPair.getPublic();
    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();

    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));
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader


  public void testCritHeaderParamIgnore()
    throws Exception {

    JWSHeader header = new JWSHeader(JWSAlgorithm.RS256);
    header.setCustomParameter("exp", "2014-04-24");
    header.setCriticalHeaders(new HashSet<String>(Arrays.asList("exp")));

    JWSObject jwsObject = new JWSObject(header, PAYLOAD);

    RSASSASigner signer = new RSASSASigner(PRIVATE_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.