001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 */ 016 017package org.opends.guitools.controlpanel.datamodel; 018 019 020 /** 021 * Policy to follow to choose the protocol to be used. 022 * 023 * */ 024public enum ConnectionProtocolPolicy 025{ 026 /** 027 * Force to use Start TLS. 028 */ 029 USE_STARTTLS, 030 /** 031 * Force to use LDAP. 032 */ 033 USE_LDAP, 034 /** 035 * Force to use LDAPs. 036 */ 037 USE_LDAPS, 038 /** 039 * Force to use the Administration Connector. 040 */ 041 USE_ADMIN, 042 /** 043 * Use the most secure available (LDAPs, StartTLS and finally LDAP). 044 */ 045 USE_MOST_SECURE_AVAILABLE, 046 /** 047 * Use the less secure available (LDAP, and then LDAPs). 048 */ 049 USE_LESS_SECURE_AVAILABLE; 050 051 /** 052 * Returns the ConnectionProtocolPolicy to be used with the parameters 053 * provided by the user. 054 * @param useSSL whether the user asked to use SSL or not. 055 * @param useStartTLS whether the user asked to use Start TLS or not. 056 * @return the ConnectionProtocolPolicy to be used with the parameters 057 * provided by the user. 058 */ 059 public static ConnectionProtocolPolicy getConnectionPolicy(boolean useSSL, 060 boolean useStartTLS) 061 { 062 ConnectionProtocolPolicy policy; 063 if (useStartTLS) 064 { 065 policy = ConnectionProtocolPolicy.USE_STARTTLS; 066 } 067 else if (useSSL) 068 { 069 policy = ConnectionProtocolPolicy.USE_LDAPS; 070 } 071 else 072 { 073 policy = ConnectionProtocolPolicy.USE_LESS_SECURE_AVAILABLE; 074 } 075 return policy; 076 } 077}