@Test(expected = NullPointerException.class) public void signShouldThrowOnNullSource() throws Exception { signatureHandler.sign(null); }
@Override public String sign(String source) { Preconditions.checkNotNull(source); try { Signature javaSignature = Signature.getInstance(ALGORITHM); javaSignature.initSign(securityKeys.getPrivateKey()); javaSignature.update(source.getBytes()); return Base64.getEncoder().encodeToString(javaSignature.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new RuntimeException(e); } }
JamesSignatureHandler implements SignatureHandler { @Override public String sign(String source) { Preconditions.checkNotNull(source); try { Signature javaSignature = Signature.getInstance(ALGORITHM); javaSignature.initSign(securityKeys.getPrivateKey()); javaSignature.update(source.getBytes()); return Base64.getEncoder().encodeToString(javaSignature.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new RuntimeException(e); } } }
JamesSignatureHandler implements SignatureHandler { @Override public String sign(String source) { Preconditions.checkNotNull(source); try { Signature javaSignature = Signature.getInstance(ALGORITHM); javaSignature.initSign(securityKeys.getPrivateKey()); javaSignature.update(source.getBytes()); return Base64.getEncoder().encodeToString(javaSignature.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new RuntimeException(e); } } @Inject @VisibleForTesting  JamesSignatureHandler(SecurityKeyLoader keyLoader); }
JamesSignatureHandler implements SignatureHandler { @Override public String sign(String source) { Preconditions.checkNotNull(source); try { Signature javaSignature = Signature.getInstance(ALGORITHM); javaSignature.initSign(securityKeys.getPrivateKey()); javaSignature.update(source.getBytes()); return Base64.getEncoder().encodeToString(javaSignature.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new RuntimeException(e); } } @Inject @VisibleForTesting  JamesSignatureHandler(SecurityKeyLoader keyLoader); @Override void init(); @Override String sign(String source); @Override boolean verify(String source, String signature); }
JamesSignatureHandler implements SignatureHandler { @Override public String sign(String source) { Preconditions.checkNotNull(source); try { Signature javaSignature = Signature.getInstance(ALGORITHM); javaSignature.initSign(securityKeys.getPrivateKey()); javaSignature.update(source.getBytes()); return Base64.getEncoder().encodeToString(javaSignature.sign()); } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { throw new RuntimeException(e); } } @Inject @VisibleForTesting  JamesSignatureHandler(SecurityKeyLoader keyLoader); @Override void init(); @Override String sign(String source); @Override boolean verify(String source, String signature); static final String ALGORITHM; }