public void loadConfig ( String config ) throws IOException { Properties properties = new Properties ( ) ; Resource resource = Resource . newResource ( config ) ; properties . load ( resource . getInputStream ( ) ) ; _jdbcDriver = properties . getProperty ( "jdbcdriver" ) ; _url = properties . getProperty ( "url" ) ; _userName = properties . getProperty ( "username" ) ; _password = properties . getProperty ( "password" ) ; _userTable = properties . getProperty ( "usertable" ) ; _userTableKey = properties . getProperty ( "usertablekey" ) ; _userTableUserField = properties . getProperty ( "usertableuserfield" ) ; _userTablePasswordField = properties . getProperty ( "usertablepasswordfield" ) ; _roleTable = properties . getProperty ( "roletable" ) ; _roleTableKey = properties . getProperty ( "roletablekey" ) ; _roleTableRoleField = properties . getProperty ( "roletablerolefield" ) ; _userRoleTable = properties . getProperty ( "userroletable" ) ; _userRoleTableUserKey = properties . getProperty ( "userroletableuserkey" ) ; _userRoleTableRoleKey = properties . getProperty ( "userroletablerolekey" ) ; _cacheTime = new Integer ( properties . getProperty ( "cachetime" ) ) . intValue ( ) ; if ( _jdbcDriver == null || _jdbcDriver . equals ( "" ) || _url == null || _url . equals ( "" ) || _userName == null || _userName . equals ( "" ) || _password == null || _cacheTime < 0 ) { if ( log . isDebugEnabled ( ) ) log . debug ( "UserRealm " + getName ( ) + " has not been properly configured" ) ; } _cacheTime *= 1000 ; _lastHashPurge = 0 ; _userSql = "select " + _userTableKey + "," + _userTablePasswordField + " from " + _userTable + " where " + _userTableUserField + " = ?" ; _roleSql = "select r." + _roleTableRoleField + " from " + _roleTable + " r, " + _userRoleTable + " u where u." + _userRoleTableUserKey + " = ?" + " and r." + _roleTableKey + " = u." + _userRoleTableRoleKey ; }
Load JDBC connection configuration from properties file .