Hi,
This is what I did.
First of all I did rename the Realm name to MyRealm.
tunnel-web.war\WEB-INF\jboss-web.xml
1<security-domain>java:/jaas/MyRealm</security-domain>
tunnel-web.war\WEB-INF\web.xml
1
2 <login-config>
3 <auth-method>BASIC</auth-method>
4 <realm-name>MyRealm</realm-name>
5 </login-config>
Next I made new class that extends org.jboss.security.auth.spi.DatabaseServerLoginModule;
In this new class I did rewrite getUsersPassword() and getRoleSets() methods.
In this methods the only thing need to be changed is
1ps.setString(1, userName)
This method is rewriten to
1ps.setLong(1, Long.parseLong(username));
This is bacause the id of user is long type.
The class is packed to the jar and placed to the server/default/lib folder
The next thing is realm configuration to the JBosses login-config.xml
1
2 <application-policy name="MyRealm">
3 <authentication>
4 <login-module code="com.xxx.jboss.LiferayDatabaseServerLoginModule"
5 flag="required">
6 <module-option name="dsJndiName">java:/jdbc/LiferayPool</module-option>
7 <module-option name="principalsQuery">
8 select password_ from user_ where userid=?
9 </module-option>
10 <module-option name="rolesQuery">
11 select name, 'Roles' from role_ inner join users_roles on role_.roleid=users_roles.roleid where users_roles.userid = ?
12 </module-option>
13 </login-module>
14 </authentication>
15 </application-policy>
The last thing is client. This is very simple example to get it work:
1
2 public static void main(String[] args){
3 UserServiceSoapServiceLocator locator = new UserServiceSoapServiceLocator();
4 Portal_UserServiceSoapBindingStub stub = null;
5 try {
6 stub = (Portal_UserServiceSoapBindingStub)locator.getPortal_UserService(_getURL("3", "Portal_UserService"));
7 stub.getUserById(10201);
8 } catch (ServiceException e) {
9 // TODO Auto-generated catch block
10 e.printStackTrace();
11 } catch (RemoteException e) {
12 // TODO Auto-generated catch block
13 e.printStackTrace();
14 } catch (Exception e) {
15 // TODO Auto-generated catch block
16 e.printStackTrace();
17 }
18
19 }
20
21 private static URL _getURL(String remoteUser, String serviceName) throws Exception {
22 String password = "password";
23 String url = "http://" + remoteUser + ":" + password + "@localhost:8080/tunnel-web/secure/axis/" + serviceName;
24
25 return new URL(url);
26 }
Tgat's it. Ugly, but works. Ugly because realm is rewritten.
The proper way is to use already defined ProtalRealm. Then there is next definition in login-config.xml:
1
2 <!--Does not work because of class loader problems!!!-->
3 <application-policy name="PortalRealm">
4 <authentication>
5 <login-module code="com.liferay.portal.security.jaas.ext.jboss.PortalLoginModule"
6 flag="required">
7 </login-module>
8 </authentication>
9 </application-policy>
But as i mentioned in previouse mails this configuration doesn't work because of class loading problems. If somebody knows how class loader should be configured or jar files can be replaced, then please let me know.
Regards
Antoni
Please sign in to flag this as inappropriate.