You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by 张云勇 <ev...@163.com> on 2007/12/17 06:15:03 UTC

Is struts 1.X has JAAS integration API?

 Is struts 1.X has JAAS integration API?
I want to use the follow code:

HttpServletRequest request = ServletActionContext.getRequest();
String authType = request.getAuthType(); // http or https
String user = request.getRemoteUser(); // the user principal (in string)
Principalprincipal = request.getUserPrincipal(); // get a Principal object
bool isAuth = request.isUserInRole("patrick");

but I don't know how to set the values for authType ,remoteUser etc.
anyone can give me help~

 
 
 

Re: Re: Is struts 1.X has JAAS integration API?

Posted by Paul Benedict <pb...@apache.org>.
Write yourself a filter. The filter should wrap the HttpServletRequest
object (JEE HttpServletRequestWrapper class) and also contain a reference to
the user's credentials. Just override isUserInRole to provide your logic.

Paul

On Dec 17, 2007 12:31 AM, 张云勇 <ev...@163.com> wrote:

>  Sorry for my pool English, I'm improving it^_^
>
> Here is my mean:
> I want to get auth user from request, but I don't know how to set the user
> to the request,like this:
>
> String user = request.getRemoteUser(); // the user principal (in string)
> Principalprincipal = request.getUserPrincipal(); // get a Principal object
> bool isAuth = request.isUserInRole("patrick");
>
>
> someone says it can be achieved by using container managed security
> policy, I can do it through by tomcat 5.X
> using "j_security" servlet, but if I want to custome the login action,such
> as logging the user's logon timestamp, how can I do it. Is struts 1.xprovied any JAAS related API to complete this?

回复:Re: Is struts 1.X has JAAS integration API?

Posted by 张云勇 <ev...@163.com>.
 Sorry for my pool English, I'm improving it^_^

Here is my mean:
I want to get auth user from request, but I don't know how to set the user to the request,like this:

String user = request.getRemoteUser(); // the user principal (in string)
Principalprincipal = request.getUserPrincipal(); // get a Principal object
bool isAuth = request.isUserInRole("patrick");


someone says it can be achieved by using container managed security policy, I can do it through by tomcat 5.X
using "j_security" servlet, but if I want to custome the login action,such as logging the user's logon timestamp, how can I do it. Is struts 1.x provied any JAAS related API to complete this? 

Re: Is struts 1.X has JAAS integration API?

Posted by Wendy Smoak <ws...@gmail.com>.
On Dec 16, 2007 10:15 PM, 张云勇 <ev...@163.com> wrote:
>  Is struts 1.X has JAAS integration API?
> I want to use the follow code:
>
> HttpServletRequest request = ServletActionContext.getRequest();
> String authType = request.getAuthType(); // http or https

Based on the comment, you probably want getScheme() here...
see
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#getScheme()
vs.
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getAuthType()

> String user = request.getRemoteUser(); // the user principal (in string)
> Principalprincipal = request.getUserPrincipal(); // get a Principal object
> bool isAuth = request.isUserInRole("patrick");
>
> but I don't know how to set the values for authType ,remoteUser etc.
> anyone can give me help~

I'm not sure exactly what you're asking, and it probably depends on
what container you're using.  Most of them come with examples to help
you get started.  Explain  bit more about what you need to do, and
someone can probably help.

-- 
Wendy