Hi
Jllort
thanks a Lot for replying so instantly to the queries . As per my understanding we can have authentication for user either by having credentials from user-properties and roles-properties Files. It can also be acheived by maintaining the user deatils with LDAP server like Active Directory and With any RDBMS like MySQL.
For my application , initially i tried to authenticate the user with properties file which are placed at JBOSS_HOME/prop folder.and Modified the login-config.xml File with following authentication policy.
For this to make happen i done following Changes in configuration File.
1. In Login-config.xml File
I am trying for this since last two weeks .but no progress . can u please help me out....
thanks in advance.
Jllort
thanks a Lot for replying so instantly to the queries . As per my understanding we can have authentication for user either by having credentials from user-properties and roles-properties Files. It can also be acheived by maintaining the user deatils with LDAP server like Active Directory and With any RDBMS like MySQL.
For my application , initially i tried to authenticate the user with properties file which are placed at JBOSS_HOME/prop folder.and Modified the login-config.xml File with following authentication policy.
Code: Select all
and my openkm.cfg details are as follows.
<application-policy name = "OpenKM">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required">
<module-option name="usersProperties">props/openkm-users.properties</module-option>
<module-option name="rolesProperties">props/openkm-roles.properties</module-option>
</login-module>
<login-module code="org.jboss.security.ClientLoginModule" flag="required" />
</authentication>
</application-policy>
Code: Select all
The Above modication done really worked for me . but I want to have this authentication done with Database i am Using i.e. MySQL .repository.config=repository.xml
repository.home=repository
system.user=system
default.user.role=UserRole
default.admin.role=AdminRole
#principal.adapter=es.git.openkm.principal.DatabasePrincipalAdapter
principal.adapter=es.git.openkm.principal.UsersRolesPrincipalAdapter
max.file.size=5
max.search.results=25
#system.demo=on
#update.info=on
#system.ocr=/usr/bin/tesseract
#system.openoffice=on
max.file.size=100
max.search.results=25
application.url=http://localhost:8080/OpenKM/es.git.openkm.frontend.Main/index.jsp
For this to make happen i done following Changes in configuration File.
1. In Login-config.xml File
Code: Select all
2.In openkm.cfg
<application-policy name = "OpenKM">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
<module-option name="dsJndiName">java:/OKMAuthDS</module-option>
<module-option name="principalsQuery">select usr_pass as PASSWD from users where usr_id=?</module-option>
<module-option name="rolesQuery">select ur_role as ROLEID, 'Roles' from user_role where ur_user=?</module-option>
<module-option name="hashAlgorithm">MD5</module-option>
<module-option name="hashEncoding">base64</module-option>
</login-module>
<login-module code="org.jboss.security.ClientLoginModule" flag="required" />
</authentication>
</application-policy>
Code: Select all
3. just for reference my openkm.ds File is like
repository.config=repository.xml
repository.home=repository
system.user=system
default.user.role=UserRole
default.admin.role=AdminRole
principal.adapter=es.git.openkm.principal.DatabasePrincipalAdapter
#principal.adapter=es.git.openkm.principal.UsersRolesPrincipalAdapter
max.file.size=5
max.search.results=25
#system.demo=on
#update.info=on
#system.ocr=/usr/bin/tesseract
#system.openoffice=on
max.file.size=100
max.search.results=25
application.url=http://localhost:8080/OpenKM/es.git.openkm.frontend.Main/index.jsp
Code: Select all
and Finally my DatabasePrincipalAdapter.java File <?xml version="1.0" ?>
<datasources>
<!-- OpenKM User Activity -->
<local-tx-datasource>
<jndi-name>OKMActivityDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/openkm</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
<!--<security-domain>HsqlDbRealm</security-domain>-->
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<metadata>
<type-mapping>MySQL</type-mapping>
</metadata>
<!-- <depends>jbosservice=Hypersonic,database=OKMActivity</depends> -->
</local-tx-datasource>
<!-- OpenKM User Auth -->
<local-tx-datasource>
<jndi-name>OKMAuthDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/openkm</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
<!--<security-domain>HsqlDbRealm</security-domain>-->
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<metadata>
<type-mapping>MySQL</type-mapping>
</metadata>
<!--<depends>jbosservice=Hypersonic,database=OKMAuth</depends> -->
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>OKMDashboardStatsDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/openkm</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>0</idle-timeout-minutes>
<track-statements/>
<!--<security-domain>HsqlDbRealm</security-domain>-->
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<metadata>
<type-mapping>MySQL</type-mapping>
</metadata>
<!-- <depends>jbosservice=Hypersonic,database=OKMDashboardStats</depends>-->
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>OKMWorkflowDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/okmworkflow</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>root</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
<track-statements/>
<!--<security-domain>HsqlDbRealm</security-domain>-->
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Code: Select all
My Query is that even after modifying these file respectively i am not able to access the application as i was able to do in previous case where authentication was happening with the help of properties File.package es.git.openkm.principal;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import es.git.openkm.core.Config;
import es.git.openkm.dao.AuthDAO;
import es.git.openkm.dao.bean.Role;
import es.git.openkm.dao.bean.User;
public class DatabasePrincipalAdapter implements PrincipalAdapter {
private static Logger log = LoggerFactory.getLogger(DatabasePrincipalAdapter.class);
public Collection<String> getUsers() throws PrincipalAdapterException {
log.debug("getUsers()");
ArrayList<String> list = new ArrayList<String>();
try {
Collection<User> col = AuthDAO.getInstance().findAllUsers();
for (Iterator<User> it = col.iterator(); it.hasNext(); ) {
User dbUser = it.next();
if (!Config.PRINCIPAL_DATABASE_FILTER_INACTIVE_USERS.equals("on") || dbUser.isActive()) {
list.add(dbUser.getId());
}
}
} catch (SQLException e) {
throw new PrincipalAdapterException(e.getMessage(), e);
}
log.debug("getUsers: "+list);
return list;
}
public Collection<String> getRoles() throws PrincipalAdapterException {
log.debug("getRoles()");
ArrayList<String> list = new ArrayList<String>();
try {
Collection<Role> col = AuthDAO.getInstance().findAllRoles();
for (Iterator<Role> it = col.iterator(); it.hasNext(); ) {
Role dbRole = it.next();
list.add(dbRole.getId());
}
} catch (SQLException e) {
throw new PrincipalAdapterException(e.getMessage(), e);
}
log.debug("getRoles: "+list);
return list;
}
public Collection<String> getMails(Collection<String> users) throws PrincipalAdapterException {
log.debug("getMails()");
ArrayList<String> list = new ArrayList<String>();
try {
for (Iterator<String> it = users.iterator(); it.hasNext(); ) {
String userId = it.next();
es.git.openkm.dao.bean.User user = AuthDAO.getInstance().findUserByPk(userId);
if (user != null && !user.getEmail().equals("")) {
list.add(user.getEmail());
}
}
} catch (SQLException e) {
throw new PrincipalAdapterException(e.getMessage(), e);
}
log.debug("getMails: "+list);
return list;
}
}
I am trying for this since last two weeks .but no progress . can u please help me out....
