Examples of CASReceipt


Examples of com.discursive.cas.extend.client.CASReceipt

        }

        HttpSession session = ((HttpServletRequest) request).getSession();

        // if our attribute's already present and valid, pass through the filter chain
        CASReceipt receipt = (CASReceipt) session.getAttribute(CAS_FILTER_RECEIPT);
        if (receipt != null && isReceiptAcceptable(receipt)) {
            log.trace("CAS_FILTER_RECEIPT attribute was present and acceptable - passing  request through filter..");
            fc.doFilter(request, response);
            return;
        }

        // otherwise, we need to authenticate via CAS
        String ticket = request.getParameter("ticket");

        // no ticket?  abort request processing and redirect
        if (ticket == null || ticket.equals("")) {
            log.trace("CAS ticket was not present on request.");
            // did we go through the gateway already?
            boolean didGateway =
                Boolean
                    .valueOf(
                        (String) session.getAttribute(
                            CAS_FILTER_GATEWAYED))
                    .booleanValue();

            if (casConfig.getCasLogin() == null) {
                //TODO: casLogin should probably be ensured to not be null at filter initialization. -awp9
                log.fatal("casLogin was not set, so filter cannot redirect request for authentication.");
                throw new ServletException(
                    "When CASFilter protects pages that do not receive a 'ticket' "
                        + "parameter, it needs a com.discursive.cas.extend.client.filter.loginUrl "
                        + "filter parameter");
            }
            if (!didGateway) {
                log.trace("Did not previously gateway.  Setting session attribute to true.");
                session.setAttribute(
                    CAS_FILTER_GATEWAYED,
                    "true");
                redirectToCAS(
                    (HttpServletRequest) request,
                    (HttpServletResponse) response);
                // abort chain
                return;
            } else {
                log.trace("Previously gatewayed.");
                // if we should be logged in, make sure validation succeeded
                if (casConfig.isCasGateway()
                    || session.getAttribute(CAS_FILTER_USER) != null) {
                      log.trace("casGateway was true and CAS_FILTER_USER set: passing request along filter chain.");
                    // continue processing the request
                    fc.doFilter(request, response);
                    return;
                } else {
                    // unknown state... redirect to CAS
                    session.setAttribute(
                        CAS_FILTER_GATEWAYED,
                        "true");
                    redirectToCAS(
                        (HttpServletRequest) request,
                        (HttpServletResponse) response);
                    // abort chain
                    return;
                }
            }
        }


        try {
            receipt = getAuthenticatedUser((HttpServletRequest) request);
        } catch (CASAuthenticationException e) {
            log.error(e);
            throw new ServletException(e);
        }

        if (! isReceiptAcceptable(receipt)){
            throw new ServletException("Authentication was technically successful but rejected as a matter of policy. [" + receipt + "]");
        }
       
        // Store the authenticated user in the session
        if (session != null) { // probably unnecessary
            session.setAttribute(CAS_FILTER_USER, receipt.getUserName());
            session.setAttribute(CASFilter.CAS_FILTER_RECEIPT, receipt);
            // don't store extra unnecessary session state
            session.removeAttribute(
                CAS_FILTER_GATEWAYED);
        }
View Full Code Here

Examples of com.discursive.cas.extend.client.CASReceipt

        }
        if (! (potentialReceipt instanceof CASReceipt)) {
            log.warn("An object was present in the session attribute " + CASFilter.CAS_FILTER_RECEIPT + " but it wasn't of type " + CASReceipt.class.getName());
            return false;
        }
        CASReceipt receipt = (CASReceipt) potentialReceipt;
       
        if (! this.authorizedProxyChains.contains(receipt.getProxyList())){
            log.info("CAS receipt: " + receipt + " did not present a proxy chain among those authorized: " + this.authorizedProxyChains + " - considering request unauthorized.");
            return false;
        }
        log.trace("returning from isRequestAuthorized() with true");
        return true;
View Full Code Here

Examples of com.discursive.cas.extend.client.CASReceipt

        HttpSession session = ((HttpServletRequest) request).getSession();

        // if our attribute's already present and valid, pass through the filter
        // chain
        CASReceipt receipt = (CASReceipt) session
                .getAttribute(CAS_FILTER_RECEIPT);
        if (receipt != null) {
            log
                    .trace("CAS_FILTER_RECEIPT attribute was present - passing  request through filter..");
            fc.doFilter(request, response);
            return;
        }

        // otherwise, we need to authenticate via CAS
        String ticket = request.getParameter("ticket");

        // no ticket? no validation to be done, pass the request through.
        if (ticket == null || ticket.equals("")) {
            log.trace("CAS ticket was not present on request.");
            fc.doFilter(request, response);
            return;
        }

        try {
            receipt = getAuthenticatedUser((HttpServletRequest) request);
        } catch (CASAuthenticationException e) {
            log.error(e);
            throw new ServletException(e);
        }

        // Store the authenticated user in the session
        if (session != null) { // probably unnecessary
            session.setAttribute(CAS_FILTER_USER, receipt.getUserName());
            session.setAttribute(CASValidateFilter.CAS_FILTER_RECEIPT, receipt);
        }
        if (log.isTraceEnabled()) {
            log.trace("validated ticket to get authenticated receipt ["
                    + receipt + "], now passing request along filter chain.");
View Full Code Here

Examples of com.discursive.cas.extend.client.CASReceipt

        HttpSession session = ((HttpServletRequest) request).getSession();

        // if our attribute's already present and valid, pass through the filter
        // chain
        CASReceipt receipt = (CASReceipt) session
                .getAttribute(CASFilter.CAS_FILTER_RECEIPT);

        // otherwise, we need to authenticate via CAS
        String ticket = request.getParameter("ticket");
View Full Code Here

Examples of com.discursive.cas.extend.client.CASReceipt

        }

        HttpSession session = ((HttpServletRequest) request).getSession();

        // if our attribute's already present and valid, pass through the filter chain
        CASReceipt receipt = (CASReceipt) session.getAttribute(CAS_FILTER_RECEIPT);
        if (receipt != null && isReceiptAcceptable(receipt)) {
            log.trace("CAS_FILTER_RECEIPT attribute was present and acceptable - passing  request through filter..");
            fc.doFilter(request, response);
            return;
        }

        // otherwise, we need to authenticate via CAS
        String ticket = request.getParameter("ticket");

        // no ticket?  abort request processing and redirect
        if (ticket == null || ticket.equals("")) {
            log.trace("CAS ticket was not present on request.");
            // did we go through the gateway already?
            boolean didGateway =
                Boolean
                    .valueOf(
                        (String) session.getAttribute(
                            CAS_FILTER_GATEWAYED))
                    .booleanValue();

            if (casConfig.getCasLogin() == null) {
                //TODO: casLogin should probably be ensured to not be null at filter initialization. -awp9
                log.fatal("casLogin was not set, so filter cannot redirect request for authentication.");
                throw new ServletException(
                    "When CASFilter protects pages that do not receive a 'ticket' "
                        + "parameter, it needs a com.discursive.cas.extend.client.filter.loginUrl "
                        + "filter parameter");
            }
            if (!didGateway) {
                log.trace("Did not previously gateway.  Setting session attribute to true.");
                session.setAttribute(
                    CAS_FILTER_GATEWAYED,
                    "true");
                redirectToCAS(
                    (HttpServletRequest) request,
                    (HttpServletResponse) response);
                // abort chain
                return;
            } else {
                log.trace("Previously gatewayed.");
                // if we should be logged in, make sure validation succeeded
                if (casConfig.isCasGateway()
                    || session.getAttribute(CAS_FILTER_USER) != null) {
                      log.trace("casGateway was true and CAS_FILTER_USER set: passing request along filter chain.");
                    // continue processing the request
                    fc.doFilter(request, response);
                    return;
                } else {
                    // unknown state... redirect to CAS
                    session.setAttribute(
                        CAS_FILTER_GATEWAYED,
                        "true");
                    redirectToCAS(
                        (HttpServletRequest) request,
                        (HttpServletResponse) response);
                    // abort chain
                    return;
                }
            }
        }


        try {
            receipt = getAuthenticatedUser((HttpServletRequest) request);
        } catch (CASAuthenticationException e) {
            log.error(e);
            throw new ServletException(e);
        }

        if (! isReceiptAcceptable(receipt)){
            throw new ServletException("Authentication was technically successful but rejected as a matter of policy. [" + receipt + "]");
        }
       
        // Store the authenticated user in the session
        if (session != null) { // probably unnecessary
            session.setAttribute(CAS_FILTER_USER, receipt.getUserName());
            session.setAttribute(CASFilter.CAS_FILTER_RECEIPT, receipt);
            // don't store extra unnecessary session state
            session.removeAttribute(
                CAS_FILTER_GATEWAYED);
        }
View Full Code Here

Examples of com.discursive.cas.extend.client.CASReceipt

        HttpSession session = ((HttpServletRequest) request).getSession();

        // if our attribute's already present and valid, pass through the filter
        // chain
        CASReceipt receipt = (CASReceipt) session
                .getAttribute(CAS_FILTER_RECEIPT);
        if (receipt != null) {
            log
                    .trace("CAS_FILTER_RECEIPT attribute was present - passing  request through filter..");
            fc.doFilter(request, response);
            return;
        }

        // otherwise, we need to authenticate via CAS
        String ticket = request.getParameter("ticket");

        // no ticket? no validation to be done, pass the request through.
        if (ticket == null || ticket.equals("")) {
            log.trace("CAS ticket was not present on request.");
            fc.doFilter(request, response);
            return;
        }

        try {
            receipt = getAuthenticatedUser((HttpServletRequest) request);
        } catch (CASAuthenticationException e) {
            log.error(e);
            throw new ServletException(e);
        }

        // Store the authenticated user in the session
        if (session != null) { // probably unnecessary
            session.setAttribute(CAS_FILTER_USER, receipt.getUserName());
            session.setAttribute(CASValidateFilter.CAS_FILTER_RECEIPT, receipt);
        }
        if (log.isTraceEnabled()) {
            log.trace("validated ticket to get authenticated receipt ["
                    + receipt + "], now passing request along filter chain.");
View Full Code Here

Examples of edu.yale.its.tp.cas.client.CASReceipt

      SourceBean engineConfig = EnginConf.getInstance().getConfig();
      SourceBean sourceBeanConf = (SourceBean) engineConfig.getAttribute("FILTER_RECEIPT");
      String filterReceipt = (String) sourceBeanConf.getCharacters();
      logger.debug("Read filterReceipt=" + filterReceipt);
      filterReceipt = spagoBiServerURL + filterReceipt;
      CASReceipt cr = (CASReceipt) session.getAttribute(CASFilter.CAS_FILTER_RECEIPT);
      logger.debug("Read cr=" + cr);
      if (cr==null) logger.warn("CASReceipt in session is NULL");
      String ticket=ProxyTicketReceptor.getProxyTicket(cr.getPgtIou(), filterReceipt);
      logger.debug("OUT.ticket="+ticket);
      return ticket;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.