Package org.ofbiz.common.authentication.api

Examples of org.ofbiz.common.authentication.api.AuthenticatorException


    public boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException {
        String token;
        try {
            token = callAuthenticate(username, password);
        } catch (RemoteException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }
        Debug.logInfo("Crowd auth called; returned token: " + token, module);
        return token != null;
    }
View Full Code Here


    public void syncUser(String username) throws AuthenticatorException {
        UserWrapper user;
        try {
            user = callGetUser(username);
        } catch (RemoteException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }

        GenericValue system;
        try {
            system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true);
        } catch (GenericEntityException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }

        GenericValue userLogin;
        try {
            userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", user.getName()), false);
        } catch (GenericEntityException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }

        // suspend the current transaction and load the user
        Transaction parentTx = null;
        boolean beganTransaction = false;
View Full Code Here

        createPersonUlMap.put("userLogin", system);
        Map<String, Object> createPersonResult;
        try {
            createPersonResult = dispatcher.runSync("createPersonAndUserLogin", createPersonUlMap);
        } catch (GenericServiceException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }
        if (ServiceUtil.isError(createPersonResult)) {
            throw new AuthenticatorException(ServiceUtil.getErrorMessage(createPersonResult));
        }
        String partyId = (String) createPersonResult.get("partyId");

        // create email
        Map<String, Serializable> createEmailMap = FastMap.newInstance();
        createEmailMap.put("emailAddress", user.getUserAttributeMapper().getEmail());
        createEmailMap.put("contactMechPurposeTypeId", "PRIMARY_EMAIL");
        createEmailMap.put("partyId", partyId);
        createEmailMap.put("userLogin", system);
        Map<String, Object> createEmailResult;
        try {
            createEmailResult = dispatcher.runSync("createPartyEmailAddress", createEmailMap);
        } catch (GenericServiceException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }
        if (ServiceUtil.isError(createEmailResult)) {
            throw new AuthenticatorException(ServiceUtil.getErrorMessage(createEmailResult));
        }

        // create security group(s)
        Timestamp now = UtilDateTime.nowTimestamp();
        for (String securityGroup : user.getUserGroupMapper().getSecurityGroups()) {
            // check and make sure the security group exists
            GenericValue secGroup = null;
            try {
                secGroup = delegator.findOne("SecurityGroup", UtilMisc.toMap("groupId", securityGroup), true);
            } catch (GenericEntityException e) {
                Debug.logError(e, e.getMessage(), module);
            }

            // add it to the user if it exists
            if (secGroup != null) {
                Map<String, Serializable> createSecGrpMap = FastMap.newInstance();
                createSecGrpMap.put("userLoginId", user.getName());
                createSecGrpMap.put("groupId", securityGroup);
                createSecGrpMap.put("fromDate", now);
                createSecGrpMap.put("userLogin", system);

                Map<String, Object> createSecGrpResult;
                try {
                    createSecGrpResult = dispatcher.runSync("addUserLoginToSecurityGroup", createSecGrpMap);
                } catch (GenericServiceException e) {
                    throw new AuthenticatorException(e.getMessage(), e);
                }
                if (ServiceUtil.isError(createSecGrpResult)) {
                    throw new AuthenticatorException(ServiceUtil.getErrorMessage(createSecGrpResult));
                }
            }
        }
    }
View Full Code Here

    public void updatePassword(String username, String password, String newPassword) throws AuthenticatorException {
        Debug.logInfo("Calling Crowd:updatePassword() - " + newPassword, module);
        try {
            callUpdatePassword(username, newPassword);
        } catch (RemoteException e) {
            throw new AuthenticatorException(e.getMessage(), e);
        }
    }
View Full Code Here

    protected static List<Authenticator> authenticators = new ArrayList<Authenticator>();
    protected static boolean authenticatorsLoaded = false;


    public static boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException {
        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
        for (Authenticator auth : authenticators) {
            boolean pass = auth.authenticate(username, password, isServiceAuth);
            if (pass) {
                return true;
            } else if (auth.isSingleAuthenticator()) {
                throw new AuthenticatorException();
            }
        }
        return false;
    }
View Full Code Here

        }
        return false;
    }

    public static void logout(String username) throws AuthenticatorException {
        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
        for (Authenticator auth : authenticators) {
            auth.logout(username);
        }
    }
View Full Code Here

            auth.logout(username);
        }
    }

    public static void syncUser(String username) throws AuthenticatorException {
        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
        for (Authenticator auth : authenticators) {
            if (auth.isUserSynchronized()) {
                auth.syncUser(username);
            }
        }
View Full Code Here

            }
        }
    }

    public static void updatePassword(String username, String password, String newPassword) throws AuthenticatorException {
        if (!authenticatorsLoaded) throw new AuthenticatorException("Authenticators never loaded; be sure to call AuthHelper.loadAuthenticators()");
        for (Authenticator auth : authenticators) {
            auth.updatePassword(username, password, newPassword);
        }
    }
View Full Code Here

TOP

Related Classes of org.ofbiz.common.authentication.api.AuthenticatorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.