From: Marian Adamjak Date: Wed, 29 Oct 2014 08:45:55 +0000 (+0100) Subject: Maintaining code - remove unused class SslTrustManagerFactory X-Git-Tag: release/lithium~86 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f864f45157b43242cfaeb4ec53a2e81f9f3b6c5b;p=openflowjava.git Maintaining code - remove unused class SslTrustManagerFactory Change-Id: I24a35c5c3ad6a06a27599f689f3de72ab1a47cc1 Signed-off-by: Marian Adamjak --- diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java deleted file mode 100644 index 14f970cc..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import javax.net.ssl.ManagerFactoryParameters; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactorySpi; -import javax.net.ssl.X509TrustManager; -import java.security.InvalidAlgorithmParameterException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.cert.X509Certificate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author michal.polkorab - */ -public class SslTrustManagerFactory extends TrustManagerFactorySpi { - - /** - * Logger for SslTrustManagerFactory - */ - public static final Logger LOGGER = LoggerFactory.getLogger(SslTrustManagerFactory.class); - private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() { - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) { - LOGGER.warn("UNKNOWN CLIENT CERTIFICATE: {}", chain[0].getSubjectDN()); - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - LOGGER.warn("UNKNOWN SERVER CERTIFICATE: {}", chain[0].getSubjectDN()); - } - }; - - /** - * Getter for TrustManagers - * - * @return TrustManager[] - */ - public static TrustManager[] getTrustManagers() { - return new TrustManager[]{DUMMY_TRUST_MANAGER}; - } - - @Override - protected TrustManager[] engineGetTrustManagers() { - return getTrustManagers(); - } - - @Override - protected void engineInit(KeyStore ks) throws KeyStoreException { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - protected void engineInit(ManagerFactoryParameters mfp) throws InvalidAlgorithmParameterException { - throw new UnsupportedOperationException("Not supported yet."); - } -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java deleted file mode 100644 index 23362840..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.security.cert.X509Certificate; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; - -/** - * - * @author jameshall - */ -public class SslTrustManagerFactoryTest { - - /** - * Sets up test environment - */ - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * - */ - @Test - public void testGetTrustManagers() throws Exception { - TrustManager[] tmArray = SslTrustManagerFactory.getTrustManagers() ; - - assertNotNull( tmArray ); - for ( TrustManager tm : tmArray ) { - if ( tm.getClass() == X509TrustManager.class ) { - X509Certificate[] certsArray = ((X509TrustManager)tm).getAcceptedIssuers() ; - assertTrue( certsArray.length > 0 ) ; - - // Boolean caught = false; - // try { - // ((X509TrustManager)tm).checkClientTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; - // } catch (CertificateException ce) { - // caught = true ; - // } - // assertTrue( caught ) ; - // - // caught = false; - // try { - // ((X509TrustManager)tm).checkServerTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; - // } catch (CertificateException ce) { - // caught = true ; - // } - // assertTrue( caught ) ; - // } - } - } - } -} -