- .
(Java 7):
public void signRequest(Request request) throws APISignatureException {
try {
Signature s = Signature.getInstance("SHA1withRSA");
s.initSign(keyChain.getPrivateKey());
s.update(plainText.getBytes("UTF-8"));
byte[] signature = s.sign();
String signedData = base64Encoder.encode(signature);
}
catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException | SignatureException e) {
throw new APISignatureException("Failed to create signature", e);
}
}
, , .
, , :
public void signRequest(Request request) {
try {
Signature s = Signature.getInstance("SHA1withRSA");
s.initSign(keyChain.getPrivateKey());
s.update(plainText.getBytes("UTF-8"));
byte[] signature = s.sign();
String signedData = base64Encoder.encode(signature);
}
catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException | SignatureException e) {
throw new RuntimeException("Failed to create signature", e);
}
}
, , , , , , . . RuntimeException , .