Search in sources :

Example 1 with AlgorithmConstraints

use of java.security.AlgorithmConstraints in project netty by netty.

the class OpenSslEngineTest method testAlgorithmConstraintsThrows.

@Test(expected = IllegalArgumentException.class)
public void testAlgorithmConstraintsThrows() throws Exception {
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    serverSslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).sslProvider(sslServerProvider()).build();
    SSLEngine engine = serverSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT);
    try {
        SSLParameters parameters = new SSLParameters();
        parameters.setAlgorithmConstraints(new AlgorithmConstraints() {

            @Override
            public boolean permits(Set<CryptoPrimitive> primitives, String algorithm, AlgorithmParameters parameters) {
                return false;
            }

            @Override
            public boolean permits(Set<CryptoPrimitive> primitives, Key key) {
                return false;
            }

            @Override
            public boolean permits(Set<CryptoPrimitive> primitives, String algorithm, Key key, AlgorithmParameters parameters) {
                return false;
            }
        });
        engine.setSSLParameters(parameters);
    } finally {
        cleanupServerSslEngine(engine);
        ssc.delete();
    }
}
Also used : SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) CryptoPrimitive(java.security.CryptoPrimitive) SSLParameters(javax.net.ssl.SSLParameters) SSLEngine(javax.net.ssl.SSLEngine) Key(java.security.Key) AlgorithmConstraints(java.security.AlgorithmConstraints) AlgorithmParameters(java.security.AlgorithmParameters) Test(org.junit.Test)

Aggregations

SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)1 AlgorithmConstraints (java.security.AlgorithmConstraints)1 AlgorithmParameters (java.security.AlgorithmParameters)1 CryptoPrimitive (java.security.CryptoPrimitive)1 Key (java.security.Key)1 SSLEngine (javax.net.ssl.SSLEngine)1 SSLParameters (javax.net.ssl.SSLParameters)1 Test (org.junit.Test)1