Examples of ProxyTicketValidator


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

  //*********************************************************************
  // Utility methods

  private String getAuthenticatedNetid(String ticket)
    throws ParserConfigurationException, SAXException, IOException, JspTagException {
    ProxyTicketValidator pv = new ProxyTicketValidator();
    pv.setCasValidateUrl(casValidate);
    pv.setServiceTicket(ticket);
    pv.setService(service);
    pv.validate();
    if (!pv.isAuthenticationSuccesful())
      throw new JspTagException(
        "CAS authentication error: " + pv.getErrorCode());
    if (pv.getProxyList().size() != 0) {
      // ticket was proxied
      if (acceptedProxies.size() == 0)
        throw new JspTagException("this page does not accept proxied tickets");
      else if (!acceptedProxies.contains(pv.getProxyList().get(0)))
        throw new JspTagException(
          "unauthorized top-level proxy: '" + pv.getProxyList().get(0) + "'");
    }
    return pv.getUser();
  }
View Full Code Here

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

     * @throws CASAuthenticationException - on authentication failure
     */
    private CASReceipt getAuthenticatedUser(HttpServletRequest request)
        throws ServletException, CASAuthenticationException {
        log.trace("entering getAuthenticatedUser()");
        ProxyTicketValidator pv = null;
       
            pv = new ProxyTicketValidator();
            pv.setCasValidateUrl(casConfig.getCasValidate() );
            pv.setServiceTicket(request.getParameter("ticket"));
            pv.setService(getService(request));
            pv.setRenew(Boolean.valueOf(casConfig.isCasRenew()).booleanValue());
            if (casConfig.getCasProxyCallbackUrl() != null) {
                pv.setProxyCallbackUrl(casConfig.getCasProxyCallbackUrl());
            }
            if (log.isDebugEnabled()) {
                log.debug(
                    "about to validate ProxyTicketValidator: [" + pv + "]");
            }
View Full Code Here

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

     *             on authentication failure
     */
    private CASReceipt getAuthenticatedUser(HttpServletRequest request)
            throws ServletException, CASAuthenticationException {
        log.trace("entering getAuthenticatedUser()");
        ProxyTicketValidator pv = null;

        pv = new ProxyTicketValidator();
        pv.setCasValidateUrl(casValidate);
        pv.setServiceTicket(request.getParameter("ticket"));
        pv.setService(getService(request));
        pv.setRenew(Boolean.valueOf(casRenew).booleanValue());
        if (casProxyCallbackUrl != null) {
            pv.setProxyCallbackUrl(casProxyCallbackUrl);
        }
        if (log.isDebugEnabled()) {
            log.debug("about to validate ProxyTicketValidator: [" + pv + "]");
        }

View Full Code Here

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

  //*********************************************************************
  // Utility methods

  private String getAuthenticatedNetid(String ticket)
    throws ParserConfigurationException, SAXException, IOException, JspTagException {
    ProxyTicketValidator pv = new ProxyTicketValidator();
    pv.setCasValidateUrl(casValidate);
    pv.setServiceTicket(ticket);
    pv.setService(service);
    pv.validate();
    if (!pv.isAuthenticationSuccesful())
      throw new JspTagException(
        "CAS authentication error: " + pv.getErrorCode());
    if (pv.getProxyList().size() != 0) {
      // ticket was proxied
      if (acceptedProxies.size() == 0)
        throw new JspTagException("this page does not accept proxied tickets");
      else if (!acceptedProxies.contains(pv.getProxyList().get(0)))
        throw new JspTagException(
          "unauthorized top-level proxy: '" + pv.getProxyList().get(0) + "'");
    }
    return pv.getUser();
  }
View Full Code Here

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

     * @throws CASAuthenticationException - on authentication failure
     */
    private CASReceipt getAuthenticatedUser(HttpServletRequest request)
        throws ServletException, CASAuthenticationException {
        log.trace("entering getAuthenticatedUser()");
        ProxyTicketValidator pv = null;
       
            pv = new ProxyTicketValidator();
            pv.setCasValidateUrl(casConfig.getCasValidate() );
            pv.setServiceTicket(request.getParameter("ticket"));
            pv.setService(getService(request));
            pv.setRenew(Boolean.valueOf(casConfig.isCasRenew()).booleanValue());
            if (casConfig.getCasProxyCallbackUrl() != null) {
                pv.setProxyCallbackUrl(casConfig.getCasProxyCallbackUrl());
            }
            if (log.isDebugEnabled()) {
                log.debug(
                    "about to validate ProxyTicketValidator: [" + pv + "]");
            }
View Full Code Here

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

     *             on authentication failure
     */
    private CASReceipt getAuthenticatedUser(HttpServletRequest request)
            throws ServletException, CASAuthenticationException {
        log.trace("entering getAuthenticatedUser()");
        ProxyTicketValidator pv = null;

        pv = new ProxyTicketValidator();
        pv.setCasValidateUrl(casValidate);
        pv.setServiceTicket(request.getParameter("ticket"));
        pv.setService(getService(request));
        pv.setRenew(Boolean.valueOf(casRenew).booleanValue());
        if (casProxyCallbackUrl != null) {
            pv.setProxyCallbackUrl(casProxyCallbackUrl);
        }
        if (log.isDebugEnabled()) {
            log.debug("about to validate ProxyTicketValidator: [" + pv + "]");
        }

View Full Code Here

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

    //~ Methods ========================================================================================================

    public TicketResponse confirmTicketValid(String serviceTicket)
        throws AuthenticationException {
        // Attempt to validate presented ticket using CAS' ProxyTicketValidator class
        ProxyTicketValidator pv = new ProxyTicketValidator();

        pv.setCasValidateUrl(super.getCasValidate());
        pv.setServiceTicket(serviceTicket);
        pv.setService(super.getServiceProperties().getService());

        if (super.getServiceProperties().isSendRenew()) {
            logger.warn(
                  "The current CAS ProxyTicketValidator does not support the 'renew' property. "
                + "The ticket cannot be validated as having been issued by a 'renew' authentication. "
                + "It is expected this will be corrected in a future version of CAS' ProxyTicketValidator.");
        }

        if ((this.proxyCallbackUrl != null) && (!"".equals(this.proxyCallbackUrl))) {
            pv.setProxyCallbackUrl(proxyCallbackUrl);
        }

        return validateNow(pv);
    }
View Full Code Here

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

      validateService = SingletonConfig.getInstance().getConfigValue("CAS_SSO.VALIDATE-USER.SERVICE");
      logger.debug("Read validateService=" + validateService);
  }
  logger.debug("userId:"+userId);
  try {
      ProxyTicketValidator pv = null;
      pv = new ProxyTicketValidator();
      pv.setCasValidateUrl(validateUrl);
      pv.setServiceTicket(ticket);
      pv.setService(validateService);
      pv.setRenew(false);
      pv.validate();
      if (pv.isAuthenticationSuccesful()) {
      String tmpUserId = pv.getUser();
      logger.debug("CAS User:" + tmpUserId);
      if userId==null || !userId.equals(tmpUserId)) {
          logger.warn("Proxy and application users are not the same [" + userId + "-"
            + tmpUserId + "]");
          throw new SecurityException("Proxy and application users are not the same [" + userId + "-"
View Full Code Here

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

    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
   
    String authenticatedUserName = null;
   
    /* instantiate a new ProxyTicketValidator */
    ProxyTicketValidator pv = new ProxyTicketValidator();
   
    /* set its parameters */
    //pv.setCasValidateUrl(casValidateUrl);
   
    String encodeValidateUrl = CmsPropertyHandler.getEncodeValidateUrl();
    String encodeCasServiceUrl = CmsPropertyHandler.getEncodeCasServiceUrl();
   
    if(ticket != null && ticket.substring(0, 2).equals("PT"))
    {
      if(encodeValidateUrl != null && encodeValidateUrl.equals("true"))
        casProxyValidateUrl = URLEncoder.encode(casProxyValidateUrl, "iso-8859-1");
       
      logger.info("setting casProxyValidateUrl: " + casProxyValidateUrl);
      pv.setCasValidateUrl(casProxyValidateUrl);
     
    }
    else
    {
      if(encodeValidateUrl != null && encodeValidateUrl.equals("true"))
        casValidateUrl = URLEncoder.encode(casValidateUrl, "iso-8859-1");

      pv.setCasValidateUrl(casValidateUrl);
      logger.info("setting casValidateUrl: " + casValidateUrl);
    }
   
    if(encodeCasServiceUrl != null && encodeCasServiceUrl.equals("true"))
      casServiceUrl = URLEncoder.encode(casServiceUrl, "iso-8859-1");
   
    logger.info("validating: " + casServiceUrl);
    pv.setService(casServiceUrl);

    pv.setServiceTicket(ticket);

    /*
     * If we want to be able to acquire proxy tickets (requires callback servlet to be set up 
     * in web.xml - see below)
     */

    /* contact CAS and validate */     
   
    try
    {
      //----------------------------------------------------------------------
      // If this is a CAS 2.0 installation the response will be in XML format.
      // If this is a CAS 1.0 the response will be a simple String and the
      // pv.validate() method will throw an exception
      // ("content not allowed in prolog"). If this exception is thrown we
      // will do a further check in the catch and see if the user was
      // verified even though the response was not in XML.
      //-----------------------------------------------------------------------
     
      pv.validate();
     
      /* if we want to look at the raw response, we can use getResponse() */
      String xmlResponse = pv.getResponse();
      logger.info("xmlResponse:" + xmlResponse);
     
      /* read the response */
      if(pv.isAuthenticationSuccesful())
      {
        String user = pv.getUser();
        List proxyList = pv.getProxyList();
        authenticatedUserName = pv.getUser();
       
        logger.info("The user " + user + " was authenticated successfully.");
      }
      else
      {
        String errorCode = pv.getErrorCode();
        String errorMessage = pv.getErrorMessage();       
        /* handle the error */
      }

      /* The user is now authenticated. */
      /* If we did set the proxy callback url, we can get proxy tickets with: */

      logger.info("proxies:\n " + pv.getProxyList());
    }
    catch (Exception e)
    {
      logger.info("-------------------------------------------------------------");
      logger.info("(Johans utskrift)  Felmeddelande: " + e.getMessage());
      logger.info("(Johans utskrift)  pv.getCasValidateUrl: " + pv.getCasValidateUrl());
      logger.info("(Johans utskrift)  pv.getErrorCode(): " + pv.getErrorCode());
      logger.info("(Johans utskrift)  pv.getErrorMessage: " + pv.getErrorMessage());
      logger.info("(Johans utskrift)  pv.getPgtIou: " + pv.getPgtIou());
      logger.info("(Johans utskrift)  pv.getProxyCallbackUrl: " + pv.getProxyCallbackUrl());
      logger.info("(Johans utskrift)  pv.getResponse: " + pv.getResponse());
      logger.info("(Johans utskrift)  pv.getUser: " + pv.getUser());
      logger.info("(Johans utskrift)  pv.getClass: " + pv.getClass());
      logger.info("(Johans utskrift)  pv.getProxyList: " + pv.getProxyList());
      logger.info("-------------------------------------------------------------");
     
      //--------------------------------------------------------------------
      // Check if the user was authenticated even though an exception occured.
      // This will be the case if the CAS is a 1.0 installation.
      //--------------------------------------------------------------------
     
      String casResponse = pv.getResponse();
     
      logger.info("CAS RESPONSE: " + casResponse.substring(0, 3));

      String response = casResponse.substring(0, casResponse.indexOf('\n'));
      String userId  = casResponse.substring(casResponse.indexOf('\n') + 1);
View Full Code Here

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

    }

    public TicketResponse confirmTicketValid(String serviceTicket)
        throws AuthenticationException {
        // Attempt to validate presented ticket using CAS' ProxyTicketValidator class
        ProxyTicketValidator pv = new ProxyTicketValidator();

        pv.setCasValidateUrl(super.getCasValidate());
        pv.setServiceTicket(serviceTicket);
        pv.setService(super.getServiceProperties().getService());

        if (super.getServiceProperties().isSendRenew()) {
            logger.warn(
                "The current CAS ProxyTicketValidator does not support the 'renew' property. The ticket cannot be validated as having been issued by a 'renew' authentication. It is expected this will be corrected in a future version of CAS' ProxyTicketValidator.");
        }

        if ((this.proxyCallbackUrl != null)
            && (!"".equals(this.proxyCallbackUrl))) {
            pv.setProxyCallbackUrl(proxyCallbackUrl);
        }

        return validateNow(pv);
    }
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.