Program: 30449
Project: 30449
Buggy source:
/** 
 * Initialize a realm with some properties.  This can be used when instantiating realms from their descriptions.  This method may only be called a single time.  
 * @param props Initialization parameters used by this realm.
 * @exception BadRealmException If the configuration parametersidentify a corrupt realm.
 * @exception NoSuchRealmException If the configuration parametersspecify a realm which doesn't exist.
 */
public synchronized void init(Properties props) throws BadRealmException, NoSuchRealmException {
  super.init(props);
  String url=props.getProperty(PARAM_DIRURL);
  String dn=props.getProperty(PARAM_USERDN);
  String jaasCtx=props.getProperty(IASRealm.JAAS_CONTEXT_PARAM);
  if (url == null || dn == null || jaasCtx == null) {
    String msg=sm.getString("String_Node_Str",url,dn,jaasCtx);
    throw new BadRealmException(msg);
  }
  this.setProperty(PARAM_DIRURL,url);
  ldapBindProps.setProperty(Context.PROVIDER_URL,url);
  this.setProperty(PARAM_USERDN,dn);
  this.setProperty(IASRealm.JAAS_CONTEXT_PARAM,jaasCtx);
  String mode=props.getProperty(PARAM_MODE,MODE_DEFAULT);
  if (!MODE_DEFAULT.equals(mode)) {
    String msg=sm.getString("String_Node_Str",mode);
    throw new BadRealmException(msg);
  }
  this.setProperty(PARAM_MODE,mode);
  String ctxF=props.getProperty(PARAM_JNDICF,JNDICF_DEFAULT);
  this.setProperty(PARAM_JNDICF,ctxF);
  ldapBindProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,ctxF);
  String searchFilter=props.getProperty(PARAM_SEARCH_FILTER,SEARCH_FILTER_DEFAULT);
  this.setProperty(PARAM_SEARCH_FILTER,searchFilter);
  String grpDN=props.getProperty(PARAM_GRPDN,dn);
  this.setProperty(PARAM_GRPDN,grpDN);
  String grpSearchFilter=props.getProperty(PARAM_GRP_SEARCH_FILTER,GRP_SEARCH_FILTER_DEFAULT);
  this.setProperty(PARAM_GRP_SEARCH_FILTER,grpSearchFilter);
  String grpTarget=props.getProperty(PARAM_GRP_TARGET,GRP_TARGET_DEFAULT);
  this.setProperty(PARAM_GRP_TARGET,grpTarget);
  String objectFactory=props.getProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,DYNAMIC_GROUP_OBJECT_FACTORY);
  this.setProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,objectFactory);
  ldapBindProps.setProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,objectFactory);
  String stateFactory=props.getProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,DYNAMIC_GROUP_STATE_FACTORY);
  this.setProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,stateFactory);
  ldapBindProps.setProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,stateFactory);
  String bindDN=props.getProperty(PARAM_BINDDN);
  if (bindDN != null) {
    this.setProperty(PARAM_BINDDN,bindDN);
    ldapBindProps.setProperty(Context.SECURITY_PRINCIPAL,bindDN);
  }
  String bindPWD=props.getProperty(PARAM_BINDPWD);
  if (bindPWD != null) {
    try {
      bindPWD=RelativePathResolver.getRealPasswordFromAlias(bindPWD);
    }
 catch (    Exception ex) {
      _logger.log(Level.WARNING,"String_Node_Str",ex);
    }
    this.setProperty(PARAM_BINDPWD,bindPWD);
    ldapBindProps.setProperty(Context.SECURITY_CREDENTIALS,bindPWD);
  }
  Enumeration penum=props.propertyNames();
  while (penum.hasMoreElements()) {
    String propName=(String)penum.nextElement();
    if (propName.startsWith("String_Node_Str") || propName.startsWith("String_Node_Str") || propName.startsWith("String_Node_Str")) {
      ldapBindProps.setProperty(propName,props.getProperty(propName));
    }
 else     if (propName.startsWith(SUN_JNDI_POOL_) && !SUN_JNDI_POOL_MAXSIZE.equals(propName)) {
      if (System.getProperty(propName) == null) {
        System.setProperty(propName,props.getProperty(propName));
      }
    }
  }
  String poolSize=Integer.getInteger(PARAM_POOLSIZE,POOLSIZE_DEFAULT).toString();
  String sunPoolSizeStr=props.getProperty(SUN_JNDI_POOL_MAXSIZE,poolSize);
  try {
    sunPoolSizeStr=Integer.valueOf(sunPoolSizeStr).toString();
  }
 catch (  Exception ex) {
    sunPoolSizeStr=poolSize;
  }
  if (System.getProperty(SUN_JNDI_POOL_MAXSIZE) == null) {
    System.setProperty(SUN_JNDI_POOL_MAXSIZE,sunPoolSizeStr);
  }
  this.setProperty(PARAM_POOLSIZE,sunPoolSizeStr);
  String usePool=props.getProperty(SUN_JNDI_POOL,"String_Node_Str");
  ldapBindProps.setProperty(SUN_JNDI_POOL,usePool);
  if (url != null && url.startsWith(LDAPS_URL)) {
    ldapBindProps.setProperty(LDAP_SOCKET_FACTORY,DEFAULT_SSL_LDAP_SOCKET_FACTORY);
    if (System.getProperty(SUN_JNDI_POOL_PROTOCOL) == null) {
      System.setProperty(SUN_JNDI_POOL_PROTOCOL,DEFAULT_POOL_PROTOCOL);
    }
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str");
    }
  }
  if (_logger.isLoggable(Level.FINE)) {
    Properties tempProps=(Properties)ldapBindProps.clone();
    tempProps.remove(Context.SECURITY_CREDENTIALS);
    _logger.log(Level.FINE,"String_Node_Str" + tempProps);
  }
  groupCache=new HashMap();
  emptyVector=new Vector();
}

Fixed version (ground truth):
/** 
 * Initialize a realm with some properties.  This can be used when instantiating realms from their descriptions.  This method may only be called a single time.  
 * @param props Initialization parameters used by this realm.
 * @exception BadRealmException If the configuration parametersidentify a corrupt realm.
 * @exception NoSuchRealmException If the configuration parametersspecify a realm which doesn't exist.
 */
public synchronized void init(Properties props) throws BadRealmException, NoSuchRealmException {
  super.init(props);
  String url=props.getProperty(PARAM_DIRURL);
  String dn=props.getProperty(PARAM_USERDN);
  String jaasCtx=props.getProperty(IASRealm.JAAS_CONTEXT_PARAM);
  if (url == null || dn == null || jaasCtx == null) {
    String msg=sm.getString("String_Node_Str",url,dn,jaasCtx);
    throw new BadRealmException(msg);
  }
  this.setProperty(PARAM_DIRURL,url);
  ldapBindProps.setProperty(Context.PROVIDER_URL,url);
  this.setProperty(PARAM_USERDN,dn);
  this.setProperty(IASRealm.JAAS_CONTEXT_PARAM,jaasCtx);
  String mode=props.getProperty(PARAM_MODE,MODE_DEFAULT);
  if (!MODE_DEFAULT.equals(mode)) {
    String msg=sm.getString("String_Node_Str",mode);
    throw new BadRealmException(msg);
  }
  this.setProperty(PARAM_MODE,mode);
  String ctxF=props.getProperty(PARAM_JNDICF,JNDICF_DEFAULT);
  this.setProperty(PARAM_JNDICF,ctxF);
  ldapBindProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,ctxF);
  String searchFilter=props.getProperty(PARAM_SEARCH_FILTER,SEARCH_FILTER_DEFAULT);
  this.setProperty(PARAM_SEARCH_FILTER,searchFilter);
  String grpDN=props.getProperty(PARAM_GRPDN,dn);
  this.setProperty(PARAM_GRPDN,grpDN);
  String grpSearchFilter=props.getProperty(PARAM_GRP_SEARCH_FILTER,GRP_SEARCH_FILTER_DEFAULT);
  this.setProperty(PARAM_GRP_SEARCH_FILTER,grpSearchFilter);
  String grpTarget=props.getProperty(PARAM_GRP_TARGET,GRP_TARGET_DEFAULT);
  this.setProperty(PARAM_GRP_TARGET,grpTarget);
  String objectFactory=props.getProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,DYNAMIC_GROUP_OBJECT_FACTORY);
  this.setProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,objectFactory);
  ldapBindProps.setProperty(DYNAMIC_GROUP_FACTORY_OBJECT_PROPERTY,objectFactory);
  String stateFactory=props.getProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,DYNAMIC_GROUP_STATE_FACTORY);
  this.setProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,stateFactory);
  ldapBindProps.setProperty(DYNAMIC_GROUP_STATE_FACTORY_PROPERTY,stateFactory);
  String bindDN=props.getProperty(PARAM_BINDDN);
  if (bindDN != null) {
    this.setProperty(PARAM_BINDDN,bindDN);
    ldapBindProps.setProperty(Context.SECURITY_PRINCIPAL,bindDN);
  }
  String bindPWD=props.getProperty(PARAM_BINDPWD);
  if (bindPWD != null) {
    try {
      bindPWD=RelativePathResolver.getRealPasswordFromAlias(bindPWD);
    }
 catch (    Exception ex) {
      _logger.log(Level.WARNING,"String_Node_Str",ex);
    }
    this.setProperty(PARAM_BINDPWD,bindPWD);
    ldapBindProps.setProperty(Context.SECURITY_CREDENTIALS,bindPWD);
  }
  Enumeration penum=props.propertyNames();
  while (penum.hasMoreElements()) {
    String propName=(String)penum.nextElement();
    if (propName.startsWith("String_Node_Str") || propName.startsWith("String_Node_Str") || propName.startsWith("String_Node_Str")) {
      ldapBindProps.setProperty(propName,props.getProperty(propName));
    }
 else     if (propName.startsWith(SUN_JNDI_POOL_) && !SUN_JNDI_POOL_MAXSIZE.equals(propName)) {
      if (System.getProperty(propName) == null) {
        System.setProperty(propName,props.getProperty(propName));
      }
    }
  }
  String poolSize=Integer.getInteger(PARAM_POOLSIZE,POOLSIZE_DEFAULT).toString();
  String sunPoolSizeStr=props.getProperty(SUN_JNDI_POOL_MAXSIZE,poolSize);
  try {
    sunPoolSizeStr=Integer.valueOf(sunPoolSizeStr).toString();
  }
 catch (  Exception ex) {
    sunPoolSizeStr=poolSize;
  }
  if (System.getProperty(SUN_JNDI_POOL_MAXSIZE) == null) {
    System.setProperty(SUN_JNDI_POOL_MAXSIZE,sunPoolSizeStr);
  }
  this.setProperty(PARAM_POOLSIZE,sunPoolSizeStr);
  String usePool=props.getProperty(SUN_JNDI_POOL,"String_Node_Str");
  ldapBindProps.setProperty(SUN_JNDI_POOL,usePool);
  if (url.startsWith(LDAPS_URL)) {
    ldapBindProps.setProperty(LDAP_SOCKET_FACTORY,DEFAULT_SSL_LDAP_SOCKET_FACTORY);
    if (System.getProperty(SUN_JNDI_POOL_PROTOCOL) == null) {
      System.setProperty(SUN_JNDI_POOL_PROTOCOL,DEFAULT_POOL_PROTOCOL);
    }
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str");
    }
  }
  if (_logger.isLoggable(Level.FINE)) {
    Properties tempProps=(Properties)ldapBindProps.clone();
    tempProps.remove(Context.SECURITY_CREDENTIALS);
    _logger.log(Level.FINE,"String_Node_Str" + tempProps);
  }
  groupCache=new HashMap();
  emptyVector=new Vector();
}