Example usage for com.liferay.portal.kernel.security.auth AuthException AuthException

List of usage examples for com.liferay.portal.kernel.security.auth AuthException AuthException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.auth AuthException AuthException.

Prototype

public AuthException(String msg, Throwable cause) 

Source Link

Usage

From source file:blade.authenticator.shiro.ShiroAuthenticatorPre.java

License:Apache License

@Override
public int authenticateByEmailAddress(long companyId, String emailAddress, String password,
        Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {

    _log.info("authenticateByEmailAddress");

    UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(emailAddress, password);

    Subject currentUser = SecurityUtils.getSubject();

    try {/*from  w w w .j a  va 2s .  c  om*/
        currentUser.login(usernamePasswordToken);

        boolean authenticated = currentUser.isAuthenticated();

        if (authenticated) {
            _log.info("authenticated");
            return SKIP_LIFERAY_CHECK;
        } else {
            return FAILURE;
        }
    } catch (AuthenticationException e) {
        _log.error(e.getMessage(), e);
        throw new AuthException(e.getMessage(), e);
    }
}

From source file:com.liferay.blade.samples.authenticator.shiro.ShiroAuthenticatorPre.java

License:Apache License

@Override
public int authenticateByEmailAddress(long companyId, String emailAddress, String password,
        Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {

    if (_log.isInfoEnabled()) {
        _log.info("authenticateByEmailAddress");
    }//from w ww.  j av  a2  s. c  o m

    UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(emailAddress, password);

    Subject currentUser = SecurityUtils.getSubject();

    try {
        currentUser.login(usernamePasswordToken);

        boolean authenticated = currentUser.isAuthenticated();

        if (authenticated) {
            if (_log.isInfoEnabled()) {
                _log.info("authenticated");
            }

            return SKIP_LIFERAY_CHECK;
        } else {
            return FAILURE;
        }
    } catch (AuthenticationException ae) {
        _log.error(ae.getMessage(), ae);
        throw new AuthException(ae.getMessage(), ae);
    }
}