Examples of JWSHeader


Examples of com.nimbusds.jose.JWSHeader


  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

Examples of com.nimbusds.jose.JWSHeader

    // 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

Examples of com.nimbusds.jose.JWSHeader

  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

Examples of com.nimbusds.jose.JWSHeader


  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

Examples of com.nimbusds.jose.JWSHeader


  public void testVerifyWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

    JWSVerifier verifier = new MACVerifier(sharedSecret);

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

Examples of com.nimbusds.jose.JWSHeader

  public void testCritHeaderParamIgnore()
    throws Exception {

    final String stringSecret = "3eae8196ad1b";

    JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.HS512).
      customParam("exp", "2014-04-24").
      criticalParams(new HashSet<>(Arrays.asList("exp"))).
      build();

    JWSObject jwsObject = new JWSObject(header, payload);
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader

  public void testCritHeaderParamReject()
    throws Exception {

    final String stringSecret = "3eae8196ad1b";

    JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.HS512).
      customParam("exp", "2014-04-24").
      criticalParams(new HashSet<>(Arrays.asList("exp"))).
      build();

    JWSObject jwsObject = new JWSObject(header, payload);
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader

    JWTClaimsSet claimsSet = claims.toJWTClaimsSet();

    Secret secret = new Secret();

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);

    jwt.sign(new MACSigner(secret.getValueBytes()));

    UserInfoSuccessResponse response = new UserInfoSuccessResponse(jwt);
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader

    claimsSet.setSubject("alice");
    claimsSet.setIssueTime(new Date(10000l));
    claimsSet.setExpirationTime(new Date(20000l));
    claimsSet.setClaim("nonce", "123");

    SignedJWT idToken = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);

    idToken.sign(new MACSigner("1234567890abcdef"));

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, null, idToken, null, new State("abc"));
View Full Code Here

Examples of com.nimbusds.jose.JWSHeader

    claimsSet.setSubject("alice");
    claimsSet.setIssueTime(new Date(10000l));
    claimsSet.setExpirationTime(new Date(20000l));
    claimsSet.setClaim("nonce", "123");

    SignedJWT idToken = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);

    idToken.sign(new MACSigner("1234567890abcdef"));

    AuthenticationSuccessResponse response = new AuthenticationSuccessResponse(
      REDIRECT_URI, code, idToken, null, new State("abc"));
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.