title: cas+spring security
body: <p>I'm trying to implement SSO in my app and as for now, I've faced the next problem:</p>
  
  <pre><code>HTTP Status 401 - Authentication Failed: Failed to provide a CAS service ticket to validate
  
  type Status report
  
  message Authentication Failed: Failed to provide a CAS service ticket to validate
  
  description This request requires HTTP authentication (Authentication Failed: Failed to provide a CAS service ticket to validate).
  </code></pre>
  
  <p>I start my cas server on a different tomcat, login there and when I go to login pageat my app, then:
  1. then is no autologin
  2. when i enter credentials, I see the stacktrace shown above
  I took an example from <a href="http://www.oudmaijer.com/2009/12/28/spring-3-spring-security-3-cas-3-3-4-integration/" rel="nofollow">this site</a> .</p>
  
  <p>here is my spring security context:</p>
  
  <pre><code>&lt;security:global-method-security  pre-post-annotations="enabled" /&gt;
  
      &lt;security:http use-expressions="true" auto-config="true"
          entry-point-ref="casAuthenticationEntryPoint" &gt;
  
      &lt;security:custom-filter position="CAS_FILTER" ref="casAuthenticationFilter"&gt;&lt;/security:custom-filter&gt;
  
          &lt;security:access-denied-handler  ref="accessDeniedHandler" /&gt;
  
          &lt;security:form-login login-page="/login.html"
              authentication-failure-url="/login.html?login_error=1"
              default-target-url="/index.html" 
              always-use-default-target="false"
              login-processing-url="/j_spring_security_check"
              authentication-failure-handler-ref="failureHandler"
              authentication-success-handler-ref="successHandler" /&gt;
          &lt;security:logout logout-url="/logout" logout-success-url="/login.html" /&gt;
  
          &lt;security:intercept-url pattern="/member/**" access="hasRole('viewer')" /&gt;
          &lt;security:intercept-url pattern="/admin/**" access="hasRole('SiteAdmin')" /&gt;
          &lt;security:intercept-url pattern="/admin/**" access="hasRole('SystemAdmin')" /&gt;
  
          &lt;security:remember-me /&gt;
      &lt;/security:http&gt;
  
      &lt;security:authentication-manager alias="authenticationManager"&gt;
          &lt;security:authentication-provider user-service-ref="myUserDetailsService" /&gt;
          &lt;security:authentication-provider ref="casAuthenticationProvider"&gt;&lt;/security:authentication-provider&gt;
      &lt;/security:authentication-manager&gt;
  
      &lt;bean id="myUserDetailsService"
          class="com.mypackage.MyUserDetailsService"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="authenticationEntryPoint"
          class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"&gt;
          &lt;property name="loginFormUrl" value="/login.html" /&gt;
          &lt;property name="forceHttps" value="false" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="successHandler"
          class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"&gt;
          &lt;property name="defaultTargetUrl" value="/member/index.html" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="failureHandler"
          class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler"&gt;
          &lt;property name="defaultFailureUrl" value="/login.html?error=auth_fail" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="bannedHandler"
          class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"&gt;
          &lt;property name="defaultFailureUrl" value="/login.html?error=banned" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="accessDeniedHandler"
          class="org.springframework.security.web.access.AccessDeniedHandlerImpl"&gt;
          &lt;property name="errorPage" value="/403.jsp"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"&gt;
          &lt;property name="service" value="http://localhost:8080/spring-security-cas/j_spring_cas_security_check"&gt;&lt;/property&gt;
          &lt;property name="sendRenew" value="false"&gt;&lt;/property&gt;
      &lt;/bean&gt; 
  
      &lt;bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"&gt;
          &lt;property name="authenticationManager" ref="authenticationManager"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="casAuthenticationEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"&gt;
          &lt;property name="loginUrl" value="http://localhost:9080/cas-server-webapp-3.4.10/login"&gt;&lt;/property&gt;
          &lt;property name="serviceProperties" ref="serviceProperties"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"&gt;
          &lt;property name="userDetailsService" ref="myUserDetailsService"&gt;&lt;/property&gt;
          &lt;property name="serviceProperties" ref="serviceProperties"&gt;&lt;/property&gt;
          &lt;property name="ticketValidator"&gt;
              &lt;bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"&gt;
                  &lt;constructor-arg index="0" value="http://localhost:9080/cas-server-webapp-3.4.10"&gt;&lt;/constructor-arg&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
          &lt;property name="key" value="cas"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>in web.xml, I've includede spring security context and set the appropriate listeners and etc.
  in pom(I use maven) I've added the required dependencies, described in the article. 
  But the problem stays.
  I'd be glad any pieces of advice</p>