MockSignature Class — netty Architecture
Architecture documentation for the MockSignature class in MockAlternativeKeyProvider.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b["MockSignature"] f82e16e4_9173_4f05_5dfa_12b954c83e72["MockAlternativeKeyProvider.java"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|defined in| f82e16e4_9173_4f05_5dfa_12b954c83e72 1cb694d8_e5f1_d084_b01b_88908d025d7e["MockSignature()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| 1cb694d8_e5f1_d084_b01b_88908d025d7e 912599f1_10d8_c353_b611_7cd976399ad0["engineInitVerify()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| 912599f1_10d8_c353_b611_7cd976399ad0 c60a4e0d_f53d_cca4_8c61_6a03888275e3["engineInitSign()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| c60a4e0d_f53d_cca4_8c61_6a03888275e3 be0ab088_a5f5_88be_87c6_3484989d1e78["engineUpdate()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| be0ab088_a5f5_88be_87c6_3484989d1e78 92f531ff_af05_13fa_3659_70a8b2e97035["engineSign()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| 92f531ff_af05_13fa_3659_70a8b2e97035 0afcc759_0abd_ff8a_f12e_60a4e3002548["engineVerify()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| 0afcc759_0abd_ff8a_f12e_60a4e3002548 c1d46385_7570_37af_519e_f48e658ff42b["engineSetParameter()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| c1d46385_7570_37af_519e_f48e658ff42b 92b73f1e_1971_e67e_72a4_89220ba1b347["Object()"] 2c7e74e2_b1bc_0ac6_7d6f_396a50aa764b -->|method| 92b73f1e_1971_e67e_72a4_89220ba1b347
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/MockAlternativeKeyProvider.java lines 114–206
public abstract static class MockSignature extends SignatureSpi {
protected final String algorithm;
protected final String providerName;
protected final Signature realSignature;
protected MockSignature(String algorithm, String providerName)
throws NoSuchProviderException, NoSuchAlgorithmException {
this.algorithm = algorithm;
this.providerName = providerName;
this.realSignature = Signature.getInstance(algorithm, providerName);
}
@Override
protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
try {
realSignature.initVerify(publicKey);
} catch (Exception e) {
throw new InvalidKeyException("Failed to initialize signature", e);
}
}
@Override
protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
engineInitSign(privateKey, null);
}
@Override
protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException {
try {
// Extract the real key if it's wrapped
if (privateKey instanceof AlternativePrivateKeyWrapper) {
privateKey = ((AlternativePrivateKeyWrapper) privateKey).getDelegate();
realSignature.initSign(privateKey, random);
} else {
throw new InvalidKeyException("Unrecognized key type: " + privateKey.getClass().getName());
}
} catch (Exception e) {
throw new InvalidKeyException("Failed to initialize signature", e);
}
}
@Override
protected void engineUpdate(byte b) throws SignatureException {
realSignature.update(b);
}
@Override
protected void engineUpdate(byte[] b, int off, int len) throws SignatureException {
realSignature.update(b, off, len);
}
@Override
protected byte[] engineSign() throws SignatureException {
// Track signature operations
signatureOperations.incrementAndGet();
return realSignature.sign();
}
@Override
protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
return realSignature.verify(sigBytes);
}
@Override
protected void engineSetParameter(String param, Object value) {
try {
realSignature.setParameter(param, value);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
try {
realSignature.setParameter(params);
} catch (InvalidAlgorithmParameterException e) {
throw e;
} catch (Exception e) {
throw new InvalidAlgorithmParameterException("Failed to set parameter", e);
Source
Frequently Asked Questions
What is the MockSignature class?
MockSignature is a class in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/MockAlternativeKeyProvider.java.
Where is MockSignature defined?
MockSignature is defined in handler/src/test/java/io/netty/handler/ssl/MockAlternativeKeyProvider.java at line 114.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free