Hi,

I'm not sure that's the best way. On our side we put the spring UTF-8 filter at the first place of filter in the web.xml, and we added the jvm var "-Dfile.encoding = UTF-8" and it works.

I checked it and from the server we obtain attributes encoded to UTF-8 and that for all CAS services. But from your client you need to have also UTF-8 encoding set ...

Julien G.


Danny B. a écrit :
I found a solution that works for me:

I needed to add a small piece of code in the saml10SuccessResponseView.


        protected void renderMergedOutputModel(final Map model,
                        final HttpServletRequest request, final 
HttpServletResponse response)
                        throws Exception {

...
        final Collection c = new ArrayList();
                                                String newValue = 
encodeToUnicodeStandard(value
                                                                .toString());

                                                c.add(newValue);
                                                attribute.setValues(c);

...


private static String encodeToUnicodeStandard(String pData) {
                StringBuffer encodedData = new StringBuffer();

                StringBuffer sBuff = new StringBuffer(pData);
                for (int i = 0; i < sBuff.length(); i++) {
                        char ch = sBuff.charAt(i);
                        int chVal = (int) ch;

                        // if this is a special character (ie. > 8 bits), 
encode it
                        if (chVal > Byte.MAX_VALUE) {
                                
encodedData.append("&#x").append(Integer.toHexString(chVal))
                                                .append(";");
                        } else {
                                encodedData.append(ch);
                        }
                }

                return encodedData.toString();
        }

enjoy!


Danny B. wrote:
Hi,
I am having problems with receiving special chars like
<AttributeValue>é.ö.û.à</AttributeValue>
Without the utf-8 filter it got in my apache log I recieved this.
 \xe9.\xf6.\xfb.\xe0 (latin)
 The php client froze on this code.
It appears we sent the message in ISO-8859-1 instead of UTF-8. Because
when we used utf8_encode($xml_response) in the php example, we could read
the response.
When I looked in my cas-java-demo, I received: ?.?.?.?

So we decided to change it, to use UTF-8 character encoding

Now when I look in my apache log. i see
<AttributeValue>\xc3\xa9.\xc3\xb6.\xc3\xbb.\xc3\xa0</AttributeValue>
When I looked in my cas-java-demo, I received: ??.??.??.??
This is with the spring utf-8 filter.

I am using:
cas-server version 3.3.1
cas-client version 3.1.4

Server: JBoss 4.2.2. running on Ubuntu.

LDAP: utf-8

Steps i have undertaken:
JBoss connector config:
connector: added URIEncoding="UTF-8"

Spring config
Filter UTF-8

Saml10SuccessResponseView
added response.setCharacterEncoding("UTF-8");

All help is very much appreciated.

Thanks in advance.





--
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