private Optional<String> validateRsaSha256(SecurityEnvironment env, InboundClientDefinition clientDefinition) { try { Signature signature = Signature.getInstance("SHA256withRSA"); signature.initVerify(clientDefinition.keyConfig() .orElseThrow(() -> new HttpSignatureException("RSA public key configuration is " + "required")) .publicKey() .orElseThrow(() -> new HttpSignatureException( "Public key is required, yet not configured"))); signature.update(getBytesToSign(env, null)); if (!signature.verify(this.signatureBytes)) { return Optional.of("Signature is not valid"); } return Optional.empty(); } catch (NoSuchAlgorithmException e) { LOGGER.log(Level.FINEST, "SHA256withRSA algorithm not found", e); return Optional.of("SHA256withRSA algorithm not found: " + e.getMessage()); } catch (InvalidKeyException e) { LOGGER.log(Level.FINEST, "Invalid RSA key", e); return Optional.of("Invalid RSA key: " + e.getMessage()); } catch (SignatureException e) { LOGGER.log(Level.FINEST, "Signature exception", e); return Optional.of("SignatureException: " + e.getMessage()); } }
public synchronized byte[] getSender() { try { if (sendAddress == null && getSignature() != null) { sendAddress = ECKey.signatureToAddress(getRawHash(), getSignature()); } return sendAddress; } catch (SignatureException e) { logger.error(e.getMessage(), e); } return null; }
@Override public byte[] sign(byte[] data) { try { return doSign(data); } catch (InvalidKeyException e) { throw new SignatureException("Invalid RSA PrivateKey. " + e.getMessage(), e); } catch (java.security.SignatureException e) { throw new SignatureException("Unable to calculate signature using RSA PrivateKey. " + e.getMessage(), e); } }
@Override public byte[] sign(byte[] data) { try { return doSign(data); } catch (InvalidKeyException e) { throw new SignatureException("Invalid Elliptic Curve PrivateKey. " + e.getMessage(), e); } catch (java.security.SignatureException e) { throw new SignatureException("Unable to calculate signature using Elliptic Curve PrivateKey. " + e.getMessage(), e); } catch (JwtException e) { throw new SignatureException("Unable to convert signature to JOSE format. " + e.getMessage(), e); } }
@Override public void write(final byte[] bytes) throws IOException { try { signer.update(bytes); } catch (SignatureException ex) { throw new IOException(ex.getMessage(), ex); } }
@Override public void write(byte[] b, int off, int len) throws IOException { try { sig.update(b, off, len); out.write(b, off, len); } catch (SignatureException e) { throw (IOException) new IOException(e.getMessage()).initCause(e); } } }
@Override public void write(int b) throws IOException { try { sig.update((byte)b); out.write(b); } catch (SignatureException e) { throw (IOException)new IOException(e.getMessage()).initCause(e); } }
public void write(byte[] bytes, int off, int len) throws IOException { try { sig.update(bytes, off, len); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes) throws IOException { try { sig.update(bytes); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(int b) throws IOException { try { sig.update((byte)b); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(int b) throws IOException { try { sig.update((byte)b); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes) throws IOException { try { sig.update(bytes); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes, int off, int len) throws IOException { try { sig.update(bytes, off, len); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes) throws IOException { try { sig.update(bytes); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes) throws IOException { try { sig.update(bytes); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public void write(byte[] bytes) throws IOException { try { sig.update(bytes); } catch (SignatureException e) { throw new OperatorStreamException("exception in content signer: " + e.getMessage(), e); } }
public byte[] getSignature() { try { return stream.getSignature(); } catch (SignatureException e) { throw new RuntimeOperatorException("exception obtaining signature: " + e.getMessage(), e); } } };
@Override public byte[] getSignature() { try { return stream.getSignature(); } catch (SignatureException ex) { throw new RuntimeOperatorException("exception obtaining signature: " + ex.getMessage(), ex); } }
@Override public byte[] sign(byte[] data) { try { return doSign(data); } catch (InvalidKeyException e) { throw new SignatureException("Invalid RSA PrivateKey. " + e.getMessage(), e); } catch (java.security.SignatureException e) { throw new SignatureException("Unable to calculate signature using RSA PrivateKey. " + e.getMessage(), e); } }
@Override public byte[] sign(byte[] data) { try { return doSign(data); } catch (InvalidKeyException e) { throw new SignatureException("Invalid RSA PrivateKey. " + e.getMessage(), e); } catch (java.security.SignatureException e) { throw new SignatureException("Unable to calculate signature using RSA PrivateKey. " + e.getMessage(), e); } }