mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
03.26.2009 e10a19e91d09aa4bf4dd1fabf048b46299899e35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.opends.sdk.util;
 
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
 
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
 
/**
 * Created by IntelliJ IDEA.
 * User: boli
 * Date: Oct 22, 2009
 * Time: 3:10:13 PM
 * To change this template use File | Settings | File Templates.
 */
public class SSLUtils
{
  private static String PROVIDER =
        System.getProperty("org.opends.security.provider");
  private static String KEY_STORE =
      System.getProperty("javax.net.ssl.keyStore");
 
  {
 
  }
  public static SSLContext getSSLContext(TrustManager trustManager,
                                         KeyManager keyManager)
      throws KeyManagementException, NoSuchAlgorithmException {
    TrustManager[] tm = null;
    if (trustManager != null)
    {
      tm = new TrustManager[] {trustManager};
    }
 
    KeyManager[] km = null;
    if (keyManager != null)
    {
      km = new KeyManager[] {keyManager};
    }
 
    SSLContext sslContext = SSLContext.getInstance("TLSv1");
    sslContext.init(km, tm, null);
 
    return sslContext;
  }
}