ECDSASigner signer = new ECDSASigner((ECKey) jwk); signers.put(id, signer);
@VisibleForTesting protected JWSSigner createECDSASignerForKey(ECPrivateKey privateKey) { return new ECDSASigner(privateKey.getS()); }
public static JWSSigner findSigner(KeyAndJwk randomKey) throws JOSEException{ if(randomKey.jwk instanceof RSAKey){ return new RSASSASigner((RSAKey)randomKey.jwk); } else if (randomKey.jwk instanceof ECKey){ return new ECDSASigner((ECKey)randomKey.jwk); } else if (randomKey.jwk instanceof OctetSequenceKey){ return new MACSigner((OctetSequenceKey)randomKey.jwk); } else { throw new IllegalStateException("Unknown key type: " + randomKey.jwk.getClass().getName()); } } }
if(algoPrefs==null) algoPrefs = JWSAlgorithm.Family.EC; jwsAlgorithm = selectAlgoPref(JWSAlgorithm.Family.EC, algoPrefs); if(jwsAlgorithm!=null)signer = new ECDSASigner((ECKey) jwk); } else if (jwk instanceof OctetSequenceKey){ if(algoPrefs==null) algoPrefs = JWSAlgorithm.Family.HMAC_SHA;
private JWSSigner createSigner() throws KrbException { // Create signer with the private key if (RSASSASigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof RSAPrivateKey)) { throw new KrbException("An RSAPrivateKey key must be specified for signature"); } return new RSASSASigner((RSAPrivateKey) signKey); } else if (ECDSASigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof ECPrivateKey)) { throw new KrbException("A ECPrivateKey key must be specified for signature"); } try { return new ECDSASigner((ECPrivateKey) signKey); } catch (JOSEException e) { throw new KrbException(e.getMessage(), e); } } else if (MACSigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof byte[])) { throw new KrbException("A byte[] key must be specified for signature"); } try { return new MACSigner((byte[]) signKey); } catch (KeyLengthException e) { throw new KrbException(e.getMessage(), e); } } throw new KrbException("An unknown signature algorithm was specified"); }
@Override public SignedJWT sign(JWTClaimsSet claims) { init(); CommonHelper.assertNotNull("privateKey", privateKey); try { final JWSSigner signer = new ECDSASigner(this.privateKey); final SignedJWT signedJWT = new SignedJWT(new JWSHeader(algorithm), claims); signedJWT.sign(signer); return signedJWT; } catch (final JOSEException e) { throw new TechnicalException(e); } }
private JWSSigner createSigner() throws KrbException { // Create signer with the private key if (RSASSASigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof RSAPrivateKey)) { throw new KrbException("An RSAPrivateKey key must be specified for signature"); } return new RSASSASigner((RSAPrivateKey) signKey); } else if (ECDSASigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof ECPrivateKey)) { throw new KrbException("A ECPrivateKey key must be specified for signature"); } try { return new ECDSASigner((ECPrivateKey) signKey); } catch (JOSEException e) { throw new KrbException(e.getMessage(), e); } } else if (MACSigner.SUPPORTED_ALGORITHMS.contains(jwsAlgorithm)) { if (!(signKey instanceof byte[])) { throw new KrbException("A byte[] key must be specified for signature"); } try { return new MACSigner((byte[]) signKey); } catch (KeyLengthException e) { throw new KrbException(e.getMessage(), e); } } throw new KrbException("An unknown signature algorithm was specified"); }