Examples of JWSSigner


Examples of com.nimbusds.jose.JWSSigner

  public void signJwt(SignedJWT jwt) {
    if (getDefaultSignerKeyId() == null) {
      throw new IllegalStateException("Tried to call default signing with no default signer ID set");
    }

    JWSSigner signer = signers.get(getDefaultSignerKeyId());

    try {
      jwt.sign(signer);
    } catch (JOSEException e) {
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

  }

  @Override
  public void signJwt(SignedJWT jwt, JWSAlgorithm alg) {

    JWSSigner signer = null;

    for (JWSSigner s : signers.values()) {
      if (s.supportedAlgorithms().contains(alg)) {
        signer = s;
        break;
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

    // Create JWS object
    JWSObject jwsObject = new JWSObject(header, new Payload(jwtClaims.toJSONObject()));

    // Create HMAC signer
    JWSSigner signer = new MACSigner(SHARED_KEY.getBytes());

    try {
      jwsObject.sign(signer);
    } catch(com.nimbusds.jose.JOSEException e) {
      System.err.println("Error signing JWT: " + e.getMessage());
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

    SecureRandom random = new SecureRandom();
    byte[] sharedSecret = new byte[32];
    random.nextBytes(sharedSecret);

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

Examples of com.nimbusds.jose.JWSSigner

  public void testSignWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(b64header);

    JWSSigner signer = new MACSigner(sharedSecret);

    Base64URL b64sigComputed = signer.sign(header, signable);

    assertEquals("Signature check", b64sig, b64sigComputed);
  }
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

  public void testSignWithReadyVector()
    throws Exception {

    JWSHeader header = JWSHeader.parse(B64_HEADER);

    JWSSigner signer = new RSASSASigner(PRIVATE_KEY);

    Base64URL b64sigComputed = signer.sign(header, SIGNABLE);

    assertEquals("Signature check", B64_SIG, b64sigComputed);
  }
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

    KeyPair kp = keyGenerator.genKeyPair();
    RSAPublicKey publicKey = (RSAPublicKey)kp.getPublic();
    RSAPrivateKey privateKey = (RSAPrivateKey)kp.getPrivate();

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

Examples of com.nimbusds.jose.JWSSigner

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

Examples of com.nimbusds.jose.JWSSigner

    // Creates initial unsigned JWS object
    JWSObject jwsObject = createInitialJWSObject(JWSAlgorithm.ES256);

    // Initialise signer
    JWSSigner signer = new ECDSASigner(privateKey.getS());

    jwsObject.sign(signer);

    assertEquals(JWSObject.State.SIGNED, jwsObject.getState());
View Full Code Here

Examples of com.nimbusds.jose.JWSSigner

    // Creates initial unsigned JWS object
    JWSObject jwsObject = createInitialJWSObject(JWSAlgorithm.ES384);

    // Initialise signer
    JWSSigner signer = new ECDSASigner(privateKey.getS());

    jwsObject.sign(signer);

    assertEquals(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.