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

2004-10-15 Thread Antoine Brocard - Vertical*i S.A.
I'm trying to use this code from withing a JAAS LoginModule (see 
yesterday's post from Michael Vorburger) and I have another problem.

My LoginModule class must be in common/lib or in application's 
classpath. It uses classes that are (normally) in server/lib (all the 
Catalina classes).

How do you make that work without copying the Catalina's jars from 
server/lib to common/lib, what I would like to avoid?


Chris Forbis wrote:
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

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

2004-10-15 Thread Shapira, Yoav

Hi,

My LoginModule class must be in common/lib or in application's
classpath. It uses classes that are (normally) in server/lib (all the
Catalina classes).

How do you make that work without copying the Catalina's jars from
server/lib to common/lib, what I would like to avoid?

The classes in common/lib, shared/lib, and WEB-INF/lib cannot see the
classes in server/lib (a.k.a the Catalina classloader repository in the
Classloader How-To document).  So you must copy or move your classes
around.

Note, however, that according to the same document the classes in
server/lib *can* see and use classes in common/lib.  So you might be
able to plugin something the other way from your current design.

 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.

That's strange.  I typed the code from memory and haven't actually used
it in a long time (it used to work, but I hate having container-specific
code in my apps, so I don't do it any more).  Maybe someone else can
correct my code or explain why you're getting a null service.

Yoav



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]



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

2004-10-15 Thread Antoine Brocard - Vertical*i S.A.
 Note, however, that according to the same document the classes in
 server/lib *can* see and use classes in common/lib.  So you might be
 able to plugin something the other way from your current design.
I really don't see how... The LoginModule has to be accessible from my 
application's classes.

Shapira, Yoav wrote:
Hi,

My LoginModule class must be in common/lib or in application's
classpath. It uses classes that are (normally) in server/lib (all the
Catalina classes).
How do you make that work without copying the Catalina's jars from
server/lib to common/lib, what I would like to avoid?

The classes in common/lib, shared/lib, and WEB-INF/lib cannot see the
classes in server/lib (a.k.a the Catalina classloader repository in the
Classloader How-To document).  So you must copy or move your classes
around.
Note, however, that according to the same document the classes in
server/lib *can* see and use classes in common/lib.  So you might be
able to plugin something the other way from your current design.

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.

That's strange.  I typed the code from memory and haven't actually used
it in a long time (it used to work, but I hate having container-specific
code in my apps, so I don't do it any more).  Maybe someone else can
correct my code or explain why you're getting a null service.
Yoav

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-15 Thread Cox, Charlie
You can set your context to be privileged so that your login class in
WEB-INF\lib can access the \server\lib classes. But keep in mind anything
from your context can access tomcat's internal classes, so it is a security
risk.

Context ... privileged=true

Charlie

 -Original Message-
 From: Antoine Brocard - Vertical*i S.A. [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 15, 2004 10:10 AM
 To: Tomcat Developers List
 Subject: Re: How to get context realm from servlet and filter.
 
   Note, however, that according to the same document the classes in
   server/lib *can* see and use classes in common/lib.  So you might be
   able to plugin something the other way from your current design.
 
 I really don't see how... The LoginModule has to be accessible from my
 application's classes.
 
 Shapira, Yoav wrote:
  Hi,
 
 
 My LoginModule class must be in common/lib or in application's
 classpath. It uses classes that are (normally) in server/lib (all the
 Catalina classes).
 
 How do you make that work without copying the Catalina's jars from
 server/lib to common/lib, what I would like to avoid?
 
 
  The classes in common/lib, shared/lib, and WEB-INF/lib cannot see the
  classes in server/lib (a.k.a the Catalina classloader repository in the
  Classloader How-To document).  So you must copy or move your classes
  around.
 
  Note, however, that according to the same document the classes in
  server/lib *can* see and use classes in common/lib.  So you might be
  able to plugin something the other way from your current design.
 
 
 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.
 
 
  That's strange.  I typed the code from memory and haven't actually used
  it in a long time (it used to work, but I hate having container-specific
  code in my apps, so I don't do it any more).  Maybe someone else can
  correct my code or explain why you're getting a null service.
 
  Yoav
 
 
 
  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-15 Thread Benson Margulies
List a class as a global JNDI resource to arrange the necessary
communications?

-
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 Shapira, Yoav

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]



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 Shapira, Yoav

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.


-
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 Michael Vorburger
Yoav,
Re. There's almost no conceivable good use-case for needing the actual 
Realm object in your webapp., here is one: We receive requests from a 
dumb Windows client application (no SOAP, simple stupid proprietary XML 
format in HTTP) that sends a uid/pwd somehwere inside the POST payload, 
not even as BASIC, and so have to validate that... how would you do that?

Agree that container-specific code should be avoided inside applications 
unless absolutely necessary - and on other containers that's easy, 
because you can use the JAAS API to authenticate uid/pwd from within a 
web application, e.g. both WebLogic or WebSphere have built-in JAAS 
LoginModule implementations which forward to whatever they call a realm.

On Tomcat however that JAAS approach is not so far possible. See also my 
post yesterday Authenticate against realm in web app: JAAS 
TomcatRealmProxyLoginModule? (WAS: The good way of making JAAS and Realm 
authentication use the same back-end authentication system?).

Thanks,
Michael
PS: Thanks for code snippet, we'll see if that helps us to write a 
better TomcatRealmProxyLoginModule, taking a context name as 
configuration parameter.


Shapira, Yoav 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

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

2004-10-14 Thread Shapira, Yoav

Hola,

Re. There's almost no conceivable good use-case for needing the actual
Realm object in your webapp., here is one: We receive requests from a
dumb Windows client application (no SOAP, simple stupid proprietary XML
format in HTTP) that sends a uid/pwd somehwere inside the POST payload,
not even as BASIC, and so have to validate that... how would you do
that?

Yeah, that's why I said almost. ;)  There's always someone somewhere
with a legacy app with a proprietary protocol, and in those cases one
usually must take extra measures.  Yours seems like such a case.  I'm
well aware that it's impossible for any one person to preclude the
existence of any use-case given Tomcat's amazingly wide user base, and
that's why I included the almost in my assertion that you quote above
;)

Of course, depending on the amount of control you have, and/or your
requirements, one might argue that you time is better spent modifying
the Windows client app to use a standard authentication approach.  But
that's beyond the scope of this thread or this mailing list in general.

On Tomcat however that JAAS approach is not so far possible. See also
my
post yesterday Authenticate against realm in web app: JAAS
TomcatRealmProxyLoginModule? (WAS: The good way of making JAAS and
Realm
authentication use the same back-end authentication system?).

I didn't follow your thread yesterday.  But if you end up writing such a
module, I'd be very interested in seeing it, and of course with your
permission incorporating it into Tomcat.

Yoav



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]



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

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]