本文整理匯總了Java中com.digitalpetri.opcua.stack.core.util.SignatureUtil.sign方法的典型用法代碼示例。如果您正苦於以下問題:Java SignatureUtil.sign方法的具體用法?Java SignatureUtil.sign怎麽用?Java SignatureUtil.sign使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.digitalpetri.opcua.stack.core.util.SignatureUtil
的用法示例。
在下文中一共展示了SignatureUtil.sign方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getServerSignature
import com.digitalpetri.opcua.stack.core.util.SignatureUtil; //導入方法依賴的package包/類
private SignatureData getServerSignature(ByteString clientNonce,
ByteString clientCertificate,
SecurityPolicy securityPolicy,
KeyPair keyPair) throws UaException {
if (clientNonce.isNull() || clientCertificate.isNull() || keyPair == null) {
return new SignatureData(null, null);
}
try {
SecurityAlgorithm algorithm = securityPolicy.getAsymmetricSignatureAlgorithm();
byte[] data = Bytes.concat(clientCertificate.bytes(), clientNonce.bytes());
byte[] signature = SignatureUtil.sign(
algorithm,
keyPair.getPrivate(),
ByteBuffer.wrap(data)
);
return new SignatureData(algorithm.getUri(), ByteString.of(signature));
} catch (UaRuntimeException e) {
throw new UaException(StatusCodes.Bad_SecurityChecksFailed);
}
}
示例2: signChunk
import com.digitalpetri.opcua.stack.core.util.SignatureUtil; //導入方法依賴的package包/類
@Override
public byte[] signChunk(SecureChannel channel, ByteBuffer chunkNioBuffer) throws UaException {
return SignatureUtil.sign(
channel.getSecurityPolicy().getAsymmetricSignatureAlgorithm(),
channel.getKeyPair().getPrivate(),
chunkNioBuffer
);
}