Step 1 : Add following line in alfresco-global.properties file located at /alfresco/tomcat/shared/classes location.
authentication.chain=yamaha:yamaha
Step 2 : create new folder test at alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/Authentication location.
Step 3 : create new file test-authentication.properties in test folder created with following content.
external.authentication.defaultAdministratorUserNames=admin
Step 5 : Create new file test-filter-context.xml in same test folder with following content.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Enable control over mapping between request and user ID -->
<bean id="remoteUserMapper" class="org.alfresco.web.app.servlet.DefaultRemoteUserMapper">
<property name="proxyUserName">
<value>${external.authentication.proxyUserName}</value>
</property>
<property name="proxyHeader">
<value>${external.authentication.proxyHeader}</value>
</property>
<property name="active">
<value>${external.authentication.enabled}</value>
</property>
<property name="userIdPattern">
<value>${external.authentication.userIdPattern}</value>
</property>
<property name="personService">
<ref bean="PersonService" />
</property>
</bean>
<!-- Enable cookie-based handling of webscript logins. We must assume cookie based client authentication when external auth is in the chain. -->
<bean id="webscriptAuthenticationFilter" class="org.alfresco.web.app.servlet.WebScriptSSOAuthenticationFilter">
<property name="active">
<value>true</value>
</property>
<property name="authenticationService">
<ref bean="AuthenticationService" />
</property>
<property name="authenticationComponent">
<ref bean="AuthenticationComponent" />
</property>
<property name="personService">
<ref bean="personService" />
</property>
<property name="nodeService">
<ref bean="NodeService" />
</property>
<property name="transactionService">
<ref bean="TransactionService" />
</property>
<property name="container">
<ref bean="webscripts.container" />
</property>
</bean>
</beans>
Step 5 : create new java project in eclipse with any name you want.
Step 6 : create package with name org.alfresco.repo.security.authentication.test in src folder.
Step 7 : Create java class TestCustomAuthenticationImpl.java with following content in same package created.
/**
* Project Name : Alfresco Custom Authentication
* ---------------------
* @author Sourabh Aggarwal
* -----------------------------------------------------------------------------------
* -----------------------------------------------------------------------------------
*/
package org.alfresco.repo.security.authentication.test;
import in.co.ymsli.sedocs.rest.client.ISeDocsRestClient;
import in.co.ymsli.sedocs.rest.client.dto.auth.ValidateTokenDTO;
import in.co.ymsli.sedocs.rest.client.impl.SeDocsRestClientImpl;
import net.sf.acegisecurity.Authentication;
import org.alfresco.repo.security.authentication.AbstractAuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationException;
/**
* @author Sourabh Aggarwal
*
*/
public class TestCustomAuthenticationImpl extends AbstractAuthenticationComponent
{
public void authenticateImpl(String userName, char[] password) throws AuthenticationException
{
System.out.println("userName = "+userName + " ::::::::::::::: password = "+String.valueOf(password));
if(userName == "abc"){
setCurrentUser(oValidateTokenDTO.getUserName());
}else{
System.out.println("Error calling login service");
throw new AuthenticationException("Unable to authentication");
}
}
/**
* The default is not to support Authentication token base authentication
*/
public Authentication authenticate(Authentication token) throws AuthenticationException
{
System.out.println("authenticating vi vi token");
//throw new AlfrescoRuntimeException("Authentication via token not supported");
return token;
}
@Override
protected boolean implementationAllowsGuestLogin() {
// TODO Auto-generated method stub
return false;
}
}
Step 8 : Import all library from alfresco/tomcat/webapps/alfresco/WEB-INF/lib folder.
Step 9 : create jar of java project and place it in alfresco/tomcat/webapps/alfresco/WEB-INF/lib folder.
Step 10: restart server.
Step 11 : its done.
Step 12 : only abc user with any password can login.
authentication.chain=yamaha:yamaha
Step 2 : create new folder test at alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/Authentication location.
Step 3 : create new file test-authentication.properties in test folder created with following content.
external.authentication.defaultAdministratorUserNames=admin
Step 3 : Create new file test-authentication-context.xml in same test folder with following content.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="authenticationComponent" class="org.alfresco.repo.security.authentication.test.TestCustomAuthenticationImpl"
parent="authenticationComponentBase">
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="personService">
<ref bean="personService" />
</property>
<property name="transactionService">
<ref bean="transactionService" />
</property>
<property name="defaultAdministratorUserNameList">
<value>${external.authentication.defaultAdministratorUserNames}</value>
</property>
</bean>
<!-- Wrapped version to be used within subsystem -->
<bean id="AuthenticationComponent" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>org.alfresco.repo.security.authentication.AuthenticationComponent</value>
</list>
</property>
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref bean="authenticationComponent" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">${server.transaction.mode.default}</prop>
</props>
</property>
</bean>
<!-- Authentication service for chaining -->
<bean id="localAuthenticationService" class="org.alfresco.repo.security.authentication.AuthenticationServiceImpl">
<property name="ticketComponent">
<ref bean="ticketComponent" />
</property>
<property name="authenticationComponent">
<ref bean="authenticationComponent" />
</property>
<property name="sysAdminParams">
<ref bean="sysAdminParams" />
</property>
</bean>
</beans>
Step 4 : Create new file test-filter.properties in same test folder with following content.
external.authentication.proxyUserName=alfresco-system
external.authentication.proxyHeader=X-Alfresco-Remote-User
external.authentication.enabled=true
external.authentication.userIdPattern=
Step 5 : Create new file test-filter-context.xml in same test folder with following content.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Enable control over mapping between request and user ID -->
<bean id="remoteUserMapper" class="org.alfresco.web.app.servlet.DefaultRemoteUserMapper">
<property name="proxyUserName">
<value>${external.authentication.proxyUserName}</value>
</property>
<property name="proxyHeader">
<value>${external.authentication.proxyHeader}</value>
</property>
<property name="active">
<value>${external.authentication.enabled}</value>
</property>
<property name="userIdPattern">
<value>${external.authentication.userIdPattern}</value>
</property>
<property name="personService">
<ref bean="PersonService" />
</property>
</bean>
<!-- Enable cookie-based handling of webscript logins. We must assume cookie based client authentication when external auth is in the chain. -->
<bean id="webscriptAuthenticationFilter" class="org.alfresco.web.app.servlet.WebScriptSSOAuthenticationFilter">
<property name="active">
<value>true</value>
</property>
<property name="authenticationService">
<ref bean="AuthenticationService" />
</property>
<property name="authenticationComponent">
<ref bean="AuthenticationComponent" />
</property>
<property name="personService">
<ref bean="personService" />
</property>
<property name="nodeService">
<ref bean="NodeService" />
</property>
<property name="transactionService">
<ref bean="TransactionService" />
</property>
<property name="container">
<ref bean="webscripts.container" />
</property>
</bean>
</beans>
Step 5 : create new java project in eclipse with any name you want.
Step 6 : create package with name org.alfresco.repo.security.authentication.test in src folder.
Step 7 : Create java class TestCustomAuthenticationImpl.java with following content in same package created.
/**
* Project Name : Alfresco Custom Authentication
* ---------------------
* @author Sourabh Aggarwal
* -----------------------------------------------------------------------------------
* -----------------------------------------------------------------------------------
*/
package org.alfresco.repo.security.authentication.test;
import in.co.ymsli.sedocs.rest.client.ISeDocsRestClient;
import in.co.ymsli.sedocs.rest.client.dto.auth.ValidateTokenDTO;
import in.co.ymsli.sedocs.rest.client.impl.SeDocsRestClientImpl;
import net.sf.acegisecurity.Authentication;
import org.alfresco.repo.security.authentication.AbstractAuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationException;
/**
* @author Sourabh Aggarwal
*
*/
public class TestCustomAuthenticationImpl extends AbstractAuthenticationComponent
{
public void authenticateImpl(String userName, char[] password) throws AuthenticationException
{
System.out.println("userName = "+userName + " ::::::::::::::: password = "+String.valueOf(password));
if(userName == "abc"){
setCurrentUser(oValidateTokenDTO.getUserName());
}else{
System.out.println("Error calling login service");
throw new AuthenticationException("Unable to authentication");
}
}
/**
* The default is not to support Authentication token base authentication
*/
public Authentication authenticate(Authentication token) throws AuthenticationException
{
System.out.println("authenticating vi vi token");
//throw new AlfrescoRuntimeException("Authentication via token not supported");
return token;
}
@Override
protected boolean implementationAllowsGuestLogin() {
// TODO Auto-generated method stub
return false;
}
}
Step 8 : Import all library from alfresco/tomcat/webapps/alfresco/WEB-INF/lib folder.
Step 9 : create jar of java project and place it in alfresco/tomcat/webapps/alfresco/WEB-INF/lib folder.
Step 10: restart server.
Step 11 : its done.
Step 12 : only abc user with any password can login.