Search in sources :

Example 1 with SimpleSigner

use of com.bluenimble.platform.crypto.signer.impl.SimpleSigner in project serverless by bluenimble.

the class SignVerifyDocumentWithKey method main.

public static void main(String[] args) throws StoreLoaderException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException, SignerException, IOException {
    Signer signer = new SimpleSigner();
    Key key = new StringKey("mykey", Algorithm.HmacSHA1);
    StringSignatureAwareSecureDocument doc = new StringSignatureAwareSecureDocument("a document to sign");
    doc.setKey(key);
    signer.sign(doc, key, null);
    System.out.println(new String(doc.getSignature(), DefaultSigner.BASE64_ENCODING));
    signer.verify(doc, null);
    System.out.println(new String(doc.getBytes()));
}
Also used : DefaultSigner(com.bluenimble.platform.crypto.signer.impl.DefaultSigner) Signer(com.bluenimble.platform.crypto.signer.Signer) SimpleSigner(com.bluenimble.platform.crypto.signer.impl.SimpleSigner) StringSignatureAwareSecureDocument(com.bluenimble.platform.crypto.signer.impl.StringSignatureAwareSecureDocument) SimpleSigner(com.bluenimble.platform.crypto.signer.impl.SimpleSigner) StringKey(com.bluenimble.platform.crypto.signer.StringKey) StringKey(com.bluenimble.platform.crypto.signer.StringKey) Key(java.security.Key)

Aggregations

Signer (com.bluenimble.platform.crypto.signer.Signer)1 StringKey (com.bluenimble.platform.crypto.signer.StringKey)1 DefaultSigner (com.bluenimble.platform.crypto.signer.impl.DefaultSigner)1 SimpleSigner (com.bluenimble.platform.crypto.signer.impl.SimpleSigner)1 StringSignatureAwareSecureDocument (com.bluenimble.platform.crypto.signer.impl.StringSignatureAwareSecureDocument)1 Key (java.security.Key)1