Example usage for com.liferay.portal.service.http UserServiceHttp getUserByScreenName

List of usage examples for com.liferay.portal.service.http UserServiceHttp getUserByScreenName

Introduction

In this page you can find the example usage for com.liferay.portal.service.http UserServiceHttp getUserByScreenName.

Prototype

public static com.liferay.portal.kernel.model.User getUserByScreenName(HttpPrincipal httpPrincipal,
            long companyId, String screenName) throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Usage

From source file:org.kmworks.liferay.rpc.utils.AuthToken.java

License:Open Source License

private void getTokenData() {
    try {/*from w ww  .j  a  v  a2s  .c  om*/
        String virtualHost = getVirtualHost();
        if (virtualHost == null) {
            throw new PortalException(
                    "Cannot parse virtual host name from malformed portal URI: " + err.getMessage());
        }

        Company company = CompanyServiceHttp.getCompanyByVirtualHost(principal, virtualHost);
        if (company == null) {
            throw new PortalException("Cannot find company record for virtual host: " + virtualHost);
        }
        long companyId = company.getCompanyId();
        principal.setCompanyId(companyId);

        user = UserServiceHttp.getUserByScreenName(principal, principal.getCompanyId(), principal.getLogin());
        if (user == null) {
            throw new PortalException("Cannot find user record for: " + principal.getLogin());
        }

        authenticationResult = RPCExtensionsHttp.authenticateUser(clone(principal, plainPassword));
        if (authenticationResult != user.getUserId()) {
            throw new PortalException("Cannot authenticate user: " + principal.getLogin());
        }

    } catch (PortalException | SystemException ex) {
        err = ex;
    }
}