Package com.nimbusds.jose

Examples of com.nimbusds.jose.JWSHeader$Builder



  public void testCritHeaderParamReject()
    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



  public void testSignAndVerify()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

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

    JWSObject jwsObject = new JWSObject(header, payload);

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


  public void testVerifyWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

    JWSVerifier verifier =  new ECDSAVerifier(new BigInteger(1, x), new BigInteger(1, y));

    boolean verified = verifier.verify(header, signable, b64sig);
View Full Code Here

  public void testPassMissingCritHeader() {

    CriticalHeaderParameterChecker checker = new CriticalHeaderParameterChecker();

    JWSHeader header = new JWSHeader(JWSAlgorithm.RS256);
    header.setKeyID("1");

    assertTrue(checker.headerPasses(header));
  }
View Full Code Here

  public void testPassIgnoredCritParams() {

    CriticalHeaderParameterChecker checker = new CriticalHeaderParameterChecker();
    checker.getIgnoredCriticalHeaders().add("exp");

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

    assertTrue(checker.headerPasses(header));
  }
View Full Code Here

  public void testReject() {

    CriticalHeaderParameterChecker checker = new CriticalHeaderParameterChecker();

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

    assertFalse(checker.headerPasses(header));
  }
View Full Code Here


  public void testSignAndVerify()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

    assertEquals("HS256 alg check", JWSAlgorithm.HS256, header.getAlgorithm());
    assertEquals("JWT type check", new JOSEObjectType("JWT"), header.getType());

    JWSObject jwsObject = new JWSObject(header, payload);

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

    // Create HMAC signer
    JWSSigner signer = new MACSigner(sharedSecret);

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

  public void testSignAndVerifyWithStringSecret()
    throws Exception {

    final String stringSecret = "3eae8196ad1b";

    JWSHeader header = new JWSHeader(JWSAlgorithm.HS512);

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

    JWSObject jwsObject = new JWSObject(header, payload);

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


  public void testSignWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

    JWSSigner signer = new MACSigner(sharedSecret);

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

TOP

Related Classes of com.nimbusds.jose.JWSHeader$Builder

Copyright © 2018 www.massapicom. 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.