Commit 938c0f26 authored by Guus der Kinderen's avatar Guus der Kinderen

OF-946: Merge SSLConfig.Type with Purpose

parent 97f7cf3f
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,14 +63,14 @@ public class SSLProtocolSocketFactory implements SecureProtocolSocketFactory { ...@@ -63,14 +63,14 @@ public class SSLProtocolSocketFactory implements SecureProtocolSocketFactory {
private SSLContext createSSLContext(String host) { private SSLContext createSSLContext(String host) {
try { try {
final SSLContext context = SSLConfig.getSSLContext( SSLConfig.Type.ADMIN ); final SSLContext context = SSLConfig.getSSLContext( Purpose.ADMIN );
context.init( context.init(
null, null,
new TrustManager[] { new TrustManager[] {
new ClearspaceX509TrustManager( new ClearspaceX509TrustManager(
host, host,
manager.getProperties(), manager.getProperties(),
SSLConfig.getStore( Purpose.ADMINISTRATIVE_TRUSTSTORE ) ) SSLConfig.getTrustStore( Purpose.ADMIN ) )
}, },
null); null);
return context; return context;
......
...@@ -54,7 +54,7 @@ public abstract class CertificateStoreConfig ...@@ -54,7 +54,7 @@ public abstract class CertificateStoreConfig
{ {
try try
{ {
this.canonicalPath = SSLConfig.canonicalize( path ); this.canonicalPath = Purpose.canonicalize( path );
final File file = new File( canonicalPath ); final File file = new File( canonicalPath );
if ( createIfAbsent && !file.exists() ) if ( createIfAbsent && !file.exists() )
......
package org.jivesoftware.openfire.keystore; package org.jivesoftware.openfire.keystore;
import org.jivesoftware.util.JiveGlobals;
import java.io.File;
import java.io.IOException;
/** /**
* Potential intended usages for keystores * Potential intended usages (for TLS connectivity).
* *
* @author Guus der Kinderen, guus.der.kinderen@gmail.com * @author Guus der Kinderen, guus.der.kinderen@gmail.com
*/ */
public enum Purpose public enum Purpose
{ {
/** /**
* Identification of this Openfire instance used by regular socket-based connections. * Socket-based server-to-server (XMPP federation) connectivity.
*/ */
SOCKETBASED_IDENTITYSTORE( false ), SOCKET_S2S( "xmpp.socket.ssl.", null ),
/** /**
* Identification of remote servers that you choose to trust, applies to server-to-server federation via regular socket-based connections. * Socket-based client connectivity.
*/ */
SOCKETBASED_S2S_TRUSTSTORE( true ), SOCKET_C2S( "xmpp.socket.ssl.client.", null ),
/** /**
* Identification of clients that you choose to trust, applies to mutual authentication via regular socket-based connections. * BOSH (HTTP-bind) based client connectivity.
*/ */
SOCKETBASED_C2S_TRUSTSTORE( true ), BOSH_C2S( "xmpp.bosh.ssl.client.", SOCKET_C2S),
/** /**
* Identification of this Openfire instance used by regular BOSH (HTTP-bind) connections. * Generic administrative services (eg: user providers).
*/ */
BOSHBASED_IDENTITYSTORE( false ), ADMIN( "admin.ssl.", SOCKET_S2S),
/** /**
* Identification of clients that you choose to trust, applies to mutual authentication via BOSH (HTTP-bind) connections. * Openfire web-admin console.
*/ */
BOSHBASED_C2S_TRUSTSTORE( true ), WEBADMIN( "admin.web.ssl.", ADMIN);
/** String prefix;
* Identification of this Openfire instance used by connections to administrative services (eg: user providers). Purpose fallback;
*/ Purpose( String prefix, Purpose fallback) {
ADMINISTRATIVE_IDENTITYSTORE( false ), this.prefix = prefix;
this.fallback = fallback;
}
/** public String getPrefix()
* Identification of remote applications/servers that provide administrative functionality (eg: user providers). {
*/ return prefix;
ADMINISTRATIVE_TRUSTSTORE( true ), }
/** public Purpose getFallback()
* Openfire web-admin console. {
*/ return fallback;
WEBADMIN_IDENTITYSTORE( false ), }
/** public String getIdentityStoreType()
* Openfire web-admin console. {
*/ final String propertyName = prefix + "storeType";
WEBADMIN_TRUSTSTORE( true ); final String defaultValue = "jks";
private final boolean isTrustStore; if ( fallback == null )
{
return JiveGlobals.getProperty( propertyName, defaultValue ).trim();
}
else
{
return JiveGlobals.getProperty( propertyName, fallback.getIdentityStoreType() ).trim();
}
}
Purpose( boolean isTrustStore ) public String getTrustStoreType()
{ {
this.isTrustStore = isTrustStore; return getIdentityStoreType();
} }
public boolean isIdentityStore() public String getIdentityStorePassword()
{ {
return !isTrustStore; final String propertyName = prefix + "keypass";
final String defaultValue = "changeit";
if ( fallback == null )
{
return JiveGlobals.getProperty( propertyName, defaultValue ).trim();
}
else
{
return JiveGlobals.getProperty( propertyName, fallback.getIdentityStorePassword() ).trim();
}
} }
public boolean isTrustStore() public String getTrustStorePassword()
{ {
return isTrustStore; final String propertyName = prefix + "trustpass";
final String defaultValue = "changeit";
if ( fallback == null )
{
return JiveGlobals.getProperty( propertyName, defaultValue ).trim();
}
else
{
return JiveGlobals.getProperty( propertyName, fallback.getTrustStorePassword() ).trim();
}
} }
public boolean acceptSelfSigned()
{
// TODO these are new properties! Deprecate (migrate?) all existing 'accept-selfsigned properties' (Eg: org.jivesoftware.openfire.session.ConnectionSettings.Server.TLS_ACCEPT_SELFSIGNED_CERTS )
final String propertyName = prefix + "certificate.accept-selfsigned";
final boolean defaultValue = false;
if ( fallback == null )
{
return JiveGlobals.getBooleanProperty( propertyName, defaultValue );
}
else
{
return JiveGlobals.getBooleanProperty( propertyName, fallback.acceptSelfSigned() );
}
}
public boolean verifyValidity()
{
// TODO these are new properties! Deprecate (migrate?) all existing 'verify / verify-validity properties' (Eg: org.jivesoftware.openfire.session.ConnectionSettings.Server.TLS_CERTIFICATE_VERIFY_VALIDITY )
final String propertyName = prefix + "certificate.verify.validity";
final boolean defaultValue = true;
if ( fallback == null )
{
return JiveGlobals.getBooleanProperty( propertyName, defaultValue );
}
else
{
return JiveGlobals.getBooleanProperty( propertyName, fallback.acceptSelfSigned() );
}
}
public String getIdentityStoreLocation() throws IOException
{
return canonicalize( getIdentityStoreLocation() );
}
public String getIdentityStoreLocationNonCanonicalized()
{
final String propertyName = prefix + "keystore";
final String defaultValue = "resources" + File.separator + "security" + File.separator + "keystore";
if ( fallback == null )
{
return JiveGlobals.getProperty( propertyName, defaultValue ).trim();
}
else
{
return JiveGlobals.getProperty( propertyName, fallback.getIdentityStoreLocationNonCanonicalized() ).trim();
}
}
public String getTrustStoreLocation() throws IOException
{
return canonicalize( getTrustStoreLocation() );
}
public String getTrustStoreLocationNonCanonicalized()
{
final String propertyName = prefix + "truststore";
final String defaultValue = "resources" + File.separator + "security" + File.separator + "truststore";
if ( fallback == null )
{
return JiveGlobals.getProperty( propertyName, defaultValue ).trim();
}
else
{
return JiveGlobals.getProperty( propertyName, fallback.getTrustStoreLocationNonCanonicalized() ).trim();
}
}
public static String canonicalize( String path ) throws IOException
{
File file = new File( path );
if (!file.isAbsolute()) {
file = new File( JiveGlobals.getHomeDirectory() + File.separator + path );
}
return file.getCanonicalPath();
}
} }
...@@ -31,6 +31,7 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus; ...@@ -31,6 +31,7 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import javax.net.ssl.SSLEngineResult.Status; import javax.net.ssl.SSLEngineResult.Status;
import org.jivesoftware.openfire.Connection; import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.keystore.Purpose;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -77,12 +78,12 @@ public class TLSWrapper { ...@@ -77,12 +78,12 @@ public class TLSWrapper {
final SSLEngine sslEngine; final SSLEngine sslEngine;
if ( clientMode ) if ( clientMode )
{ {
sslEngine = SSLConfig.getClientModeSSLEngine( SSLConfig.Type.SOCKET_S2S ); sslEngine = SSLConfig.getClientModeSSLEngine( Purpose.SOCKET_S2S );
} }
else else
{ {
final SSLConfig.Type type = isPeerClient ? SSLConfig.Type.SOCKET_C2S : SSLConfig.Type.SOCKET_S2S; final Purpose purpose = isPeerClient ? Purpose.SOCKET_C2S : Purpose.SOCKET_S2S;
sslEngine = SSLConfig.getServerModeSSLEngine( type, clientAuth ); sslEngine = SSLConfig.getServerModeSSLEngine( purpose, clientAuth );
} }
final SSLSession sslSession = sslEngine.getSession(); final SSLSession sslSession = sslEngine.getSession();
......
...@@ -28,19 +28,13 @@ import java.net.InetAddress; ...@@ -28,19 +28,13 @@ import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction; import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import javax.net.ssl.SSLContext; import javax.net.ssl.*;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.filterchain.IoFilterChain; import org.apache.mina.core.filterchain.IoFilterChain;
...@@ -52,26 +46,20 @@ import org.jivesoftware.openfire.Connection; ...@@ -52,26 +46,20 @@ import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.ConnectionCloseListener; import org.jivesoftware.openfire.ConnectionCloseListener;
import org.jivesoftware.openfire.PacketDeliverer; import org.jivesoftware.openfire.PacketDeliverer;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.keystore.IdentityStoreConfig; import org.jivesoftware.openfire.keystore.*;
import org.jivesoftware.openfire.keystore.Purpose;
import org.jivesoftware.openfire.keystore.TrustStoreConfig;
import org.jivesoftware.openfire.net.*; import org.jivesoftware.openfire.net.*;
import org.jivesoftware.openfire.session.ConnectionSettings;
import org.jivesoftware.openfire.session.LocalSession; import org.jivesoftware.openfire.session.LocalSession;
import org.jivesoftware.openfire.session.Session; import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.XMLWriter; import org.jivesoftware.util.XMLWriter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
/** /**
* Implementation of {@link Connection} inteface specific for NIO connections when using * Implementation of {@link Connection} interface specific for NIO connections when using the Apache MINA framework.
* the MINA framework.<p>
*
* MINA project can be found at <a href="http://mina.apache.org">here</a>.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
* @see <a href="http://mina.apache.org">Apache MINA</a>
*/ */
public class NIOConnection implements Connection { public class NIOConnection implements Connection {
...@@ -378,65 +366,28 @@ public class NIOConnection implements Connection { ...@@ -378,65 +366,28 @@ public class NIOConnection implements Connection {
@Deprecated @Deprecated
@Override @Override
public void startTLS(boolean clientMode, String remoteServer, ClientAuth authentication) throws Exception { public void startTLS(boolean clientMode, String remoteServer, ClientAuth authentication) throws Exception {
final boolean isClientToServer = ( remoteServer == null ); final boolean isPeerClient = ( remoteServer == null );
startTLS( clientMode, isClientToServer, authentication ); startTLS( clientMode, isPeerClient, authentication );
} }
public void startTLS(boolean clientMode, boolean isClientToServer, ClientAuth authentication) throws Exception { public void startTLS(boolean clientMode, boolean isPeerClient, ClientAuth authentication) throws Exception {
Log.debug( "StartTLS: using {}", isClientToServer ? "c2s" : "s2s" );
final SSLConfig sslConfig = SSLConfig.getInstance(); final SslFilter filter;
final TrustStoreConfig storeConfig; if ( clientMode ) {
if (isClientToServer) { filter = SSLConfig.getClientModeSslFilter( Purpose.SOCKET_S2S );
storeConfig = (TrustStoreConfig) sslConfig.getStoreConfig( Purpose.SOCKETBASED_C2S_TRUSTSTORE );
} else {
storeConfig = (TrustStoreConfig) sslConfig.getStoreConfig( Purpose.SOCKETBASED_S2S_TRUSTSTORE );
} }
else
final TrustManager[] tm; {
if (clientMode || authentication == ClientAuth.needed || authentication == ClientAuth.wanted) { final Purpose purpose = isPeerClient ? Purpose.SOCKET_C2S : Purpose.SOCKET_S2S;
// We might need to verify a certificate from our peer, so get different TrustManager[]'s filter = SSLConfig.getServerModeSslFilter( purpose, authentication );
final KeyStore ksTrust = storeConfig.getStore();
if(isClientToServer) {
// Check if we can trust certificates presented by the client
tm = new TrustManager[]{new ClientTrustManager(ksTrust)};
} else {
// Check if we can trust certificates presented by the server
tm = new TrustManager[]{new ServerTrustManager(ksTrust)};
}
} else {
tm = storeConfig.getTrustManagers();
} }
final SSLContext tlsContext = SSLConfig.getSSLContext();
final IdentityStoreConfig identityStoreConfig = (IdentityStoreConfig) sslConfig.getStoreConfig( Purpose.SOCKETBASED_IDENTITYSTORE );
tlsContext.init( identityStoreConfig.getKeyManagers(), tm, null);
SslFilter filter = new SslFilter(tlsContext);
filter.setUseClientMode(clientMode);
// Disable SSLv3 due to POODLE vulnerability.
if (clientMode) {
filter.setEnabledProtocols(new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"});
} else {
// ... but accept a SSLv2 Hello when in server mode.
filter.setEnabledProtocols(new String[]{"SSLv2Hello", "TLSv1", "TLSv1.1", "TLSv1.2"});
}
if (authentication == ClientAuth.needed) {
filter.setNeedClientAuth(true);
}
else if (authentication == ClientAuth.wanted) {
// Just indicate that we would like to authenticate the client but if client
// certificates are self-signed or have no certificate chain then we are still
// good
filter.setWantClientAuth(true);
}
ioSession.getFilterChain().addBefore(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, filter); ioSession.getFilterChain().addBefore(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, filter);
ioSession.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE); ioSession.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE, Boolean.TRUE);
if (!clientMode) { if ( !clientMode ) {
// Indicate the client that the server is ready to negotiate TLS // Indicate the client that the server is ready to negotiate TLS
deliverRawText("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"); deliverRawText( "<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>" );
} }
} }
......
...@@ -56,14 +56,7 @@ import org.apache.mina.integration.jmx.IoServiceMBean; ...@@ -56,14 +56,7 @@ import org.apache.mina.integration.jmx.IoServiceMBean;
import org.apache.mina.integration.jmx.IoSessionMBean; import org.apache.mina.integration.jmx.IoSessionMBean;
import org.apache.mina.transport.socket.SocketSessionConfig; import org.apache.mina.transport.socket.SocketSessionConfig;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor; import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.jivesoftware.openfire.ConnectionManager; import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.JMXManager;
import org.jivesoftware.openfire.PacketDeliverer;
import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.RoutingTable;
import org.jivesoftware.openfire.ServerPort;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.container.BasicModule; import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.container.PluginManager; import org.jivesoftware.openfire.container.PluginManager;
import org.jivesoftware.openfire.container.PluginManagerListener; import org.jivesoftware.openfire.container.PluginManagerListener;
...@@ -451,6 +444,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -451,6 +444,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
Log.debug("Throttling read buffer for connections from sslSocketAcceptor={} to max={} bytes", Log.debug("Throttling read buffer for connections from sslSocketAcceptor={} to max={} bytes",
sslSocketAcceptor, maxBufferSize); sslSocketAcceptor, maxBufferSize);
// Add the SSL filter now since sockets are "borned" encrypted in the old ssl method // Add the SSL filter now since sockets are "borned" encrypted in the old ssl method
Connection.ClientAuth clientAuth; Connection.ClientAuth clientAuth;
try { try {
...@@ -459,9 +453,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -459,9 +453,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
clientAuth = Connection.ClientAuth.disabled; clientAuth = Connection.ClientAuth.disabled;
} }
final SslFilter sslFilter = SSLConfig.getServerModeSslFilter( SSLConfig.Type.SOCKET_C2S, clientAuth ); final SslFilter sslFilter = SSLConfig.getServerModeSslFilter( Purpose.SOCKET_C2S, clientAuth );
sslSocketAcceptor.getFilterChain().addAfter(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, sslFilter); sslSocketAcceptor.getFilterChain().addAfter(EXECUTOR_FILTER_NAME, TLS_FILTER_NAME, sslFilter);
} }
catch (Exception e) { catch (Exception e) {
System.err.println("Error starting SSL XMPP listener on port " + port + ": " + System.err.println("Error starting SSL XMPP listener on port " + port + ": " +
...@@ -615,7 +608,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -615,7 +608,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
@Override @Override
public boolean isClientSSLListenerEnabled() { public boolean isClientSSLListenerEnabled() {
try { try {
return JiveGlobals.getBooleanProperty(ConnectionSettings.Client.ENABLE_OLD_SSLPORT, false) && SSLConfig.getStore( Purpose.SOCKETBASED_IDENTITYSTORE ).size() > 0; return JiveGlobals.getBooleanProperty(ConnectionSettings.Client.ENABLE_OLD_SSLPORT, false) && SSLConfig.getIdentityStore( Purpose.SOCKET_C2S ).size() > 0;
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
return false; return false;
} }
......
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
storePurpose = null; storePurpose = null;
} }
if (! storePurpose.isIdentityStore() ) {
errors.put( "storePurpose", "shoud be an identity store (not a trust store)");
storePurpose = null;
}
pageContext.setAttribute( "storePurpose", storePurpose ); pageContext.setAttribute( "storePurpose", storePurpose );
if (save) { if (save) {
...@@ -47,7 +42,7 @@ ...@@ -47,7 +42,7 @@
} }
if (errors.isEmpty()) { if (errors.isEmpty()) {
try { try {
final IdentityStoreConfig identityStoreConfig = (IdentityStoreConfig) SSLConfig.getInstance().getStoreConfig( storePurpose ); final IdentityStoreConfig identityStoreConfig = SSLConfig.getInstance().getIdentityStoreConfig( storePurpose );
// Create an alias for the signed certificate // Create an alias for the signed certificate
String domain = XMPPServer.getInstance().getServerInfo().getXMPPDomain(); String domain = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
...@@ -62,7 +57,7 @@ ...@@ -62,7 +57,7 @@
identityStoreConfig.installCertificate( alias, privateKey, passPhrase, certificate ); identityStoreConfig.installCertificate( alias, privateKey, passPhrase, certificate );
// Log the event // Log the event
webManager.logEvent("imported SSL certificate in "+ storePurposeText, "alias = "+alias); webManager.logEvent("imported SSL certificate in identity store "+ storePurposeText, "alias = "+alias);
response.sendRedirect("security-keystore.jsp?storePurpose="+storePurposeText); response.sendRedirect("security-keystore.jsp?storePurpose="+storePurposeText);
return; return;
...@@ -77,8 +72,8 @@ ...@@ -77,8 +72,8 @@
<html> <html>
<head> <head>
<title><fmt:message key="ssl.import.certificate.keystore.${connectivityType}.title"/></title> <title><fmt:message key="ssl.import.certificate.keystore.${storePurpose}.title"/></title>
<meta name="pageID" content="security-keystore-${connectivityType}"/> <meta name="pageID" content="security-keystore-${storePurpose}"/>
</head> </head>
<body> <body>
...@@ -120,7 +115,7 @@ ...@@ -120,7 +115,7 @@
<!-- BEGIN 'Import Private Key and Certificate' --> <!-- BEGIN 'Import Private Key and Certificate' -->
<form action="import-keystore-certificate.jsp" method="post" name="f"> <form action="import-keystore-certificate.jsp" method="post" name="f">
<input type="hidden" name="connectivityType" value="${connectivityType}"/> <input type="hidden" name="storePurpose" value="${storePurpose}"/>
<div class="jive-contentBoxHeader"> <div class="jive-contentBoxHeader">
<fmt:message key="ssl.import.certificate.keystore.boxtitle" /> <fmt:message key="ssl.import.certificate.keystore.boxtitle" />
</div> </div>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<% final boolean save = ParamUtils.getParameter(request, "save") != null; <% final boolean save = ParamUtils.getParameter(request, "save") != null;
final String alias = ParamUtils.getParameter(request, "alias"); final String alias = ParamUtils.getParameter(request, "alias");
final String certificate = ParamUtils.getParameter(request, "certificate"); final String certificate = ParamUtils.getParameter(request, "certificate");
final String storePurposeText = ParamUtils.getParameter(request, "storePurpose"); final String storePurposeText = ParamUtils.getParameter(request, "storePurpose");
final Map<String, String> errors = new HashMap<String, String>(); final Map<String, String> errors = new HashMap<String, String>();
...@@ -29,16 +29,11 @@ ...@@ -29,16 +29,11 @@
storePurpose = null; storePurpose = null;
} }
if (! storePurpose.isTrustStore() ) {
errors.put( "storePurpose", "shoud be a trust store (not an identity store)");
storePurpose = null;
}
pageContext.setAttribute( "storePurpose", storePurpose ); pageContext.setAttribute( "storePurpose", storePurpose );
if (save && errors.isEmpty()) if (save && errors.isEmpty())
{ {
final TrustStoreConfig trustStoreConfig = (TrustStoreConfig) SSLConfig.getInstance().getStoreConfig( storePurpose ); final TrustStoreConfig trustStoreConfig = SSLConfig.getInstance().getTrustStoreConfig( storePurpose );
if (alias == null || "".equals(alias)) if (alias == null || "".equals(alias))
{ {
...@@ -62,7 +57,7 @@ ...@@ -62,7 +57,7 @@
trustStoreConfig.installCertificate( alias, certificate ); trustStoreConfig.installCertificate( alias, certificate );
// Log the event // Log the event
webManager.logEvent("imported SSL certificate in "+ storePurposeText, "alias = "+alias); webManager.logEvent("imported SSL certificate in trust store "+ storePurposeText, "alias = "+alias);
response.sendRedirect( "security-truststore.jsp?storePurpose=" + storePurposeText + "&importsuccess=true" ); response.sendRedirect( "security-truststore.jsp?storePurpose=" + storePurposeText + "&importsuccess=true" );
return; return;
...@@ -79,9 +74,9 @@ ...@@ -79,9 +74,9 @@
<html> <html>
<head> <head>
<title> <title>
<fmt:message key="ssl.import.certificate.keystore.${connectivityType}.title"/> - <fmt:message key="ssl.certificates.truststore.${param.type}-title"/> <fmt:message key="ssl.import.certificate.keystore.${storePurpose}.title"/> - <fmt:message key="ssl.certificates.truststore.${param.type}-title"/>
</title> </title>
<meta name="pageID" content="security-truststore-${connectivityType}-${param.type}"/> <meta name="pageID" content="security-truststore-${storePurpose}-${param.type}"/>
</head> </head>
<body> <body>
...@@ -129,7 +124,7 @@ ...@@ -129,7 +124,7 @@
<!-- BEGIN 'Import Certificate' --> <!-- BEGIN 'Import Certificate' -->
<form action="import-truststore-certificate.jsp?type=${param.type}" method="post" name="f"> <form action="import-truststore-certificate.jsp?type=${param.type}" method="post" name="f">
<input type="hidden" name="connectivityType" value="${connectivityType}"/> <input type="hidden" name="connectivityType" value="${storePurpose}"/>
<div class="jive-contentBoxHeader"> <div class="jive-contentBoxHeader">
<fmt:message key="ssl.import.certificate.keystore.boxtitle"/> <fmt:message key="ssl.import.certificate.keystore.boxtitle"/>
</div> </div>
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<fmt:message key="index.server_name" /> <fmt:message key="index.server_name" />
</td> </td>
<td class="c2"> <td class="c2">
<% final IdentityStoreConfig storeConfig = (IdentityStoreConfig) SSLConfig.getInstance().getStoreConfig( Purpose.SOCKETBASED_IDENTITYSTORE ); %> <% final IdentityStoreConfig storeConfig = SSLConfig.getInstance().getIdentityStoreConfig( Purpose.SOCKET_C2S ); %>
<% try { %> <% try { %>
<% if (!storeConfig.containsDomainCertificate( "RSA" )) {%> <% if (!storeConfig.containsDomainCertificate( "RSA" )) {%>
<img src="images/warning-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="index.certificate-warning" />" title="<fmt:message key="index.certificate-warning" />">&nbsp; <img src="images/warning-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="index.certificate-warning" />" title="<fmt:message key="index.certificate-warning" />">&nbsp;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<%@ page import="java.security.AlgorithmParameters" %> <%@ page import="java.security.AlgorithmParameters" %>
<%@ page import="org.jivesoftware.openfire.keystore.Purpose" %> <%@ page import="org.jivesoftware.openfire.keystore.Purpose" %>
<%@ page import="org.jivesoftware.openfire.keystore.CertificateStoreConfig" %> <%@ page import="org.jivesoftware.openfire.keystore.CertificateStoreConfig" %>
<%@ page import="java.security.KeyStore" %>
<%@ taglib uri="admin" prefix="admin" %> <%@ taglib uri="admin" prefix="admin" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
final String alias = ParamUtils.getParameter( request, "alias" ); final String alias = ParamUtils.getParameter( request, "alias" );
final String storePurposeText = ParamUtils.getParameter( request, "storePurpose" ); final String storePurposeText = ParamUtils.getParameter( request, "storePurpose" );
final boolean isTrustStore = ParamUtils.getBooleanParameter( request, "isTrustStore" );
final Map<String, String> errors = new HashMap<String, String>(); final Map<String, String> errors = new HashMap<String, String>();
...@@ -42,10 +44,15 @@ ...@@ -42,10 +44,15 @@
{ {
try try
{ {
final CertificateStoreConfig certificateStoreConfig = SSLConfig.getInstance().getStoreConfig( storePurpose ); final KeyStore store;
if (isTrustStore) {
store = SSLConfig.getTrustStore( storePurpose );
} else {
store = SSLConfig.getIdentityStore( storePurpose );
}
// Get the certificate // Get the certificate
final X509Certificate certificate = (X509Certificate) certificateStoreConfig.getStore().getCertificate( alias ); final X509Certificate certificate = (X509Certificate) store.getCertificate( alias );
if ( certificate == null ) { if ( certificate == null ) {
errors.put( "alias", "alias" ); errors.put( "alias", "alias" );
...@@ -62,7 +69,7 @@ ...@@ -62,7 +69,7 @@
// Handle a "go back" click: // Handle a "go back" click:
if ( request.getParameter( "back" ) != null ) { if ( request.getParameter( "back" ) != null ) {
if ( storePurpose.isTrustStore() ) { if ( isTrustStore ) {
response.sendRedirect( "security-truststore.jsp?storePurpose=" + storePurpose ); response.sendRedirect( "security-truststore.jsp?storePurpose=" + storePurpose );
} else { } else {
response.sendRedirect( "security-keystore.jsp?storePurpose=" + storePurpose ); response.sendRedirect( "security-keystore.jsp?storePurpose=" + storePurpose );
...@@ -77,11 +84,11 @@ ...@@ -77,11 +84,11 @@
<head> <head>
<title><fmt:message key="ssl.certificate.details.title"/></title> <title><fmt:message key="ssl.certificate.details.title"/></title>
<c:choose> <c:choose>
<c:when test="${storePurpose.identityStore}"> <c:when test="${isTrustStore}">
<meta name="pageID" content="security-keystore"/> <meta name="pageID" content="security-truststore"/>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<meta name="pageID" content="security-truststore"/> <meta name="pageID" content="security-keystore"/>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</head> </head>
......
...@@ -16,41 +16,12 @@ ...@@ -16,41 +16,12 @@
// Read parameters // Read parameters
final boolean save = request.getParameter("save") != null; final boolean save = request.getParameter("save") != null;
final String paramLocKeySocket = ParamUtils.getParameter(request, "loc-key-socket");
final String paramLocTrustSocketS2S = ParamUtils.getParameter(request, "loc-trust-socket-s2s");
final String paramLocTrustSocketC2S = ParamUtils.getParameter(request, "loc-trust-socket-c2s");
final String paramLocKeyBosh = ParamUtils.getParameter(request, "loc-key-bosh");
final String paramLocTrustBoshC2S = ParamUtils.getParameter(request, "loc-trust-bosh-c2s");
final String paramLocKeyWebadmin = ParamUtils.getParameter(request, "loc-key-webadmin");
final String paramLocTrustWebadmin = ParamUtils.getParameter(request, "loc-trust-webadmin");
final String paramLocKeyAdministrative = ParamUtils.getParameter( request, "loc-key-administrative" );
final String paramLocTrustAdministrative = ParamUtils.getParameter( request, "loc-trust-administrative" );
// TODO actually save something! // TODO actually save something!
// Pre-update property values // Pre-update property values
final String locKeySocket = SSLConfig.getNonCanonicalizedLocation( Purpose.SOCKETBASED_IDENTITYSTORE );
final String locTrustSocketS2S = SSLConfig.getNonCanonicalizedLocation( Purpose.SOCKETBASED_S2S_TRUSTSTORE );
final String locTrustSocketC2S = SSLConfig.getNonCanonicalizedLocation( Purpose.SOCKETBASED_C2S_TRUSTSTORE );
final String locKeyBosh = SSLConfig.getNonCanonicalizedLocation( Purpose.BOSHBASED_IDENTITYSTORE );
final String locTrustBoshC2S = SSLConfig.getNonCanonicalizedLocation( Purpose.BOSHBASED_C2S_TRUSTSTORE );
final String locKeyWebadmin = SSLConfig.getNonCanonicalizedLocation( Purpose.WEBADMIN_IDENTITYSTORE );
final String locTrustWebadmin = SSLConfig.getNonCanonicalizedLocation( Purpose.WEBADMIN_TRUSTSTORE );
final String locKeyAdministrative = SSLConfig.getNonCanonicalizedLocation( Purpose.ADMINISTRATIVE_IDENTITYSTORE );
final String locTrustAdministrative = SSLConfig.getNonCanonicalizedLocation( Purpose.ADMINISTRATIVE_TRUSTSTORE );
final Map<String, String> errors = new HashMap<>(); final Map<String, String> errors = new HashMap<>();
pageContext.setAttribute( "errors", errors ); pageContext.setAttribute( "errors", errors );
pageContext.setAttribute( "locKeySocket", locKeySocket );
pageContext.setAttribute( "locTrustSocketS2S",locTrustSocketS2S );
pageContext.setAttribute( "locTrustSocketC2S", locTrustSocketC2S );
pageContext.setAttribute( "locKeyBosh", locKeyBosh );
pageContext.setAttribute( "locTrustBoshC2S", locTrustBoshC2S );
pageContext.setAttribute( "locKeyWebadmin", locKeyWebadmin );
pageContext.setAttribute( "locTrustWebadmin", locTrustWebadmin );
pageContext.setAttribute( "locKeyAdministrative", locKeyAdministrative );
pageContext.setAttribute( "locTrustAdministrative", locTrustAdministrative );
%> %>
<html> <html>
......
...@@ -36,18 +36,10 @@ ...@@ -36,18 +36,10 @@
try try
{ {
storePurpose = Purpose.valueOf( storePurposeText ); storePurpose = Purpose.valueOf( storePurposeText );
storeConfig = SSLConfig.getInstance().getIdentityStoreConfig( storePurpose );
if ( !storePurpose.isIdentityStore() ) if ( storeConfig == null )
{
errors.put( "storePurpose", "should be an identity store (not a trust store)");
}
else
{ {
storeConfig = (IdentityStoreConfig) SSLConfig.getInstance().getStoreConfig( storePurpose ); errors.put( "storeConfig", "Unable to get an instance." );
if ( storeConfig == null )
{
errors.put( "storeConfig", "Unable to get an instance." );
}
} }
} }
catch (RuntimeException ex) catch (RuntimeException ex)
...@@ -60,7 +52,7 @@ ...@@ -60,7 +52,7 @@
pageContext.setAttribute( "storePurpose", storePurpose ); pageContext.setAttribute( "storePurpose", storePurpose );
pageContext.setAttribute( "storeConfig", storeConfig ); pageContext.setAttribute( "storeConfig", storeConfig );
final Set<Purpose> sameStorePurposes = SSLConfig.getInstance().getOtherPurposesForSameStore( storePurpose ); final Set<Purpose> sameStorePurposes = Collections.EMPTY_SET; // TODO FIXME: SSLConfig.getInstance().getOtherPurposesForSameStore( storePurpose );
pageContext.setAttribute( "sameStorePurposes", sameStorePurposes ); pageContext.setAttribute( "sameStorePurposes", sameStorePurposes );
final Map<String, X509Certificate> certificates = storeConfig.getAllCertificates(); final Map<String, X509Certificate> certificates = storeConfig.getAllCertificates();
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<%@ page import="org.jivesoftware.openfire.keystore.Purpose" %> <%@ page import="org.jivesoftware.openfire.keystore.Purpose" %>
<%@ page import="org.jivesoftware.openfire.keystore.TrustStoreConfig" %> <%@ page import="org.jivesoftware.openfire.keystore.TrustStoreConfig" %>
<%@ page import="java.util.Set" %> <%@ page import="java.util.Set" %>
<%@ page import="java.util.Collections" %>
<%@ taglib uri="admin" prefix="admin" %> <%@ taglib uri="admin" prefix="admin" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
...@@ -28,18 +29,10 @@ ...@@ -28,18 +29,10 @@
try try
{ {
storePurpose = Purpose.valueOf( storePurposeText ); storePurpose = Purpose.valueOf( storePurposeText );
storeConfig = SSLConfig.getInstance().getTrustStoreConfig( storePurpose );
if ( !storePurpose.isTrustStore() ) if ( storeConfig == null )
{
errors.put( "storePurpose", "should be a trust store (not an identity store)");
}
else
{ {
storeConfig = (TrustStoreConfig) SSLConfig.getInstance().getStoreConfig( storePurpose ); errors.put( "storeConfig", "Unable to get an instance." );
if ( storeConfig == null )
{
errors.put( "storeConfig", "Unable to get an instance." );
}
} }
} }
catch (RuntimeException ex) catch (RuntimeException ex)
...@@ -52,7 +45,7 @@ ...@@ -52,7 +45,7 @@
pageContext.setAttribute( "storePurpose", storePurpose ); pageContext.setAttribute( "storePurpose", storePurpose );
pageContext.setAttribute( "storeConfig", storeConfig ); pageContext.setAttribute( "storeConfig", storeConfig );
final Set<Purpose> sameStorePurposes = SSLConfig.getInstance().getOtherPurposesForSameStore( storePurpose ); final Set<Purpose> sameStorePurposes = Collections.EMPTY_SET; // TODO FIXME: SSLConfig.getInstance().getOtherPurposesForSameStore( storePurpose );
pageContext.setAttribute( "sameStorePurposes", sameStorePurposes ); pageContext.setAttribute( "sameStorePurposes", sameStorePurposes );
if ( delete ) if ( delete )
......
...@@ -38,10 +38,6 @@ ...@@ -38,10 +38,6 @@
storePurpose = null; storePurpose = null;
} }
if (! storePurpose.isIdentityStore() ) {
errors.put( "storePurpose", "shoud be an identity store (not a trust store)");
storePurpose = null;
}
pageContext.setAttribute( "storePurpose", storePurpose ); pageContext.setAttribute( "storePurpose", storePurpose );
// if (save) { // if (save) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment