use of org.xdi.oxauth.model.jws.ECDSASigner in project oxAuth by GluuFederation.
the class SignatureTest method generateES384Keys.
@Test
public void generateES384Keys() throws Exception {
showTitle("TEST: generateES384Keys");
KeyFactory<ECDSAPrivateKey, ECDSAPublicKey> keyFactory = new ECDSAKeyFactory(SignatureAlgorithm.ES384, "CN=Test CA Certificate");
Key<ECDSAPrivateKey, ECDSAPublicKey> key = keyFactory.getKey();
ECDSAPrivateKey privateKey = key.getPrivateKey();
ECDSAPublicKey publicKey = key.getPublicKey();
Certificate certificate = key.getCertificate();
System.out.println(key);
String signingInput = "Hello World!";
ECDSASigner ecdsaSigner1 = new ECDSASigner(SignatureAlgorithm.ES384, privateKey);
String signature = ecdsaSigner1.generateSignature(signingInput);
ECDSASigner ecdsaSigner2 = new ECDSASigner(SignatureAlgorithm.ES384, publicKey);
assertTrue(ecdsaSigner2.validateSignature(signingInput, signature));
ECDSASigner ecdsaSigner3 = new ECDSASigner(SignatureAlgorithm.ES384, certificate);
assertTrue(ecdsaSigner3.validateSignature(signingInput, signature));
}
use of org.xdi.oxauth.model.jws.ECDSASigner in project oxAuth by GluuFederation.
the class SignatureTest method generateES256Keys.
@Test
public void generateES256Keys() throws Exception {
showTitle("TEST: generateES256Keys");
KeyFactory<ECDSAPrivateKey, ECDSAPublicKey> keyFactory = new ECDSAKeyFactory(SignatureAlgorithm.ES256, "CN=Test CA Certificate");
Key<ECDSAPrivateKey, ECDSAPublicKey> key = keyFactory.getKey();
ECDSAPrivateKey privateKey = key.getPrivateKey();
ECDSAPublicKey publicKey = key.getPublicKey();
Certificate certificate = key.getCertificate();
System.out.println(key);
String signingInput = "Hello World!";
ECDSASigner ecdsaSigner1 = new ECDSASigner(SignatureAlgorithm.ES256, privateKey);
String signature = ecdsaSigner1.generateSignature(signingInput);
ECDSASigner ecdsaSigner2 = new ECDSASigner(SignatureAlgorithm.ES256, publicKey);
assertTrue(ecdsaSigner2.validateSignature(signingInput, signature));
ECDSASigner ecdsaSigner3 = new ECDSASigner(SignatureAlgorithm.ES256, certificate);
assertTrue(ecdsaSigner3.validateSignature(signingInput, signature));
}
Aggregations