Showing posts with label alfresco 4. Show all posts
Showing posts with label alfresco 4. Show all posts

Wednesday, June 13, 2012

Create OpenLDAP chaining

Many times we require alfresco authentication from one or more LDAP system for authentication.
Here we will look at authentication from two openLDAP.

Note : Below configuration is related to alfresco 4.x versions

I am here refering two LDAP as below :
#1) Internal LDAP
#2) ExternalLDAP

Step #1) Copy ldap files from original location and create/paste to extension path.
-----------------------------------------------------------------------------------
Copy following file from path
 (<alfresco>\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\Authentication\ldap)
1. ldap-authentication.properties
2. ldap-authentication-context.xml

Paste both file(s)  to following location. (<alfresco>\tomcat\shared\classes\alfresco\extension\subsystems\Authentication\ldap\internalLDAP)
(<alfresco>\tomcat\shared\classes\alfresco\extension\subsystems\Authentication\ldap\externalLDAP)

You can see here we need to create two folders 1) internalLDAP  2) externalLDAP to separate out both LDAP.

You can configure internalLDAP connection settings in ldap-authentication.properties inside internalLDAP folder and for externalLDAP to same file ldap-authentication.properites.

Step #2) Add  common-ldap-context.xml
-------------------------------------------
Copy <alfresco>\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\Authentication\common-ldap-context.xml

Paste to path (<alfresco>\tomcat\shared\classes\alfresco\extension\subsystems\Authentication )

Step #3) Make chaining entry inside alfresco-global.properties
-------------------------------------------------------------------------
 Place below entry


### Ldap settings ####
authentication.chain=externalLDAP:ldap,internalLDAP:ldap,alfrescoNtlm1:alfrescoNtlm

You can place these 3 in any order you want.

alfrescoNtlm is alfresco's default authentication mechanism.

Please make above changes and restart server.







Thursday, May 24, 2012

Enable javascript debugging log

In alfresco share we sometime need to log the js content.
Using below configuration we can enable javascript logging .

inside log4j.properties modify below entry to debug from error or warn.

log4j.logger.org.alfresco.repo.jscript=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug




Auditing custom content types

Sometimes in important application requires auditing data. Alfresco provides auditing facility based on nodes behavior and actions.
In most cases out of box audit configuration is enough to satisfy the requirements, but sometime it requires certain kind of data also needs to be audited. Like we are auditing our own custom content types.

I have tested below configuration in Alfresco version 4.0 EE

E.g. I have my own custom content type say "clm:contract" and I want to monitor changes inside this node whether its create/read/update/delete.

We are including following configuration in alfresco-global.properties file to achieve this.

audit.enabled=true
audit.alfresco-access.enabled=true
audit.alfresco-access.sub-actions.enabled=true




### Audit Filter ### audit.filter.alfresco-access.default.enabled=true audit.filter.alfresco-access.transaction.user=~System;~null;.* audit.filter.alfresco-access.transaction.type=cm:folder;cm:content;st:site;clm:contract audit.filter.alfresco-access.transaction.path=~/sys:archivedItem;~/ver:;.*

Above configuration is enough to detect your custom content type clm:contract and auditing it.
If you want to see detailed log in console just write below configuration in log4j.properties file.

### Audit Logs ###
log4j.logger.org.alfresco.repo.audit.AuditComponentImpl=DEBUG
log4j.logger.org.alfresco.repo.audit.inbound=DEBUG

EnJOy !!



Thursday, April 12, 2012

Creating a folder in alfresco repository

When you want to create some folder in alfresco repository use below kind of snippet to help you creating space/folder inside repository.

private NodeRef createFolder(NodeRef parentNode, String folderName)
    {
        ServiceRegistry serviceRegistry = AlfrescoServiceRegistry.getServiceRegistry();
        FileInfo fInfo = serviceRegistry.getFileFolderService().create(parentNode, folderName, ContentModel.TYPE_FOLDER);
        return fInfo.getNodeRef();
    }

Putting logger in alfresco

Many times we need to observe certain custom things to be logged.
To enable logger we need to change log4j.properties which is located in alfresco at following location:

Location : <alfresco_home>/tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties

Let say we have packages which is starting with like  com.company.projectx
then make an entry at last to log4j.properties like "log4j.logger.com.company.projectx=debug"

and inside java class do following :

public class CustomClass
{
 private static final Log LOGGER = LogFactory.getLog(CustomClass.class);
  protected processNode()
 {
               LOGGER.debug(" INSIDE processNode method "); 
        }
}

Alfresco login with system user and restore back

Many time we need to perform certain operations in alfresco which needs system user access.
Using following code snippet we can use system user and restore back it to normal user authentication.

Note : alfresco 4 Enterprise version considered as of now


try
{
final Authentication authentication = AuthenticationUtil.getFullAuthentication();
AuthenticationUtil.setRunAsUserSystem(); 
// do your operation here
}
finally
{
AuthenticationUtil.clearCurrentSecurityContext();
AuthenticationUtil.setFullAuthentication(authentication);
}