Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 79970 invoked from network); 14 Feb 2006 15:58:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Feb 2006 15:58:23 -0000 Received: (qmail 90895 invoked by uid 500); 14 Feb 2006 15:58:07 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 90880 invoked by uid 500); 14 Feb 2006 15:58:07 -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 90869 invoked by uid 99); 14 Feb 2006 15:58:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 07:58:07 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [66.45.118.99] (HELO atl104.trxfs.trx.com) (66.45.118.99) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 07:58:06 -0800 Received: from trxatl100.mail.trx.com ([172.16.1.23] unverified) by atl104.trxfs.trx.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 14 Feb 2006 10:59:39 -0500 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: JAASRealm and LoginContext reuse X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Date: Tue, 14 Feb 2006 10:59:39 -0500 Message-ID: <322805D420B7D41180AE00508B5E25CD0B84CE8A@trxatl100.trxfs.trx.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: JAASRealm and LoginContext reuse Thread-Index: AcYxf6jZReEgyVSsQeyYAyfQDsUObw== From: "Stefan Baramov" To: X-OriginalArrivalTime: 14 Feb 2006 15:59:39.0291 (UTC) FILETIME=[A904CEB0:01C6317F] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I found that the JAASRealm implementation (org.apache.catalina.realm.JAASRealm) does not reuse the LoginContext (javax.security.auth.login.LoginContext) instance. Every time the authenticate(String,String) method is called a new LoginContext instance is created. Creating a new instance of the LoginContext will result in creating a new instance of all LoginModule's configured for this application. In other words, for each login a new instance of the LoginModule is created. However, in my case the initialization of the login module is an expensive operation.=20 The only way to resolve this is to write a custom JAASRealm implementation. However, before doing this I would like to know whether there is any rational of not caching the LoginContext instance. I looked in the JAAS spec and could find anything against caching the LoginContext. I've also looked at LoginContext source code in JDK 1.4 and it appears to be written to cache the LoginModule instances. So I would assume it is correct to write a custom version of the JAASRealm to operate on a single instance of the LoginContext. Am I right?=20 I would appreciate any thoughts.=20 Thanks Stefan Baramov=20 Software Developer=20 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org