Re: How to get context realm from servlet and filter.

2004-10-14 Thread Chris Forbis
Quick follow-up to your post.

I understand what you are saying.  But I am not sure how to get access
to the Container, can you point me in the correct direction?

Thanks!


On Thu, 14 Oct 2004 08:43:23 -0400, Shapira, Yoav [EMAIL PROTECTED] wrote:
 
 Hi,
 A Realm is associated with a Container, not necessarily a Context, so
 the method is appropriately placed in the Container interface, a parent
 of the Context interface.  Obviously all this is not part of the Servlet
 API, so you'll have to write Tomcat-specific code to get it.
 
 Yoav Shapira http://www.yoavshapira.com
 
 
 -Original Message-
 From: Chris Forbis [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, October 13, 2004 6:24 PM
 To: tomcat-dev
 Subject: How to get context realm from servlet and filter.
 
 I am trying to get the current contexts realms from a servlet (and
 maybe a filter).  I do not see a getContext().getRealm() method.  So I
 am guessing there is another way to get to this, but I do not see it.
 
 Can any one provide some quick direction to me on this.  Thank you!
 
 Chris
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 This e-mail, including any attachments, is a confidential business communication, 
 and may contain information that is confidential, proprietary and/or privileged.  
 This e-mail is intended only for the individual(s) to whom it is addressed, and may 
 not be saved, copied, printed, disclosed or used by anyone else.  If you are not 
 the(an) intended recipient, please immediately delete this e-mail from your computer 
 system and notify the sender.  Thank you.
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to get context realm from servlet and filter.

2004-10-14 Thread Chris Forbis
I seem to be having an issue :)

I tried the code you provided and did this.

I am getting a null pointer when I ask for service.  Also if I do
server.findServices() to get a list of all of them I get nothing back.
 This is from withing a Servlet to test getting these objects.

//See if we can get the container object
Server server = ServerFactory.getServer();
Service service = server.findService(Catalina);
//Next line gets NULL Pointer, because service is not found
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(engine.getDefaultHost());
Container[] containers = host.findChildren();
for (int i = 0; i  containers.length; i++) {
  Container container = containers[i];
  out.println(!-- Found Container::+container.getName());
}



On Thu, 14 Oct 2004 11:14:31 -0400, Shapira, Yoav [EMAIL PROTECTED] wrote:
 
 Hi,
 I've posted this a number of times in the past on the list, so you can
 STFA.  To summarize, you'd do something like this (most of these classes
 are in the org.apache.catalina package):
 
 Server server = ServerFactory.getServer();
 Service service = server.findService(Catalina);
 Engine engine = (Engine) service.getContainer();
 Host host = (Host) engine.findChild(engine.getDefaultHost());
 Context context = (Context) host.findChild(myContext);
 Realm realm = context.getRealm();
 
 I'm using the default service name of Catalina above: it should match
 what's in your server.xml.  I'm also using myContext as a dummy:
 obviously that should match your webapp name.  And finally, I'm getting
 the Realm from the context, because that's what you asked for, but in
 reality the Realm (or another realm) may be associated with the Host or
 Engine as well.  So take the above code and modify it to your needs.
 
 As always, I caution you and everyone else to not use Tomcat-specific
 (or container-specific in general) code unless absolutely necessary.
 Make your app as portable as possible.  There's almost no conceivable
 good use-case for needing the actual Realm object in your webapp.
 
 Yoav Shapira http://www.yoavshapira.com
 
 
 
 
 -Original Message-
 From: Chris Forbis [mailto:[EMAIL PROTECTED]
 Sent: Thursday, October 14, 2004 11:02 AM
 To: Tomcat Developers List
 Subject: Re: How to get context realm from servlet and filter.
 
 Quick follow-up to your post.
 
 I understand what you are saying.  But I am not sure how to get access
 to the Container, can you point me in the correct direction?
 
 Thanks!
 
 
 On Thu, 14 Oct 2004 08:43:23 -0400, Shapira, Yoav
 [EMAIL PROTECTED]
 wrote:
 
  Hi,
  A Realm is associated with a Container, not necessarily a Context, so
  the method is appropriately placed in the Container interface, a
 parent
  of the Context interface.  Obviously all this is not part of the
 Servlet
  API, so you'll have to write Tomcat-specific code to get it.
 
  Yoav Shapira http://www.yoavshapira.com
 
 
  -Original Message-
  From: Chris Forbis [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, October 13, 2004 6:24 PM
  To: tomcat-dev
  Subject: How to get context realm from servlet and filter.
  
  I am trying to get the current contexts realms from a servlet (and
  maybe a filter).  I do not see a getContext().getRealm() method.  So
 I
  am guessing there is another way to get to this, but I do not see
 it.
  
  Can any one provide some quick direction to me on this.  Thank you!
  
  Chris
  
 
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
  This e-mail, including any attachments, is a confidential business
 communication, and may contain information that is confidential,
 proprietary and/or privileged.  This e-mail is intended only for the
 individual(s) to whom it is addressed, and may not be saved, copied,
 printed, disclosed or used by anyone else.  If you are not the(an)
 intended
 recipient, please immediately delete this e-mail from your computer
 system
 and notify the sender.  Thank you.
 
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 
 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 This e-mail, including any attachments, is a confidential business communication, 
 and may contain information that is confidential, proprietary and/or privileged.  
 This e-mail is intended only for the individual(s) to whom it is addressed, and may 
 not be saved, copied, printed, disclosed or used by anyone else.  If you are not 
 the(an) intended recipient, please immediately delete this e-mail from your computer 
 system and notify the sender.  Thank you

Where to place classes

2004-10-14 Thread Chris Forbis
I am having a problem as where to place classes.

I have a CustomJDBCRealm  (it extends JDBC realm)

I need this to be setup in the context of my application like any
other realm.  If I place my jar in server\lib it works.

BUT

If I do this the MyPrincipal object can not be refrenced from my web
application.

If I place this jar in my webapp lib or in the common\lib the realm
can not find JDBCRealm that is extends from on startup so it fails.

I am a little lost as to the correct place to put this...

I have a CustomJDBCRealm extends JDBCRealm  (it does an getEmailAddress)
I have an interface MyPrincipalInterface extends java.security.Principal
I have a class MyPrincipal implements MyPrincipalInterface

The JDBCRealm gived back a MyPrincipal for its principal...  and my
servlet code then does this to get at it

MyPrincipalInterface p =
(MyPrincipalInterface)httpServletRequest.getUserPrincipal();
String emailAddress = p.getEmailAddress();

As I see it that is all should work except the common\lib as I
understood it was suppose to work for ALL web applications as well as
ALL server side items, but ti does not seem to.

(For refrence most my test has come from the Tomcat Wiki at
http://wiki.apache.org/jakarta-tomcat/HowTo)

I am lost...

Thanks!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to get context realm from servlet and filter.

2004-10-13 Thread Chris Forbis
I am trying to get the current contexts realms from a servlet (and
maybe a filter).  I do not see a getContext().getRealm() method.  So I
am guessing there is another way to get to this, but I do not see it.

Can any one provide some quick direction to me on this.  Thank you!

Chris

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]