Hi,
It is already working from ACC, but not from standalone client.
I have two question:
1st is what can I do in standalone client?
2nd is what can I use instead "com.sun.enterprise.security.auth.login.ClientPasswordLoginModule" if I want a silent login without a LoginDialog.
Description and example are attached.
Thanks, Attila.
Create Tables:
--------------
create table usertable (
username varchar(128) NOT NULL CONSTRAINT USER_PK PRIMARY KEY ,
password varchar(128) NOT NULL
);
create table grouptable(
username varchar(128) NOT NULL,
groupname varchar(128) NOT NULL,
CONSTRAINT GROUP_PK PRIMARY KEY(username, groupname),
CONSTRAINT USER_FK FOREIGN KEY(username) REFERENCES usertable(username)
ON DELETE CASCADE ON UPDATE RESTRICT
);
and populate:
-------------
insert into usertable(username,password) values ('programmer', 'hello');
insert into grouptable(username,groupname) values ('programmer', 'developers');
insert into grouptable(username,groupname) values ('guest', 'guests');
make sure your database is up and running, compare properties to other loaded connection pools..
Create Connection Pools:
------------------------
In the Glassfish admin panel:
Resources->JDBC->Connection Pools, select 'new'
Pool Name: authPool
...
<OK>
Create JDBC Resource:
---------------------
In the Glassfish admin panel:
Resources->JDBC->JDBC resources, select 'new'
JNDI Name: jdbc/auth
Pool Name: authPool
<OK>
Create JDBCRealm:
-----------------
In the Glassfish admin panel:
Configuration->Security->Realm, select 'new'
Name: helloRealm
Class Name: com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm
JAAS Context: jdbcRealm
JNDI: jdbc/security
User Table: usertable
User Name Column: username
Password Column: password
Group Table: grouptable
Group Name Column: groupname
Digest Algorithm: none
<OK>
/java/projects/HelloApp/src/conf/sun-application.xml
<sun-application>
<security-role-mapping>
<role-name>programmers</role-name>
<group-name>developers</group-name>
</security-role-mapping>
<realm>helloRealm</realm>
</sun-application>
/java/projects/HelloApp/HelloApp-ejb/src/conf/sun-ejb-jar.xml
<sun-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>StatelessSessionBean</ejb-name>
<ior-security-config>
<as-context>
<auth-method>username_password</auth-method>
<realm>helloRealm</realm>
<required>true</required>
</as-context>
</ior-security-config>
</ejb>
</enterprise-beans>
</sun-ejb-jar>
/java/projects/HelloApp/HelloApp-ejb/src/java/enterprise/hello_stateless_ejb/StatelessSessionBean.java
@RolesAllowed("programmers")
/java/projects/HelloApp/HelloApp-app-client/src/conf/login.config
helloRealm {
com.sun.enterprise.security.auth.login.ClientPasswordLoginModule required debug=false;
};
/java/projects/HelloApp/HelloApp-app-client/src/java/enterprise/hello_stateless_client/StatelessJavaClient.java
System.setProperty("java.security.auth.login.config", "META-INF/login.config");
StatelessJavaClientPassiveCallbackHandler ch = new StatelessJavaClientPassiveCallbackHandler("programmer", "hello");
try {
InitialContext ic = new InitialContext();
LoginContext lc = new LoginContext("helloRealm",ch);
lc.login();
NetBeans
Open project HelloApp
Clean and Build
test
hellostub_and_testacc.sh
[Message sent by forum member 'aszomor']
http://forums.java.net/jive/thread.jspa?messageID=398662