On Fri, 2019-01-25 at 09:50 +0530, Kanishka kumar wrote:
> Hey Andreas ,According to the documentThe getSubject() call in a
> standalone application might return a Subject based on user data in
> an application-specific location

Hi Kanishka,

not sure if I understand your question right, but for me it looks like
this:

      // 1. Load the INI configuration with the Custom JDBC Realm
    Ini ini = new Ini();
    ini.load(ClassLoader.getSystemResourceAsStream("com/manticore/commo
n/auth/shiro.ini"));
    Factory<SecurityManager> factory = new
IniSecurityManagerFactory(ini);


    // 2. Create the SecurityManager
    SecurityManager securityManager = factory.getInstance();


    // 3. Make it accessible
    SecurityUtils.setSecurityManager(securityManager);


    // 4. Acquire submitted principals and credentials:
    UsernamePasswordToken token = new UsernamePasswordToken("VBox",
"1508Reporting");


    //”Remember Me” built-in:
    token.setRememberMe(true);


    // 5. Get the current Subject:
    Subject currentUser = SecurityUtils.getSubject();


    logger.info("Try to log in");
    
    // 6. Login, throws an exception on failure
    currentUser.login(token);
    
    // 7. at this point we have authenticated
    logger.info("Logged in");

Best regards
Andreas

Reply via email to