Commit a1cf99e0 authored by Guus der Kinderen's avatar Guus der Kinderen

OF-1004: Add functionality to determine supported encryption protocols/suites.

parent 5c87f318
......@@ -325,4 +325,30 @@ public class EncryptionArtifactFactory
}
return filter;
}
/**
* Returns the names of all encryption protocols that are supported (but not necessarily enabled).
*
* @return An array of protocol names. Not expected to be empty.
*/
public static String[] getSupportedProtocols() throws NoSuchAlgorithmException, KeyManagementException
{
// TODO Might want to cache the result. It's unlikely to change at runtime.
final SSLContext context = SSLContext.getInstance( "TLSv1" );
context.init( null, null, null );
return context.createSSLEngine().getSupportedProtocols();
}
/**
* Returns the names of all encryption cipher suites that are supported (but not necessarily enabled).
*
* @return An array of cipher suite names. Not expected to be empty.
*/
public static String[] getSupportedCipherSuites() throws NoSuchAlgorithmException, KeyManagementException
{
// TODO Might want to cache the result. It's unlikely to change at runtime.
final SSLContext context = SSLContext.getInstance( "TLSv1" );
context.init( null, null, null );
return context.createSSLEngine().getSupportedCipherSuites();
}
}
package org.jivesoftware.openfire.spi;
import org.junit.Assert;
import org.junit.Test;
/**
* Unit tests that verify the functionality of {@link EncryptionArtifactFactory}.
*
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
*/
public class EncryptionArtifactFactoryTest
{
/**
* Verifies that the collection of supported encryption protocols is not empty.
*/
@Test
public void testHasSupportedProtocols() throws Exception
{
// Setup fixture.
// (not needed)
// Execute system under test.
final String[] result = EncryptionArtifactFactory.getSupportedProtocols();
// Verify results.
Assert.assertTrue( result.length > 0 );
}
/**
* Verifies that the collection of supported cipher suites is not empty.
*/
@Test
public void testHasSupportedCipherSuites() throws Exception
{
// Setup fixture.
// (not needed)
// Execute system under test.
final String[] result = EncryptionArtifactFactory.getSupportedCipherSuites();
// Verify results.
Assert.assertTrue( result.length > 0 );
}
}
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