@Override
    public void authenticate(String username, String password) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException {
        if (manager == null) {
            throw new ConnectionException("Unable to connect to Crowd");
        }

        if (username == null || password == null || password.trim().isEmpty()) {
            throw new UnauthorizedException();
        }

        if (username.contains("@")) {
            // Check that the specified domain matches the server's domain
            int index = username.indexOf("@");
            String domain = username.substring(index + 1);
            if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) {
                username = username.substring(0, index);
            } else {
                // Unknown domain. Return authentication failed.
                throw new UnauthorizedException();
            }
        }

        try {
            manager.authenticate(username, password);
        } catch (RemoteException re) {
            throw new UnauthorizedException();
        }
    }
Returns if the username and password are valid; otherwise this
method throws an UnauthorizedException.<p>

@param username the username or full JID.
@param password the password
@throws UnauthorizedException if the username and password do
     not match any existing user.
@throws ConnectionException it there is a problem connecting to user and group system
@throws InternalUnauthenticatedException if there is a problem authentication Openfire itself into the user and group system
xmppserver/src/main/java/org/jivesoftware/openfire/crowd/CrowdAuthProvider.java