java - Line argument must contain a key and a value. Only one string token was found. shiro.ini -


this error:

error statuslogger no log4j2 configuration file found. using default configuration: logging errors console. exception in thread "main" java.lang.illegalargumentexception: line argument must contain key , value. 1 string token found. @ org.apache.shiro.config.ini$section.splitkeyvalue(ini.java:542) @ org.apache.shiro.config.ini$section.tomapprops(ini.java:567) @ org.apache.shiro.config.ini$section.(ini.java:464) @ org.apache.shiro.config.ini$section.(ini.java:445) @ org.apache.shiro.config.ini.addsection(ini.java:302) @ org.apache.shiro.config.ini.load(ini.java:351) @ org.apache.shiro.config.ini.load(ini.java:287) @ org.apache.shiro.config.ini.load(ini.java:275) @ org.apache.shiro.config.ini.loadfrompath(ini.java:244) @ org.apache.shiro.config.ini.fromresourcepath(ini.java:225) @ org.apache.shiro.config.inisecuritymanagerfactory.(inisecuritymanagerfactory.java:69) @ com.ldapconsole.consoleldaplogin.shirointegration(consoleldaplogin.java:50) @ com.ldapconsole.consoleldaplogin.main(consoleldaplogin.java:32)

** shiro.ini file :**

[users] # user 'root' password 'secret' , 'admin' role root = secret, admin  # user 'employee1' 'commonuser' role employee1=passwd, commonuser  # user 'employee2' 'developer' , 'hr' role employee2=passwd, developer, hr  # -----------------------------------------------------------------------------  [roles] # 'admin' role has permissions, indicated wildcard '*' admin = * # 'hr' role can (*) management: hr = management:* # 'developer' role allowed 'access system' (action) added (type) 'develop software' developer = added:systemaccess:developsoftware  # -----------------------------------------------------------------------------  [main] #ds =  com.mysql.jdbc.driver #ds = com.mysql.jdbc.jdbc2.optional.mysqldatasource  ds = org.sqlite.jdbc @property @syntesize ds.databasename = jdbc:sqlite:getclass().getclassloader().getresourceasstream(usersroles.db)  jdbcrealm = org.apache.shiro.realm.jdbc.jdbcrealm jdbcrealm.datasource = $ds jdbcrealm.permissionslookupenabled = true jdbcrealm.authenticationquery = "select upasswd userslist uname = ?" jdbcrealm.userrolesquery = "select urole userslist uname = ?" jdbcrealm.permissionsquery = "select upermission rolespermission urole = ?" #securitymanager.realms = $jdbcrealm 

consoleldaplogin.java file

package com.ldapconsole;  import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import org.apache.shiro.securityutils; import org.apache.shiro.authc.authenticationexception; import org.apache.shiro.authc.usernamepasswordtoken; import org.apache.shiro.config.inisecuritymanagerfactory; import org.apache.shiro.mgt.defaultsecuritymanager; import org.apache.shiro.mgt.securitymanager; import org.apache.shiro.realm.jdbc.jdbcrealm; import org.apache.shiro.subject.subject; import org.apache.shiro.util.factory; import org.apache.log4j.logger;  public class consoleldaplogin {          private static logger log=logger.getlogger(consoleldaplogin.class);         static string username="";         static string passwd="";          public static void main(string[] args){              /*  bufferedreader br=new bufferedreader(new inputstreamreader(system.in));                      try {                 system.out.println("enter username: ");                 username=br.readline();                 system.out.println("enter password: ");                 passwd=br.readline();                            */                   shirointegration(username,passwd);              /*  } catch (ioexception e) {                 log.info("ioexception : "+e);             }             finally{                  if (br != null) {                         try {                             br.close();                         } catch (ioexception e) {                             log.info("ioexception : "+e);                         }                     }             }*/         }          public static void shirointegration(string uname,string passwd)         {             factory<securitymanager> factory= new inisecuritymanagerfactory("classpath:shiro.ini");             securitymanager securitymanager=factory.getinstance();             securityutils.setsecuritymanager(securitymanager);             subject currentuser = securityutils.getsubject();             /*arraylist<string> roleidentifiers = new arraylist<string>(arrays.aslist("admin","commonuser"));*/             if ( !currentuser.isauthenticated() ) {                 usernamepasswordtoken token = new usernamepasswordtoken(uname, passwd);                 token.setrememberme(true);                 try {                     currentuser.login(token);                     log.info( "user " + currentuser.getprincipal() + " logged in successfully." );                     //currentuser.getclass().get                     /*currentuser.checkroles(roleidentifiers);*/                     if (currentuser.hasrole("admin")) {                         log.info( "logged in user " + currentuser.getprincipal() + " admin." );                      } else if(currentuser.hasrole("commonuser")) {                         log.info( "logged in user " + currentuser.getprincipal() + " commonuser" );                     }else{                          // key "jdbcrealm" must same in shiro.ini file.                         jdbcrealm realm = (jdbcrealm) ((inisecuritymanagerfactory) factory).getbeans().get("jdbcrealm");                         //realm.setpermissionslookupenabled(true);                          defaultsecuritymanager security = new defaultsecuritymanager(realm);                         securityutils.setsecuritymanager(securitymanager);                         subject loginuser = securityutils.getsubject();                           if(loginuser.isauthenticated()){                                usernamepasswordtoken logintoken = new usernamepasswordtoken("sroot", "sroot");                                  logintoken.setrememberme(true);                                  loginuser.login(logintoken);                                log.info("login sqlite user successfully...");                         }                          //realm.getauthorizationinfo(securityutils.getsubject().getprincipals()).getstringpermissions();                     }                 } catch (authenticationexception e) {                     log.info("authenticationexception : "+e.getmessage());                 }             }         }           /*** autenticates user **/         /*public static subject authenticate(string username, string pass) {              final string roles_query = "select access_designation access_level,users access_level.id=users.access_level_id , users.username = ?" ;             subject currentuser = null;             try {             factory<org.apache.shiro.mgt.securitymanager> factory = new inisecuritymanagerfactory("classpath:shiro.ini");     org.apache.shiro.mgt.securitymanager securitymanager = factory.getinstance();                 // key "jdbcrealm" must same in shiro.ini file.      jdbcrealm realm = (jdbcrealm) ((inisecuritymanagerfactory) factory).getbeans().get("jdbcrealm");                 realm.setauthenticationquery(authentication_query);                 realm.setuserrolesquery(roles_query);                  securityutils.setsecuritymanager(securitymanager);                  currentuser = securityutils.getsubject();                  usernamepasswordtoken token = new usernamepasswordtoken(username, pass);                  currentuser.login(token);              } catch (exception e) {                 e.printstacktrace();             }             return currentuser;          }*/        } 

my try solve errors:

  1. just before solved error shiro.ini file , "property 'databasename' not found org.sqlite.jdbc" solve 1 added 2 annotations before line @property @syntesize.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -