public void authenticate()

in nt/src/java/org/apache/fulcrum/security/nt/NTUserManagerImpl.java [159:198]


    public void authenticate(User user, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendException
    {
        NTSystem ntSystem = new NTSystem();
        char passwordArray[] = password.toCharArray();
        try
        {
            String username = ParseUtils.parseForUsername(user.getName());
            String domain = ParseUtils.parseForDomain(user.getName());
            ntSystem.logon(username, passwordArray, domain);
            if (!ntSystem.getName().equalsIgnoreCase(username))
            {
                throw new PasswordMismatchException("Could not authenticate user " + username + " against domain " + domain);
            }
            String groups[] = ntSystem.getGroupNames(false);
            for (String group2 : groups)
            {
                // Note how it populates groups? This
                // should maybe delegate a call to the
                // group manager to look for groups it
                // knows about instead.
                Group group = getGroupManager().getGroupInstance();
                group.setName(group2);
                group.setId(group2);
                if (user instanceof DynamicUser)
                {
                    ((DynamicUser) user).addGroup(group);
                }
                else if (user instanceof BasicUser)
                {
                    ((BasicUser) user).addGroup(group);
                }
            }
            ntSystem.logoff();
        }
        catch (LoginException le)
        {
            ntSystem.logoff();
            throw new DataBackendException(le.getMessage(), le);
        }
    }