Program: 126145
Project: 126145
Buggy source:
/** 
 * Administrator Comment method "checkParam".
 * @param connection
 * @return
 */
public static boolean checkParam(LDAPSchemaConnection connection,boolean isStep1Check){
  String hostName=connection.getHost();
  String port=connection.getPort();
  String protocol=connection.getProtocol();
  if (isStep1Check) {
    protocol=EAuthenticationMethod.ANONYMOUS.getName();
  }
  String encryptionMethod=connection.getEncryptionMethodName();
  String userOrBindId=connection.getBindPrincipal();
  String password=connection.getValue(connection.getBindPassword(),false);
  String aliasesDereference=connection.getAliases();
  String referral=connection.getReferrals();
  boolean isAuthUsed=connection.isUseAuthen();
  env=new java.util.Hashtable<String,String>();
  env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,CONTEXT_FACTORY);
  if (protocol.equals(EAuthenticationMethod.SIMPLE.getName())) {
    env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  }
 else {
    env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  }
  if (isAuthUsed && userOrBindId != null && userOrBindId.length() > 0) {
    env.put(javax.naming.Context.SECURITY_PRINCIPAL,userOrBindId);
  }
  if (isAuthUsed && password != null && password.length() > 0) {
    env.put(javax.naming.Context.SECURITY_CREDENTIALS,password);
  }
  if (aliasesDereference != null && aliasesDereference.length() > 0) {
    env.put("String_Node_Str",aliasesDereference);
  }
  if (referral != null && referral.length() > 0) {
    env.put(javax.naming.Context.REFERRAL,referral);
  }
  String hostUrl="String_Node_Str";
  if (encryptionMethod.equals(EEncryptionMethod.SSL_ENCRYPTION_METHOD.getName()) || (encryptionMethod.equals(EEncryptionMethod.STARTTSL_EXTENSION_METHOD.getName()))) {
    hostUrl=LDAPS_URL_PREFIX + hostName + "String_Node_Str"+ port;
    env.put(javax.naming.Context.SECURITY_PROTOCOL,"String_Node_Str");
    env.put("String_Node_Str","String_Node_Str");
  }
 else   if (encryptionMethod.equals(EEncryptionMethod.NO_ENCRYPTION_METHOD.getName())) {
    hostUrl=LDAP_URL_PREFIX + hostName + "String_Node_Str"+ port;
    env.remove(javax.naming.Context.SECURITY_PROTOCOL);
  }
  env.put(javax.naming.Context.PROVIDER_URL,hostUrl);
  try {
    ctx=new javax.naming.ldap.InitialLdapContext(env,null);
    if (encryptionMethod.equals(EEncryptionMethod.STARTTSL_EXTENSION_METHOD)) {
      javax.naming.ldap.StartTlsRequest tldsReq=new javax.naming.ldap.StartTlsRequest();
      javax.naming.ldap.StartTlsResponse tls=(javax.naming.ldap.StartTlsResponse)ctx.extendedOperation(tldsReq);
      javax.net.ssl.SSLSession session=tls.negotiate((javax.net.ssl.SSLSocketFactory)AdvancedSocketFactory.getDefault());
    }
    return true;
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Administrator Comment method "checkParam".
 * @param connection
 * @return
 */
public static boolean checkParam(LDAPSchemaConnection connection,boolean isStep1Check){
  String hostName=connection.getHost();
  String port=connection.getPort();
  String protocol=connection.getProtocol();
  if (isStep1Check) {
    protocol=EAuthenticationMethod.ANONYMOUS.getName();
  }
  String encryptionMethod=connection.getEncryptionMethodName();
  String userOrBindId=connection.getBindPrincipal();
  String password=connection.getValue(connection.getBindPassword(),false);
  String aliasesDereference=connection.getAliases();
  String referral=connection.getReferrals();
  boolean isAuthUsed=connection.isUseAuthen();
  env=new java.util.Hashtable<String,String>();
  env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,CONTEXT_FACTORY);
  if (protocol.equals(EAuthenticationMethod.SIMPLE.getName())) {
    env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  }
 else {
    env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  }
  if (isAuthUsed && userOrBindId != null && userOrBindId.length() > 0) {
    env.put(javax.naming.Context.SECURITY_PRINCIPAL,userOrBindId);
  }
  if (isAuthUsed && password != null && password.length() > 0) {
    env.put(javax.naming.Context.SECURITY_CREDENTIALS,password);
  }
  if (aliasesDereference != null && aliasesDereference.length() > 0) {
    env.put("String_Node_Str",aliasesDereference);
  }
  if (referral != null && referral.length() > 0) {
    env.put(javax.naming.Context.REFERRAL,referral);
  }
  String hostUrl="String_Node_Str";
  if (encryptionMethod.equals(EEncryptionMethod.SSL_ENCRYPTION_METHOD.getName()) || (encryptionMethod.equals(EEncryptionMethod.STARTTSL_EXTENSION_METHOD.getName()))) {
    hostUrl=LDAPS_URL_PREFIX + hostName + "String_Node_Str"+ port;
    env.put(javax.naming.Context.SECURITY_PROTOCOL,"String_Node_Str");
    env.put("String_Node_Str",AdvancedSocketFactory.class.getName());
  }
 else   if (encryptionMethod.equals(EEncryptionMethod.NO_ENCRYPTION_METHOD.getName())) {
    hostUrl=LDAP_URL_PREFIX + hostName + "String_Node_Str"+ port;
    env.remove(javax.naming.Context.SECURITY_PROTOCOL);
  }
  env.put(javax.naming.Context.PROVIDER_URL,hostUrl);
  try {
    ctx=new javax.naming.ldap.InitialLdapContext(env,null);
    if (encryptionMethod.equals(EEncryptionMethod.STARTTSL_EXTENSION_METHOD)) {
      javax.naming.ldap.StartTlsRequest tldsReq=new javax.naming.ldap.StartTlsRequest();
      javax.naming.ldap.StartTlsResponse tls=(javax.naming.ldap.StartTlsResponse)ctx.extendedOperation(tldsReq);
      javax.net.ssl.SSLSession session=tls.negotiate((javax.net.ssl.SSLSocketFactory)AdvancedSocketFactory.getDefault());
    }
    return true;
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
    return false;
  }
}