Examples of MACSigner


Examples of com.nimbusds.jose.crypto.MACSigner

  public void testRejectSoftwareStatementWithoutIssuer()
    throws Exception {

    SignedJWT jwt = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), new JWTClaimsSet());
    jwt.sign(new MACSigner("abcdef1234567890"));

    ClientMetadata metadata = new ClientMetadata();
    metadata.setRedirectionURI(new URI("https://client.com/in"));
    metadata.setName("Test App");
View Full Code Here

Examples of com.nimbusds.jose.crypto.MACSigner

    claim.setSubject(Long.toString(sub));
    claim.setIssuer(host);
    claim.setIssueTime(DateTime.now().toDate());
    claim.setExpirationTime(DateTime.now().plusDays(14).toDate());
   
    JWSSigner signer = new MACSigner(TOKEN_SECRET);
    SignedJWT jwt = new SignedJWT(JWT_HEADER, claim);
    jwt.sign(signer);
   
    return new Token(jwt.serialize());
  }
View Full Code Here

Examples of com.nimbusds.jose.crypto.MACSigner

    // Create HMAC signer
    String sharedKey = "a0a2abd8-6162-41c3-83d6-1cf559b46afc";
   
    System.out.println("HMAC key: " + sharedKey);
   
    JWSSigner signer = new MACSigner(sharedKey.getBytes());
   
    try {
      jwsObject.sign(signer);
     
    } catch (JOSEException e) {
View Full Code Here

Examples of com.nimbusds.jose.crypto.MACSigner

    header.setKeyID("1");

    assertTrue(signingInput.equals(Base64URL.encode(jwsObject.getSigningInput())));

    jwsObject.sign(new MACSigner("1234567890abc"));

    String output = jwsObject.serialize();

    header.setKeyID("2");
View Full Code Here

Examples of org.springframework.security.jwt.crypto.sign.MacSigner

      logger.info("Configured with RSA signing key");
    }
    else {
      // Assume it's a MAC key
      this.verifierKey = key;
      signer = new MacSigner(key);
    }
  }
View Full Code Here

Examples of org.springframework.security.jwt.crypto.sign.MacSigner

      throw new InvalidTokenException("Cannot convert access token to JSON", e);
    }
  }

  public void afterPropertiesSet() throws Exception {
    SignatureVerifier verifier = new MacSigner(verifierKey);
    try {
      verifier = new RsaVerifier(verifierKey);
    }
    catch (Exception e) {
      logger.warn("Unable to create an RSA verifier from verifierKey (ignoreable if using MAC)");
    }
    // Check the signing and verification keys match
    if (signer instanceof RsaSigner) {
      byte[] test = "test".getBytes();
      try {
        verifier.verify(test, signer.sign(test));
        logger.info("Signing and verification RSA keys match");
      }
      catch (InvalidSignatureException e) {
        logger.error("Signing and verification RSA keys do not match");
      }
View Full Code Here

Examples of org.springframework.security.jwt.crypto.sign.MacSigner

    JwtHelper.decode(JOE_HMAC_TOKEN).verifySignature(hmac);
  }

  @Test(expected=InvalidSignatureException.class)
  public void invalidHmacSignatureRaisesException() {
    JwtHelper.decode(JOE_HMAC_TOKEN).verifySignature(new MacSigner("differentkey".getBytes()));
  }
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.