Search in sources :

Example 1 with Cas20ProxyTicketValidator

use of org.jasig.cas.client.validation.Cas20ProxyTicketValidator in project ddf by codice.

the class CasProxyTicketValidator method setCasServerUrl.

public void setCasServerUrl(String serverUrl) {
    proxyTicketValidator = new Cas20ProxyTicketValidator(PropertyResolver.resolveProperties(serverUrl));
    proxyTicketValidator.setProxyCallbackUrl(proxyCallbackUrl.getResolvedString());
    proxyTicketValidator.setAcceptAnyProxy(acceptAnyProxy);
    proxyTicketValidator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
}
Also used : Cas20ProxyTicketValidator(org.jasig.cas.client.validation.Cas20ProxyTicketValidator)

Example 2 with Cas20ProxyTicketValidator

use of org.jasig.cas.client.validation.Cas20ProxyTicketValidator in project ddf by codice.

the class WebSSOTokenValidator method validate.

/**
     * Validate the CAS ticket and service
     *
     * @param ticket
     * @param service
     * @return
     * @throws TicketValidationException
     */
public Assertion validate(String ticket, String service) throws TicketValidationException {
    LOGGER.trace("CAS Server URL = {}", casServerUrl);
    Cas20ProxyTicketValidator casValidator = new Cas20ProxyTicketValidator(casServerUrl.getResolvedString());
    casValidator.setAcceptAnyProxy(true);
    return casValidator.validate(ticket, service);
}
Also used : Cas20ProxyTicketValidator(org.jasig.cas.client.validation.Cas20ProxyTicketValidator)

Example 3 with Cas20ProxyTicketValidator

use of org.jasig.cas.client.validation.Cas20ProxyTicketValidator in project mycore by MyCoRe-Org.

the class MCRCASServlet method doGetPost.

public void doGetPost(MCRServletJob job) throws Exception {
    HttpServletRequest req = job.getRequest();
    HttpServletResponse res = job.getResponse();
    String ticket = req.getParameter("ticket");
    if ((ticket == null) || (ticket.trim().length() == 0)) {
        res.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return;
    }
    // Validate ticket at CAS server
    Cas20ProxyTicketValidator sv = new Cas20ProxyTicketValidator(serverURL);
    sv.setAcceptAnyProxy(true);
    Assertion a = sv.validate(ticket, clientURL);
    AttributePrincipal principal = a.getPrincipal();
    // Get user name logged in
    String userName = principal.getName();
    LOGGER.info("Login {}", userName);
    MCRUser user;
    boolean userExists = MCRUserManager.exists(userName, realmID);
    if (userExists)
        user = MCRUserManager.getUser(userName, realmID);
    else
        user = new MCRUser(userName, realmID);
    // Get user properties from LDAP server
    boolean userChanged = MCRLDAPClient.instance().updateUserProperties(user);
    if (userChanged && userExists) {
        MCRUserManager.updateUser(user);
    }
    // Store login user in session and redirect browser to target url
    MCRSessionMgr.getCurrentSession().setUserInformation(user);
    // MCR-1154
    req.changeSessionId();
    MCRLoginServlet.redirect(res);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MCRUser(org.mycore.user2.MCRUser) Assertion(org.jasig.cas.client.validation.Assertion) HttpServletResponse(javax.servlet.http.HttpServletResponse) Cas20ProxyTicketValidator(org.jasig.cas.client.validation.Cas20ProxyTicketValidator) AttributePrincipal(org.jasig.cas.client.authentication.AttributePrincipal)

Aggregations

Cas20ProxyTicketValidator (org.jasig.cas.client.validation.Cas20ProxyTicketValidator)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AttributePrincipal (org.jasig.cas.client.authentication.AttributePrincipal)1 Assertion (org.jasig.cas.client.validation.Assertion)1 MCRUser (org.mycore.user2.MCRUser)1