spring ldap

59
Spring LDAP Spring LDAP basics: how to start to use the LdapTemplate in your custom J2EE application

Upload: piergiorgio-lucidi

Post on 27-Jan-2015

136 views

Category:

Technology


5 download

DESCRIPTION

This presentation was shown at Spring Framework Meeting 2009 in Rome (Lazio - Italy) - 31th October 2009. http://www.open4dev.com/journal/2009/10/26/spring-framework-meeting-2009-rome.html Abstract: Spring LDAP basics: how to start to use the LdapTemplate in your custom J2EE application. This how-to will show you how to bind, unbind, search and authenticate users in your LDAP using the LdapTemplate provided by Spring.

TRANSCRIPT

Page 1: Spring Ldap

Spring LDAPSpring LDAP basics: how to start to use the

LdapTemplate in your custom J2EE application

Page 2: Spring Ldap

About meProduct Specialist at Sourcesense

ECMsystem integrationweb / portals

Alfresco

Certified Alfresco TrainerForum supporter (en, it)

JBoss Portal / GateIn

Project Leader:JBoss WikiJBoss Feeds/Blog

Committer:JBoss LabsJBoss PortletSwap JBoss Forums

Wiki editor + forum supporter

Contributions Database Dependencies (dbdep)

DbDep for Apache IvyDbDep for Apache Maven

CMIS Portlet Affiliate Partner at Packt PublishingCreative Commons supporter

Past

Editor at oneOpenSource.it My website: http://www.open4dev.com/ Where you can find me

http://www.open4dev.com/community/

Page 3: Spring Ldap

Agenda

1. ECM in the real world2. Introduction to LDAP 3. Spring LDAP

basicsoperations

AuthenticationSearchBindUnbindModify

Page 4: Spring Ldap

ECM=Enterprise Content Management

AIIM Definition (Association for Information and Image Management) Enterprise Content Management embodies the technologies used to capture, manage, store, preserve and deliver content and documents related to organizational processes.

WikipediaA system for organizing and facilitating collaborative creation of documents and other contentAble to monitor content through its lifecycle, and track changes to content, and users of contentSometimes a web application used for managing websites and web contentIn many cases, content management systems require special client software for editing and constructing articles

Page 5: Spring Ldap

ECM architecture - step 1

Page 6: Spring Ldap

ECM architecture - step 2

Page 7: Spring Ldap

Introduction to LDAP

Page 8: Spring Ldap

What is LDAP

Lightweight Directory Access Protocolentries based on an hierarchical tree: Directory Information Tree (DIT) manage information about people and servicesis a protocol over TCP/IP (DAP was over OSI)used with a Directory System Agent (DSA = LDAP Server)

Implementations

ApacheDSOpenLDAPOpenDS

Page 9: Spring Ldap

LDAP stored information

Usersstandard attributes (name, surname, address, age, etc...) custom attributes (department, skills, etc...)

Groups

memberscustom attributes (department, city, role)

Page 10: Spring Ldap

LDAP data structure

Page 11: Spring Ldap

LDAP data structure - Group

Page 12: Spring Ldap

LDAP data structure - User

Page 13: Spring Ldap

LDAP Directory Information Tree (DIT)

Page 14: Spring Ldap

LDAP Directory Information Tree (DIT)

Page 15: Spring Ldap

LDAP - BaseDN

BaseDN = ou=users, ou=system

Page 16: Spring Ldap

LDAP - Modification Logs - add user

Page 17: Spring Ldap

LDAP - Modification Logs - add user

Page 18: Spring Ldap

LDAP - Modification Logs - member

Page 19: Spring Ldap

LDAP features

Authentication ( = get LDAP context)encrypted user passwordsLDAP connector using TCP/IP (default port 389)

Authorization ( = search attributes)

groupsmembers

Page 20: Spring Ldap

Software architecture

Page 21: Spring Ldap

Software architecture - beans graph

Page 22: Spring Ldap

Software architecture - beans graph 2

Page 23: Spring Ldap

Software architecture

Page 24: Spring Ldap

Spring LDAP - resources

project page: http://www.springsource.org/ldap

downloads: http://www.springsource.com/download/community?project=Spring%20LDAP

docs: http://static.springframework.org/spring-ldap/docs/1.3.x/reference/html/ api: http://static.springframework.org/spring-ldap/docs/1.3.x/apidocs/ forum: http://forum.springframework.org/forumdisplay.php?f=40 source code: http://src.springframework.org/svn/spring-ldap/trunk

Page 25: Spring Ldap

Spring LDAP - project page

Page 26: Spring Ldap

Spring LDAP - how to start with Maven

add in your pom.xml the following dependencies:

Page 27: Spring Ldap

Spring LDAP - how to start without Maven

1. download the latest stable with dependecies from here: http://www.springsource.com/download/community?project=Spring%20LDAP

2. extract and import all the libraries in your classpath3. bind the source code for Spring LDAP libraries from: 4. spring-ldap-1.3.0.RELEASE-with-dependencies/dist/modules-source

Page 28: Spring Ldap

The traditional way

using Java LDAP standard

Page 29: Spring Ldap

Java LDAP

Page 30: Spring Ldap

Spring LDAP

Spring context configuration

Page 31: Spring Ldap

Spring Context - PropertyPlaceHolder

you can configure Spring contexts with properties files

Page 32: Spring Ldap

Spring Context - LdapTemplate

LdapTemplate is the core of Spring LDAP

Page 33: Spring Ldap

Spring context - ldap.properties

Page 34: Spring Ldap

Spring LDAP

Authentication

Page 35: Spring Ldap

Spring Context - AuthenticationDao

Page 36: Spring Ldap

Spring Bean - AuthenticationDAO.java

IoC pattern with setter injection

Page 37: Spring Ldap

POJO - LoginVO.java

Page 38: Spring Ldap

LdapTemplate

Authentication using Spring LDAP 1.2.1

Page 39: Spring Ldap

AuthenticationDAO.java - getUserDN

how to authenticate users using Spring LDAP 1.2.1

Page 40: Spring Ldap

Spring Context - AuthenticationBl

Page 41: Spring Ldap

Spring Bean - AuthenticationBl.java

Page 42: Spring Ldap

Spring Bean - AuthenticationBl.javahow to authenticate users using Spring LDAP 1.2.1

Page 43: Spring Ldap

LdapTemplate

Authentication using Spring LDAP 1.3.0

Page 44: Spring Ldap

Spring Context - AuthenticationBl

add ldapTemplate to your old implementation

Page 45: Spring Ldap

Spring Bean - AuthenticationBl.java

how to authenticate users using Spring LDAP 1.3.0

add dinamically filters for LDAP fieldsauthentication feature with custom constraints on your LDAPmuch easier to implement!

Page 46: Spring Ldap

Spring LDAP

Search

Page 47: Spring Ldap

SearchDAO.java - single attribute

returns a list with a single attribute

Page 48: Spring Ldap

Search - PersonVO.java

Page 49: Spring Ldap

SearchDAO.java - return an object

returns a list of Person objects

Page 50: Spring Ldap

SearchDAO.java - find a Person

Page 51: Spring Ldap

SearchDAO.java - dynamic filter

Page 52: Spring Ldap

Spring LDAP

Binding - how to insert entries

Page 53: Spring Ldap

PersonDAO.java - insert a new Person

Page 54: Spring Ldap

Spring LDAP

Unbinding - how to remove an entry

Page 55: Spring Ldap

PersonDAO.java - remove a Person

Page 56: Spring Ldap

Spring LDAP

Modifying - how to change an entry

Page 57: Spring Ldap

PersonDAO.java - Modifying using rebind

rebind = unbind + bindvery crude maybe you don't want to do this!

Page 58: Spring Ldap

PersonDAO.java - Modifying using modifyAttributes

Page 59: Spring Ldap

Thank you

My website:http://www.open4dev.com