Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Help with custom Realm

Help with custom Realm

2006-11-20       - By Daniel Santos

 Back

Hello, I'm implementing a new realm for a custom single sign-on dealie that
my company is using (so I can use container managed security with their new
system).  Everything is going smoothly, except that I can't figure out how
to get an object I declared as a <Resource> under the context, from outside
of the web-application space.  Basically, my Realm object works great, but
it needs pluggable support objects and I'm having problems getting those to
the Realm (perhaps I'm even putting them in a bad place?)  Anyway, I figured
I would declare them at the same level as the Realm.  I'm declaring this
Realm at the Context level now, and I need to get it done for a deadline,
and then make sure it works at the Server, Host, etc. level later.

sample snipped from <context> section:

<Resource
  name="a.unique.name.for.something.i.Need"
  auth="Container"
  type="com.att.my.package.tomcat.SupportObject"
  factory="org.apache.naming.factory.BeanFactory Source code of org.apache.naming.factory.BeanFactory"
  dataSourceName="jdbc/myApp"
  userTableName="users"
  userFieldName="id"
  lastActiveFieldName="last_active"
/>

<Realm
  className="com.att.my.package.tomcat.SuperRealm"
  validationEnv="PROD"
  loginURL="https://www.yadayada.att.com/login"
  logoutURL="https://www.yadayada.att.com/logout"
  myThingieName="a.unique.name.for.something.i.Need"
/>

Of course, I have a pretty mbean for the realm (I'm implementing RealmBase
to save me some time although I don't use 80% of RealmBase) and my custom
realm comes up fine.  What I haven't figured out how to do is to get a
context that contains this crap!!  I can do it from my web app fairly simply
with this:

  import com.att.my.package.tomcat.SupportObject;
  import javax.naming.Context Source code of javax.naming.Context;

  Context initialContext = new InitialContext();
  Context envContext = (Context)initialContext.lookup("java:comp/env");
  Object o = envContext.lookup("a.unique.name.for.something.i.Need");
  SupportObject mySupportObject = (SupportObject)o;

and hurray!  It works.  I get a new instance of my support object class,
fully initialized.  Of course, I need this in my realm, not the web app.
This will be used by many different Tomcat-based web applications and I want
it to be as clean and transparent as possible.

My realm's container happens to be a StandardContext (or wrapper to it, I
forgot) and via the fields namingContextListener.envCtx will give me the
Context I need to create my support objects, but it's hacky and
"StandardContext.namingContextListener" is private.

So here are my questions:

A.   Is using a <Resrouce> or <GlobalResource> a healthy way to provide
support objects to a custom Realm?
B.   Would it be better to hack something else so that I can embed these into
the <Realm> tag as children?  (I'm not super-duper strong on the commons
digester, although it's really cool)
C.   If what I'm tyring to do looks sane, can you please show me how to get
the javax.naming.Context Source code of javax.naming.Context or org.apache.naming.NamingContext Source code of org.apache.naming.NamingContext object that can
create my support objects for me?

Thanks,
Daniel



--
View this message in context: http://www.nabble.com/Help-with-custom-Realm
-tf2672022.html#a7451310
Sent from the Tomcat - User mailing list archive at Nabble.com.


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.