public boolean login()

in jaas/jaas-modules/src/main/java/org/apache/servicemix/kernel/jaas/modules/properties/PropertiesLoginModule.java [70:117]


    public boolean login() throws LoginException {
        Properties users = new Properties();
        File f = new File(usersFile);
        try {
            users.load(new java.io.FileInputStream(f));
        } catch (IOException ioe) {
            throw new LoginException("Unable to load user properties file " + f);
        }

        Callback[] callbacks = new Callback[2];

        callbacks[0] = new NameCallback("Username: ");
        callbacks[1] = new PasswordCallback("Password: ", false);
        try {
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw new LoginException(ioe.getMessage());
        } catch (UnsupportedCallbackException uce) {
            throw new LoginException(uce.getMessage() + " not available to obtain information from user");
        }
        user = ((NameCallback) callbacks[0]).getName();
        char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword();
        if (tmpPassword == null) {
            tmpPassword = new char[0];
        }

        String userInfos = (String) users.get(user);
        if (userInfos == null) {
            throw new FailedLoginException("User does not exist");
        }
        String[] infos = userInfos.split(",");
        if (!new String(tmpPassword).equals(infos[0])) {
            throw new FailedLoginException("Password does not match");
        }

        principals = new HashSet<Principal>();
        principals.add(new UserPrincipal(user));
        for (int i = 1; i < infos.length; i++) {
            principals.add(new RolePrincipal(infos[i]));
        }

        users.clear();

        if (debug) {
            LOG.debug("login " + user);
        }
        return true;
    }