Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DE3F510C3C for ; Mon, 24 Jun 2013 11:37:39 +0000 (UTC) Received: (qmail 66080 invoked by uid 500); 24 Jun 2013 11:37:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 65778 invoked by uid 500); 24 Jun 2013 11:37:34 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 65768 invoked by uid 99); 24 Jun 2013 11:37:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2013 11:37:33 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of vavra@602.cz designates 209.85.215.48 as permitted sender) Received: from [209.85.215.48] (HELO mail-la0-f48.google.com) (209.85.215.48) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2013 11:37:26 +0000 Received: by mail-la0-f48.google.com with SMTP id lx15so9950172lab.7 for ; Mon, 24 Jun 2013 04:37:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=9q/f3Uc02w6TcT6mJg/JOlpUA4U1u4uTgnSDzIjBfvw=; b=n61jE36jF1eCAyqfUdMa1kdj4Xp80QEHZttpqNoRDMdp7H1wTEeD8itmRNkjbpVYUc iXx8+fhaxU60nYJacOu9gt8gGoptdTTCF6nN7PsbS+pYNkeEY9QcL1ThbvtPbpDimIf5 yHTkXp4hvjzCSJhMYvZD+Q6Ba+5pYsSN5D5wrytSxqMbhNDTTShO6SYKCtpewGUCAHGU uzwZjyZkGTmYmbH/o5uQu8qXr/os7dZcbpRQU4vS4aBhuiQ1Rgs/CeKkVZsO00EPjGuE ipa3hzpkCTB5/51wPqF9I0c1m2SyJ/ZYWQuoptabwhtqKkYEfS15ZLs5tZWEKTo57xbZ SxBg== X-Received: by 10.112.55.9 with SMTP id n9mr12905307lbp.5.1372073824820; Mon, 24 Jun 2013 04:37:04 -0700 (PDT) Received: from [192.168.1.211] (94.112.242.230.static.b2b.upcbusiness.cz. [94.112.242.230]) by mx.google.com with ESMTPSA id w9sm6402278lbk.7.2013.06.24.04.37.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 04:37:03 -0700 (PDT) Message-ID: <51C82F5B.8050300@602.cz> Date: Mon, 24 Jun 2013 13:36:59 +0200 From: =?ISO-8859-2?Q?Jan_V=E1vra?= User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Tomcat Users List Subject: FORM based authentication and utf-8 encoding of credentials Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Gm-Message-State: ALoCoQkRaaZ4JNMwWy1LBwp1jaLNnCe619ggEL89e1MOruwAL995Kd2V241nBaMr3nRjb4JyW/QU X-Virus-Checked: Checked by ClamAV on apache.org Hello, I'm successfully using form based authenntication when login or password contains only letters from English alphabet. I have also written own realm. When I create user with password with czech String "�e�Uli�ka.1" the browser sends correctly this string as: POST http://localhost:70/myapp/j_security_check HTTP/1.1 Content-Type: application/x-www-form-urlencoded j_username=p&j_password=%C5%BDe%C5%BEUli%C4%8Dka.1 The first letter "�" is really encoded in the utf-8 as bytes in hexa C5, BD. But in the method public Principal authenticate(String username, String credentials) the parameter credentials has first two bytes C3, 85. In my login.jsp I have these relevant parts: <% request.setCharacterEncoding("UTF-8"); %> ...
and also tomcat is telling in the http response header: Content-Type: text/html;charset=UTF-8 But nothing of it forced Tomcat to translate password correctly from utf-8 string. Even the manual reencoding in authenticate(.) doesn't help: credentials = new String(credentials.getBytes(),"utf-8") Because the received bytes of first letter are C3, 85 instead of expected C5, BD. Any idea how to tell tomcat to use utf-8 in form based authentication? It's tomcat 7.0.34 on Czech Windows 7 32 bit with default ansi code page set as Windows-1250. Thanks Jan. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org