/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.remoting3.test; import java.net.URL; /** * * @author <a href="mailto:flavia.rainone@jboss.com">Flavia Rainone</a> */ public class SslHelper { private static final String KEY_STORE_PROPERTY = "javax.net.ssl.keyStore"; private static final String KEY_STORE_PASSWORD_PROPERTY = "javax.net.ssl.keyStorePassword"; private static final String TRUST_STORE_PROPERTY = "javax.net.ssl.trustStore"; private static final String TRUST_STORE_PASSWORD_PROPERTY = "javax.net.ssl.trustStorePassword"; private static final String DEFAULT_KEY_STORE = "keystore.jks"; private static final String DEFAULT_KEY_STORE_PASSWORD = "jboss-remoting-test"; public static void setKeyStoreAndTrustStore() { final URL storePath = RemoteSslChannelTest.class.getClassLoader().getResource(DEFAULT_KEY_STORE); if (System.getProperty(KEY_STORE_PROPERTY) == null) { System.setProperty(KEY_STORE_PROPERTY, storePath.getFile()); } if (System.getProperty(KEY_STORE_PASSWORD_PROPERTY) == null) { System.setProperty(KEY_STORE_PASSWORD_PROPERTY, DEFAULT_KEY_STORE_PASSWORD); } if (System.getProperty(TRUST_STORE_PROPERTY) == null) { System.setProperty(TRUST_STORE_PROPERTY, storePath.getFile()); } if (System.getProperty(TRUST_STORE_PASSWORD_PROPERTY) == null) { System.setProperty(TRUST_STORE_PASSWORD_PROPERTY, DEFAULT_KEY_STORE_PASSWORD); } } }