You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by ZhongGuan <gu...@gmail.com> on 2013/04/09 14:31:50 UTC

TomEE Configure JAAS

hi,
at first, I have read the blog at
http://rmannibucau.wordpress.com/2012/05/09/tomee-and-its-ssh-connector/
and
http://rmannibucau.wordpress.com/2012/10/18/create-a-tomee-accessible-through-ssh-with-tomee-maven-plugin/

but i still can not make the JAAS in Tomee work.
(I think it should popup a prompt window and let me input the user and
password,
when I access the Url http://localhost:8080  right?)

and My config is 
1.  add login.config, users.properties and groups.properties to
tomee_home/conf/
2.  add the startup param
-Djava.security.auth.login.config=D:\tomee-plus1.5.1\conf\login.config
3.  add the SecurityListener and Realm in server.xml 

When I access the http://localhost:8080, the index.html shows..
do I miss something? should I add some filter or something?

thanks.


     



--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-Configure-JAAS-tp4662130.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE Configure JAAS

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Badically jaadrealm is only used to use jaas when calling httprequest.login.
Le 9 avr. 2013 21:37, "ZhongGuan" <gu...@gmail.com> a écrit :

> hi, I have written a simple sample (a servlet), and wrote the new
> LoginContext stuff. and it worked.
>
> String userName = request.getParameter("userName");
> String password = request.getParameter("password");
> LoginContext lc = new LoginContext("PropertiesLoginModule", new
> UsernamePasswordCallbackHandler(userName, password));
> lc.login();
> Subject subject = lc.getSubject();
>
> I still have a question.
> When I write code like this, I do not need to add the JAASRealm in
> server.xml
> I just need a login.config, users.properties, groups.properties
> and a java.security.auth.login.config setting in system.properties.
>
> I read some documents, it seems that tomcat will call the method
> authenticate in JAASRealm Class,
> and in this method, it uses the new LoginContext() and JAASCallbackHandler.
> so that, i think if
> I add the JAASRealm in server.xml, maybe I do not need to write code above.
>
> after that, I try to add the  <security-constraint> in web.xml, and when I
> access the url,
> it will open a dialog to input user and password, I try to input the user
> and password that in the users.properties, but it does not work.
>
> so I want to ask, how to use the JAASRealm?
>
> here is some of my settings
> groups.properties
>     admin=test
> users.properties
>     test=test
> web.xml
>         <security-constraint>
>                 <web-resource-collection>
>                         <web-resource-name>Protected
> Area</web-resource-name>
>                         <url-pattern>/admin/*</url-pattern>
>                 </web-resource-collection>
>                 <auth-constraint>
>                         <role-name>admin</role-name>
>                 </auth-constraint>
>         </security-constraint>
>         <login-config>
>                 <auth-method>BASIC</auth-method>
>                 <realm-name>JAASRealm</realm-name>
>         </login-config>
>
> My input of the popup dialog is "test" and "test", but I can not login.
>
> Thanks.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/TomEE-Configure-JAAS-tp4662130p4662140.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: TomEE Configure JAAS

Posted by ZhongGuan <gu...@gmail.com>.
hi, I have written a simple sample (a servlet), and wrote the new
LoginContext stuff. and it worked.

String userName = request.getParameter("userName");
String password = request.getParameter("password");
LoginContext lc = new LoginContext("PropertiesLoginModule", new
UsernamePasswordCallbackHandler(userName, password));
lc.login();
Subject subject = lc.getSubject();

I still have a question.
When I write code like this, I do not need to add the JAASRealm in
server.xml
I just need a login.config, users.properties, groups.properties
and a java.security.auth.login.config setting in system.properties.

I read some documents, it seems that tomcat will call the method
authenticate in JAASRealm Class,
and in this method, it uses the new LoginContext() and JAASCallbackHandler.
so that, i think if 
I add the JAASRealm in server.xml, maybe I do not need to write code above.

after that, I try to add the  <security-constraint> in web.xml, and when I
access the url, 
it will open a dialog to input user and password, I try to input the user
and password that in the users.properties, but it does not work.

so I want to ask, how to use the JAASRealm?

here is some of my settings
groups.properties
    admin=test
users.properties
    test=test
web.xml
	<security-constraint>
		<web-resource-collection>
			<web-resource-name>Protected Area</web-resource-name>
			<url-pattern>/admin/*</url-pattern>
		</web-resource-collection>
		<auth-constraint>
			<role-name>admin</role-name>
		</auth-constraint>
	</security-constraint>
	<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>JAASRealm</realm-name>
	</login-config>

My input of the popup dialog is "test" and "test", but I can not login.

Thanks.




--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-Configure-JAAS-tp4662130p4662140.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE Configure JAAS

Posted by ZhongGuan <gu...@gmail.com>.
thanks,I am learning jaas, after that I will try again



--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-Configure-JAAS-tp4662130p4662134.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE Configure JAAS

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

jaas is just an api to let you put what you want behing. The login/perm
logic is not defined so you need to call it yourself (new LoginContext...)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/4/9 ZhongGuan <gu...@gmail.com>

> hi,
> at first, I have read the blog at
> http://rmannibucau.wordpress.com/2012/05/09/tomee-and-its-ssh-connector/
> and
>
> http://rmannibucau.wordpress.com/2012/10/18/create-a-tomee-accessible-through-ssh-with-tomee-maven-plugin/
>
> but i still can not make the JAAS in Tomee work.
> (I think it should popup a prompt window and let me input the user and
> password,
> when I access the Url http://localhost:8080  right?)
>
> and My config is
> 1.  add login.config, users.properties and groups.properties to
> tomee_home/conf/
> 2.  add the startup param
> -Djava.security.auth.login.config=D:\tomee-plus1.5.1\conf\login.config
> 3.  add the SecurityListener and Realm in server.xml
>
> When I access the http://localhost:8080, the index.html shows..
> do I miss something? should I add some filter or something?
>
> thanks.
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/TomEE-Configure-JAAS-tp4662130.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>