+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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 ) ;
- // }
- }
- }
- }
-}
-