David,

  Thanks for your time! Are you sure about the key thing? I've been trying to 
make it work and it isn't cooperating. All I see on the login page is ": 
mycompany.account.email.only". Is there some magic I should be using?

 

Thanks,

Eric

 

messages_en.properties:

 

###############################################################################

### Mycompany Properties

###############################################################################

mycompany.account.email.only=Account is email-only

 

 

MycompanyAuthenticationException:

 

     * @param messageBundleKey the key in the CAS message bundle to display.

     * May not be null.

     * @param webflowTransition the transition code that will be used to

     * redirect the user in the CAS login-webflow. May not be null.

     */

    public MycompanyAuthenticationException(

            final String webflowTransition,

            final String messageBundleKey

            ) {

        super(

                messageBundleKey,

                messageBundleKey,

                webflowTransition);

 

MycompanyAuthenticationHandler:

 

throw new LocusAuthenticationException("error", "mycompany.account.email.only");

 

 

-----Original Message-----
From: David Ordas [mailto:[email protected]] 
Sent: Friday, January 18, 2013 4:03 AM
To: [email protected]
Subject: re:[cas-user] FW: Redirecting a login

 

First, let me say you that all authentication handler exceptions are added to 
webflow error stack.

 

Second, if you customize the exception type argument (by default "error" to let 
flow back to login view), you must have a webflow transition with that name, 
and then, if you desire, a custom view to handle that exception. 

 

If you put the key of your message as exception code the flow resolves the 
message against your messages properties. The problem, message can not have 
arguments. To avoid that and since CAS is a Spring application you can get an 
messages resolver object instance implementing any class that extends 
org.springframework.context.MessageSourceAware. Take a look also at 
org.springframework.context.support.ApplicationObjectSupport to get an 
accessor. In this way and using 
org.springframework.context.i18n.LocaleContextHolder.getLocale you can full 
i18n your exception messages.

 

I don't really like much the handler resolves the error messages because it is 
not the appropiate layer (should be in the web layer), but this behaviour 
implies do some changes. Really, the best implementation maybe let exceptions 
be self resolvable using some Spring machinery philosophy, such as 
org.springframework.context.support.DefaultMessageSourceResolvable, and handle 
it in that web layer that I have said, but I think that this behavior is not 
implemented and in CAS4 is proposed in another way that also not allow pass 
arguments (let me the CAS development team if I am wrong)

--

You are currently subscribed to [email protected] 
<mailto:[email protected]>  as: [email protected] 
<mailto:[email protected]>  To unsubscribe, change settings or access 
archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user 
<http://www.ja-sig.org/wiki/display/JSG/cas-user> 


-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

Reply via email to