UnauthorizedServiceException doesn't display serviceErrorView?

John Thiltges jthiltges2 at unl.edu
Fri Nov 10 12:58:46 EST 2006


Scott,

Success! It appears the exception must be handled in the flow. Adding 
the following line to the generateServiceTicket action-state appears to 
make things work as expected:
    <transition 
on-exception="org.jasig.cas.services.UnauthorizedServiceException" 
to="viewServiceErrorView"/>

I attached a new patch to CAS-423. Apparently I'm not able to reopen the 
ticket.

Now that the exception is being handled, there's no indication in the 
logs. Maybe logging an info when a service is rejected. Where's the best 
place for that to go, in the UnauthorizedServiceException itself, or in 
each place it's thrown?

Thanks,
John

Scott Battaglia wrote:
> I checked it out and it appears Spring Web Flow wraps the exception.  
> But it also appears that the error-page for "Exception" is a catch-all 
> (which I didn't think it was supposed to be but maybe I read the spec 
> wrong).
>
>
>
> On 11/7/06, *John Thiltges* <jthiltges2 at unl.edu 
> <mailto:jthiltges2 at unl.edu>> wrote:
>
>     Scott,
>
>     With CAS 3.0.5, applying your patch to
>     UnauthorizedServiceException.java and web.xml
>     (MAIN:sbattaglia:20061106190331) doesn't appear to resolve the
>     problem. The error-page for java.lang.Exception still shows up.
>     Are there other changes required as well?
>
>     I tried adding org.jasig.cas.services.UnauthorizedServiceException
>     to the SimpleMappingExceptionResolver in cas-servlet.xml but
>     again, the java.lang.Exception error-page shows up. However, when
>     I added org.springframework.webflow.ActionExecutionException to
>     the SimpleMappingExceptionResolver, the correct view was shown.
>
>     It feels like the solution is close, but I can't see it. The
>     UnauthorizedServiceException is nested inside of
>     ActionExecutionException...how to get ahold of it?
>
>     Thanks,
>     John
>
>     2006-11-07 17:28:28,842 DEBUG
>     [org.springframework.web.context.support.XmlWebApplicationContext]
>     - <Publishing event in context [WebApplicationContext for
>     namespace 'cas-servlet']: ServletRequestHandledEvent:
>     url=[/cas/login]; client=[127.0.0.1 <http://127.0.0.1>];
>     method=[GET]; servlet=[cas];
>     session=[43D30D5B33CE84E8D0F5A7DD6723CAEC]; user=[null];
>     time=[19ms]; status=[failed:
>     _org.springframework.webflow.ActionExecutionException_: Exception
>     thrown executing [AnnotatedAction at 13c952f targetAction =
>     org.jasig.cas.web.flow.GenerateServiceTicketAction at 666a53,
>     attributes = map[[empty]]] in state 'generateServiceTicket' of
>     flow 'login-webflow' -- action execution properties where
>     'map[[empty]]'; _nested exception is
>     org.jasig.cas.services.UnauthorizedServiceException_: Service:
>     [http://localhost/foo] not found in registry.]>
>
>
>     Scott Battaglia wrote:
>>     John,
>>
>>     I'll be sure to switch it to a RuntimeException (I'm currently
>>     re-working the Services support).  Once you change it to derive
>>     from Runtime Exception you should be able to use the traditional
>>     web.xml method or a Spring Error Handler without having to modify
>>     the actions.
>>
>>     -Scott
>>
>>     On 10/24/06, *John Thiltges* <jthiltges2 at unl.edu
>>     <mailto:jthiltges2 at unl.edu>> wrote:
>>
>>         Scott,
>>
>>         Thanks for the ideas, but unfortunately I didn't have any
>>         luck. I looked into the problem a little more and came up
>>         with the following solution:
>>
>>         It appears that because UnauthorizedServiceException derives
>>         from Exception, it gets converted to an
>>         UndeclaredThrowableException. By changing it to derive from
>>         RuntimeException, the exception type does not get lost, and
>>         the exception can then be caught in GenerateServiceTicketAction.
>>
>>         Next, I added a catch statement in
>>         GenerateServiceTicketAction and added to the webflow so that
>>         UnauthorizedServiceException goes to the serviceErrorView view.
>>
>>         If it would be helpful, I can sort through my code and post a
>>         patch to cas-dev.
>>
>>         Thanks,
>>         John
>>
>>         Scott Battaglia wrote:
>>>         You can try adding the following to your web.xml:
>>>
>>>         Either:
>>>             <error-page>
>>>                
>>>         <exception>java.lang.reflect.UndeclaredThrowableException</exception>
>>>                
>>>         <location>/WEB-INF/view/jsp/default/ui/serviceErrorView.jsp</location>
>>>
>>>             </error-page>
>>>
>>>         or
>>>
>>>             <error-page>
>>>                
>>>         <exception>org.jasig.cas.services.UnauthorizedServiceException</exception>
>>>                
>>>         <location>/WEB-INF/view/jsp/default/ui/serviceErrorView.jsp</location>
>>>
>>>             </error-page>
>>>
>>>         Let me know if that works for you.
>>>
>>>         -Scott
>>>
>>>         On 10/24/06, *John Thiltges* < jthiltges2 at unl.edu
>>>         <mailto:jthiltges2 at unl.edu>> wrote:
>>>
>>>             Hello group,
>>>
>>>             When using approvedServices and a service is not found, an
>>>             UnauthorizedServiceException is thrown. This appears to
>>>             cause an error
>>>             and the end user sees "CAS is Unavailable. A general
>>>             exception
>>>             occurred..." (WEB-INF/view/jsp/errors.jsp).
>>>
>>>             Should the serviceErrorView be displayed instead? If
>>>             not, when is the
>>>             serviceErrorView used?
>>>
>>>             Error message from CAS 3.0.5 (unmodified except for enabling
>>>             approvedServices in web.xml):
>>>             2006-10-24 10:23:03,609 INFO
>>>             [org.jasig.cas.authentication.AuthenticationManagerImpl] -
>>>             <AuthenticationHandler:
>>>             org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler
>>>             successfully authenticated the user which provided the
>>>             following
>>>             credentials: asdf>
>>>             2006-10-24 10:23:03,678 ERROR
>>>             [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/cas305].[cas]]
>>>             - <Servlet.service() for servlet cas threw exception>
>>>             java.lang.reflect.UndeclaredThrowableException
>>>                     at $Proxy1.grantServiceTicket(Unknown Source)
>>>                     at
>>>             org.jasig.cas.web.flow.GenerateServiceTicketAction.doExecuteInternal(GenerateServiceTicketAction.java:33)
>>>                     at
>>>             org.jasig.cas.web.flow.AbstractLoginAction.doExecute
>>>             (AbstractLoginAction.java:60)
>>>                     at
>>>             org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:204)
>>>                 ...
>>>                     at java.lang.Thread.run(Thread.java:595)
>>>             Caused by:
>>>             org.jasig.cas.services.UnauthorizedServiceException :
>>>             Service:
>>>             [http://localhost/asdf] not found in registry.
>>>                     at
>>>             org.jasig.cas.services.advice.ServiceAllowedMethodBeforeAdvice.before(ServiceAllowedMethodBeforeAdvice.java
>>>             :58)
>>>                     at
>>>             org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
>>>                     at
>>>             org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>>>             (ReflectiveMethodInvocation.java:170)
>>>                     at
>>>             org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
>>>                     ... 63 more
>>>
>>>             Thanks,
>>>             John
>>>             --
>>>             John Thiltges
>>>             Information Services-Systems Group
>>>             University of Nebraska - Lincoln
>>>             _______________________________________________
>>>             Yale CAS mailing list
>>>             cas at tp.its.yale.edu <mailto:cas at tp.its.yale.edu>
>>>             http://tp.its.yale.edu/mailman/listinfo/cas
>>>
>>>
>>>         ------------------------------------------------------------------------
>>>
>>>         _______________________________________________
>>>         Yale CAS mailing list
>>>         cas at tp.its.yale.edu <mailto:cas at tp.its.yale.edu>
>>>         http://tp.its.yale.edu/mailman/listinfo/cas
>>>           
>>
>>
>>         _______________________________________________
>>         Yale CAS mailing list
>>         cas at tp.its.yale.edu <mailto:cas at tp.its.yale.edu>
>>         http://tp.its.yale.edu/mailman/listinfo/cas
>>
>>
>>
>>     ------------------------------------------------------------------------
>>
>>     _______________________________________________
>>     Yale CAS mailing list
>>     cas at tp.its.yale.edu <mailto:cas at tp.its.yale.edu>
>>     http://tp.its.yale.edu/mailman/listinfo/cas
>>       
>
>
>     _______________________________________________
>     Yale CAS mailing list
>     cas at tp.its.yale.edu <mailto:cas at tp.its.yale.edu>
>     http://tp.its.yale.edu/mailman/listinfo/cas
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Yale CAS mailing list
> cas at tp.its.yale.edu
> http://tp.its.yale.edu/mailman/listinfo/cas
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tp.its.yale.edu/pipermail/cas/attachments/20061110/35de3579/attachment.html


More information about the cas mailing list