Home / File/ MockAlternativeKeyProvider.java — netty Source File

MockAlternativeKeyProvider.java — netty Source File

Architecture documentation for MockAlternativeKeyProvider.java, a java file in the netty codebase.

File java Buffer Allocators 13 classes

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2025 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.handler.ssl;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.SignatureSpi;
import java.security.spec.AlgorithmParameterSpec;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * A mock security provider that simulates alternative key providers (HSMs, smart cards, etc.)
 * by wrapping a real RSA key but returning null from getEncoded() while delegating all
 * cryptographic operations to the underlying JDK implementation.
 */
public final class MockAlternativeKeyProvider extends Provider {

    private static final String PROVIDER_NAME = "MockAlternativeKeyProvider";
    private static final double PROVIDER_VERSION = 1.0;
    private static final String PROVIDER_INFO = "Mock provider simulating alternative key providers";

    // Track signature operations for test verification
    private static final AtomicInteger signatureOperations = new AtomicInteger(0);

    MockAlternativeKeyProvider() {
        super(PROVIDER_NAME, PROVIDER_VERSION, PROVIDER_INFO);

        // Register RSA signature algorithms
        put("Signature.RSASSA-PSS", MockRsaPssSignature.class.getName());
        put("Signature.SHA1withRSA", MockSha1WithRsaSignature.class.getName());
        put("Signature.SHA256withRSA", MockSha256WithRsaSignature.class.getName());
        put("Signature.SHA384withRSA", MockSha384WithRsaSignature.class.getName());
        put("Signature.SHA512withRSA", MockSha512WithRsaSignature.class.getName());
        put("Signature.MD5withRSA", MockMd5WithRsaSignature.class.getName());

        // Register ECDSA signature algorithms
        put("Signature.SHA1withECDSA", MockSha1WithEcdsaSignature.class.getName());
        put("Signature.SHA256withECDSA", MockSha256WithEcdsaSignature.class.getName());
        put("Signature.SHA384withECDSA", MockSha384WithEcdsaSignature.class.getName());
// ... (210 more lines)

Domain

Subdomains

Frequently Asked Questions

What does MockAlternativeKeyProvider.java do?
MockAlternativeKeyProvider.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is MockAlternativeKeyProvider.java in the architecture?
MockAlternativeKeyProvider.java is located at handler/src/test/java/io/netty/handler/ssl/MockAlternativeKeyProvider.java (domain: Buffer, subdomain: Allocators, directory: handler/src/test/java/io/netty/handler/ssl).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free