Example usage for com.liferay.portal.kernel.util PropsKeys CAS_SERVER_URL

List of usage examples for com.liferay.portal.kernel.util PropsKeys CAS_SERVER_URL

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys CAS_SERVER_URL.

Prototype

String CAS_SERVER_URL

To view the source code for com.liferay.portal.kernel.util PropsKeys CAS_SERVER_URL.

Click Source Link

Usage

From source file:com.ext.portal.servlet.filters.sso.cas.CASFilterExt.java

License:Open Source License

protected TicketValidator getTicketValidator(long companyId) throws Exception {

    TicketValidator ticketValidator = _ticketValidators.get(companyId);

    if (ticketValidator != null) {
        return ticketValidator;
    }//from   w w  w  . j  a  v a2 s  .c o m

    String serverName = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_NAME,
            PropsValues.CAS_SERVER_NAME);
    String serverUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_URL,
            PropsValues.CAS_SERVER_URL);
    String loginUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGIN_URL, PropsValues.CAS_LOGIN_URL);

    Cas20ProxyTicketValidator cas20ProxyTicketValidator = new Cas20ProxyTicketValidator(serverUrl);

    Map<String, String> parameters = new HashMap<String, String>();

    parameters.put("serverName", serverName);
    parameters.put("casServerUrlPrefix", serverUrl);
    parameters.put("casServerLoginUrl", loginUrl);
    parameters.put("redirectAfterValidation", "false");

    cas20ProxyTicketValidator.setCustomParameters(parameters);

    _ticketValidators.put(companyId, cas20ProxyTicketValidator);

    return cas20ProxyTicketValidator;
}

From source file:com.liferay.portlet.portalsettings.action.EditCompanyAction.java

License:Open Source License

protected void validateCAS(ActionRequest actionRequest) throws Exception {
    boolean casEnabled = ParamUtil.getBoolean(actionRequest, "settings--" + PropsKeys.CAS_AUTH_ENABLED + "--");

    if (!casEnabled) {
        return;/*from ww w. j a v a  2  s .c  o m*/
    }

    String casLoginURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGIN_URL + "--");
    String casLogoutURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_LOGOUT_URL + "--");
    String casServerName = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_NAME + "--");
    String casServerURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVER_URL + "--");
    String casServiceURL = ParamUtil.getString(actionRequest, "settings--" + PropsKeys.CAS_SERVICE_URL + "--");
    String casNoSuchUserRedirectURL = ParamUtil.getString(actionRequest,
            "settings--" + PropsKeys.CAS_NO_SUCH_USER_REDIRECT_URL + "--");

    if (!Validator.isUrl(casLoginURL)) {
        SessionErrors.add(actionRequest, "casLoginURLInvalid");
    }

    if (!Validator.isUrl(casLogoutURL)) {
        SessionErrors.add(actionRequest, "casLogoutURLInvalid");
    }

    if (Validator.isNull(casServerName)) {
        SessionErrors.add(actionRequest, "casServerNameInvalid");
    }

    if (Validator.isNotNull(casServerURL) && Validator.isNotNull(casServiceURL)) {

        SessionErrors.add(actionRequest, "casServerURLAndServiceURLConflict");
    } else if (Validator.isNull(casServerURL) && Validator.isNull(casServiceURL)) {

        SessionErrors.add(actionRequest, "casServerURLAndServiceURLNotSet");
    } else {
        if (Validator.isNotNull(casServerURL) && !Validator.isUrl(casServerURL)) {

            SessionErrors.add(actionRequest, "casServerURLInvalid");
        }

        if (Validator.isNotNull(casServiceURL) && !Validator.isUrl(casServiceURL)) {

            SessionErrors.add(actionRequest, "casServiceURLInvalid");
        }
    }

    if (Validator.isNotNull(casNoSuchUserRedirectURL) && !Validator.isUrl(casNoSuchUserRedirectURL)) {

        SessionErrors.add(actionRequest, "casNoSuchUserURLInvalid");
    }
}

From source file:es.uib.owu.liferay.cas.service.impl.CasServiceUtilLocalServiceImpl.java

License:Open Source License

private TicketValidator getTicketValidator(long companyId, String proxyReceptorUrl, String allowAnyProxy,
        String allowedProxyChains, boolean renew) throws SystemException {
    if (_log.isDebugEnabled())
        _log.debug("getTicketValidator");
    Cas20ServiceTicketValidator ticketValidator = _ticketValidators.get(Long.valueOf(companyId));
    //Cas20ServiceTicketValidator ticketValidator = (Cas20ServiceTicketValidator) _ticketValidators.get(Long.valueOf(companyId));

    if (ticketValidator != null) {
        return ticketValidator;
    }//from   www  .  ja va 2s .c o  m

    String serverName = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_NAME,
            PropsUtil.get(PropsKeys.CAS_SERVER_NAME));
    String casServerUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_URL,
            PropsUtil.get(PropsKeys.CAS_SERVER_URL));
    String casLoginUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGIN_URL,
            PropsUtil.get(PropsKeys.CAS_LOGIN_URL));

    if ((CommonUtils.isNotBlank(allowAnyProxy) || CommonUtils.isNotBlank(allowedProxyChains))) {
        final Cas20ProxyTicketValidator v = new Cas20ProxyTicketValidator(casServerUrl);
        v.setAcceptAnyProxy(PrefsPropsUtil.getBoolean(allowAnyProxy));
        v.setAllowedProxyChains(createProxyList(allowedProxyChains));
        ticketValidator = v;
        if (_log.isDebugEnabled()) {
            _log.debug("Cas20ProxyTicketValidator");
            _log.debug("-setAcceptAnyProxy: " + allowAnyProxy);
            _log.debug("-setAllowedProxyChains: " + allowedProxyChains);
        }
    } else {
        ticketValidator = new Cas20ServiceTicketValidator(casServerUrl);
        if (_log.isDebugEnabled()) {
            _log.debug("Cas20ServiceValidator");
        }
    }

    if (proxyReceptorUrl != null) {
        ticketValidator.setProxyCallbackUrl(serverName + proxyReceptorUrl);
        ProxyGrantingTicketStorageImpl proxyGrantingTicketStorage = getPGTSI();
        if (_log.isDebugEnabled()) {
            _log.debug("Cas20ServiceValidator assigname proxyGrantingTicketStorage: "
                    + proxyGrantingTicketStorage);
        }
        ticketValidator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
    }

    ticketValidator.setRenew(renew);

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("serverName", serverName);
    parameters.put("casServerUrlPrefix", casServerUrl);
    parameters.put("casServerLoginUrl", casLoginUrl);
    parameters.put("redirectAfterValidation", "false");

    if (allowAnyProxy != null)
        parameters.put("allowAnyProxy", allowAnyProxy);

    ticketValidator.setCustomParameters(parameters);
    _ticketValidators.put(Long.valueOf(companyId), ticketValidator);

    if (_log.isDebugEnabled()) {
        _log.debug("Returning cas20ProxyTicketValidator with..");
        _log.debug("- serverName: " + serverName);
        _log.debug("- casServerUrlPrefix: " + casServerUrl);
        _log.debug("- casServerLoginUrl: " + casLoginUrl);
        if (proxyReceptorUrl != null)
            _log.debug("- proxyCallbackUrl: " + serverName + proxyReceptorUrl);

    }

    return ticketValidator;

}

From source file:es.uib.owu.liferay.cas.service.impl.CasServiceUtilLocalServiceImpl.java

License:Open Source License

public String constructServiceUrl(Long companyId, HttpServletRequest request, HttpServletResponse response)
        throws SystemException {
    String casServerName = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_NAME,
            PropsUtil.get(PropsKeys.CAS_SERVER_NAME));
    String casServiceUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVICE_URL,
            PropsUtil.get(PropsKeys.CAS_SERVICE_URL));
    String casServerUrl = PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_URL,
            PropsUtil.get(PropsKeys.CAS_SERVER_URL));
    return CommonUtils.constructServiceUrl(request, response, casServiceUrl, casServerName, "ticket", true); //ENCODEURL TRUE

}