<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Source Allies Blog &#187; Spring LDAP</title>
	<atom:link href="http://blogs.sourceallies.com/tag/spring-ldap/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.sourceallies.com</link>
	<description>Technical and process thinking from Source Allies employees</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:40:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring Roo Sample App Tutorial &#8211; Part 1</title>
		<link>http://blogs.sourceallies.com/2009/12/spring-roo-sample-app-tutorial-part-1/</link>
		<comments>http://blogs.sourceallies.com/2009/12/spring-roo-sample-app-tutorial-part-1/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 17:44:56 +0000</pubDate>
		<dc:creator>Matt Vincent</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Java 1.5]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[OpenLDAP]]></category>
		<category><![CDATA[Roo 1.0.0.RC3]]></category>
		<category><![CDATA[Spring LDAP]]></category>
		<category><![CDATA[Spring Security 3.0]]></category>
		<category><![CDATA[Spring Security Tags]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=691</guid>
		<description><![CDATA[In this blog, I will start creating a web application used to organize bookmarks.  Because only certain bookmarks are of interest to specific groups of people, I will use groups in our LDAP server to control which users see which groups of bookmarks.
The entire blog will be released in posts staggered over time.  [...]]]></description>
			<content:encoded><![CDATA[<p>In this blog, I will start creating a web application used to organize bookmarks.  Because only certain bookmarks are of interest to specific groups of people, I will use groups in our LDAP server to control which users see which groups of bookmarks.</p>
<p>The entire blog will be released in posts staggered over time.  Part 1 will focus on initial setup of Roo, the core web application and authentication with a directory server.  Subsequent posts will refine the Spring Roo application.</p>
<p><strong>What is Roo?</strong></p>
<p>It&#8217;s a great rapid prototyping tool because prototypes don&#8217;t need to be scrapped to proceed with fleshing out the application if a prototype proves itself.</p>
<p>Roo gives you Spring best practices, Rails-like scaffolding, an interactive shell, no additional run-time dependencies, and a big productivity boost while not locking you into yet another framework.  You can re-use your existing Spring/JPA/Hibernate knowledge, while getting the productivity gains from Roo.</p>
<p><strong>Setting up Roo</strong></p>
<ul>
<li>wget http://s3.amazonaws.com/dist.springframework.org/milestone/ROO/spring-roo-1.0.0.RC3.zip</li>
<li>unzip spring-roo-1.0.0.RC3.zip</li>
<li>sudo ln -s ~/Frameworks/spring-roo-1.0.0.RC3/bin/roo.sh /usr/bin/roo</li>
<li>mkdir ~/Workspaces/intranetlinks; cd ~/Workspaces/intranetlinks</li>
</ul>
<p><strong>Starting our Project</strong></p>
<p>Once in your new project directory, type &#8216;roo&#8217;.  Then once in the Roo shell, execute these commands.  See <a href="http://blog.springsource.com/2009/05/27/roo-part-2/">this guide</a> for an explanation of what these commands do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">project <span style="color: #660033;">--topLevelPackage</span> com.sourceallies.links
persistence setup <span style="color: #660033;">--provider</span> HIBERNATE <span style="color: #660033;">--database</span> MYSQL
database properties <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">--key</span> database.password <span style="color: #660033;">--value</span> password
database properties <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">--key</span> database.username <span style="color: #660033;">--value</span> username
database properties <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">--key</span> database.url <span style="color: #660033;">--value</span> jdbc:mysql:<span style="color: #000000; font-weight: bold;">//</span>localhost:<span style="color: #000000;">3306</span><span style="color: #000000; font-weight: bold;">/</span>intranetlinks
&nbsp;
entity <span style="color: #660033;">--name</span> ~.domain.LinkCategory
field string name <span style="color: #660033;">--notNull</span> <span style="color: #660033;">--sizeMin</span> <span style="color: #000000;">1</span> <span style="color: #660033;">--sizeMax</span> <span style="color: #000000;">255</span>
&nbsp;
entity <span style="color: #660033;">--name</span> ~.domain.Link
field string name <span style="color: #660033;">--notNull</span> <span style="color: #660033;">--sizeMin</span> <span style="color: #000000;">1</span> <span style="color: #660033;">--sizeMax</span> <span style="color: #000000;">60</span>
field string url <span style="color: #660033;">--notNull</span> <span style="color: #660033;">--sizeMin</span> <span style="color: #000000;">1</span> <span style="color: #660033;">--sizeMax</span> <span style="color: #000000;">255</span>
field string ldapSecurityGroup <span style="color: #660033;">--notNull</span> <span style="color: #660033;">--sizeMin</span> <span style="color: #000000;">1</span> <span style="color: #660033;">--sizeMax</span> <span style="color: #000000;">60</span>
field reference <span style="color: #660033;">--class</span> ~.domain.Link <span style="color: #660033;">--fieldName</span> category <span style="color: #660033;">--type</span> ~.domain.LinkCategory
&nbsp;
logging setup <span style="color: #660033;">--level</span> DEBUG
&nbsp;
controller scaffold <span style="color: #660033;">--name</span> ~.web.LinkCategoryController <span style="color: #660033;">--entity</span> ~.domain.LinkCategory
controller scaffold <span style="color: #660033;">--name</span> ~.web.LinkController <span style="color: #660033;">--entity</span> ~.domain.Link
&nbsp;
finder list <span style="color: #660033;">--class</span> com.sourceallies.links.domain.Link
finder add <span style="color: #660033;">--finderName</span> findLinksByCategory <span style="color: #660033;">--class</span> ~.domain.Link
&nbsp;
security setup
<span style="color: #7a0874; font-weight: bold;">test</span> integration
perform <span style="color: #7a0874; font-weight: bold;">test</span>
perform eclipse</pre></div></div>

<p>Then of course, create your local database inside the MySQL shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">create database intranetlinks;
create user <span style="color: #ff0000;">'username'</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #ff0000;">'localhost'</span> IDENTIFIED BY <span style="color: #ff0000;">'password'</span>;
grant all privileges on intranetlinks.<span style="color: #000000; font-weight: bold;">*</span> to <span style="color: #ff0000;">'username'</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #ff0000;">'localhost'</span> with grant option;</pre></div></div>

<p>Next, unless you&#8217;re using Roo 1.0.0.RC4 (not available at the time of this blog post), you&#8217;ll need to add the following config to near the bottom of your pom.xml (<a href="https://jira.springsource.org/browse/ROO-224">to fix this bug</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jaxb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jdk<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jdk<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.xml.bind<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jaxb-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.sun.xml.bind<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jaxb-impl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.1.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Then pull the JAXB JAR into your build by executing this maven command (outside of the Roo shell):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn package clean</pre></div></div>

<p>Finally, <a href="http://blogs.sourceallies.com/2009/10/spring-ldap-group-authorization-tip/">per a prior blog</a>, replace the body of your src/main/resources/META-INF/spring/applicationContext-security.xml with this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;http<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form-login</span> <span style="color: #000066;">login-processing-url</span>=<span style="color: #ff0000;">&quot;/static/j_spring_security_check&quot;</span> <span style="color: #000066;">login-page</span>=<span style="color: #ff0000;">&quot;/login&quot;</span> <span style="color: #000066;">authentication-failure-url</span>=<span style="color: #ff0000;">&quot;/login?login_error=t&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logout</span> <span style="color: #000066;">logout-url</span>=<span style="color: #ff0000;">&quot;/static/j_spring_security_logout&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/admin/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_ADMIN&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/member/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;IS_AUTHENTICATED_REMEMBERED&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/resources/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;IS_AUTHENTICATED_ANONYMOUSLY&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/static/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;IS_AUTHENTICATED_ANONYMOUSLY&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/images/**&quot;</span> <span style="color: #000066;">filters</span>=<span style="color: #ff0000;">&quot;none&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/styles/**&quot;</span> <span style="color: #000066;">filters</span>=<span style="color: #ff0000;">&quot;none&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/link/form&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_INTRANETLINKS-ADMINS&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #808080; font-style: italic;">&lt;!-- We're doing REST, only allow GETs to normal users --&gt;</span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/link/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_INTRANETLINKS-ADMINS&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;DELETE&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/link/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_INTRANETLINKS-ADMINS&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;POST&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/link/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_INTRANETLINKS-ADMINS&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;PUT&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/link/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;IS_AUTHENTICATED_REMEMBERED&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/login/**&quot;</span> <span style="color: #000066;">filters</span>=<span style="color: #ff0000;">&quot;none&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intercept-url</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;/**&quot;</span> <span style="color: #000066;">access</span>=<span style="color: #ff0000;">&quot;ROLE_USERS&quot;</span>  <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;anonymous</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/http<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ldap-server</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ldapServer&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;ldap://yourdirectoryserver:338899/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;authentication-manager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ldap-authentication-provider</span> <span style="color: #000066;">server-ref</span>=<span style="color: #ff0000;">&quot;ldapServer&quot;</span>  </span>
<span style="color: #009900;">       <span style="color: #000066;">user-search-base</span>=<span style="color: #ff0000;">&quot;ou=people,dc=sourceallies,dc=com&quot;</span> </span>
<span style="color: #009900;">       <span style="color: #000066;">user-search-filter</span>=<span style="color: #ff0000;">&quot;(uid={0})&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">group-role-attribute</span>=<span style="color: #ff0000;">&quot;cn&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">group-search-base</span>=<span style="color: #ff0000;">&quot;ou=groups,dc=sourceallies,dc=com&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">group-search-filter</span>=<span style="color: #ff0000;">&quot;(memberUid={1})&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">role-prefix</span>=<span style="color: #ff0000;">&quot;ROLE_&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/authentication-manager<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Note that in Spring Security 3.0, Authentication Providers must now be declared from within the authentication-manager element (<a href="http://static.springsource.org/spring-security/site/docs/3.0.x/reference/appendix-namespace.html">more information here</a>).</p>
<p>Then add a few more dependencies to your pom.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.security<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.security.ldap<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.0.0.RC1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.ldap<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>spring-ldap-core<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.3.0.RELEASE<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.springframework.ldap<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>spring-ldap-core-tiger<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.3.0.RELEASE<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This will allow you to use Spring LDAP and also conditionally render pieces of your application like this:</p>

<div class="wp_syntax"><div class="code"><pre class="jsp" style="font-family:monospace;">&lt;security:authorize ifAllGranted=&quot;ROLE_SUPERVISOR&quot;&gt;
    &lt;li id=&quot;finder_findlinksbycategory_menu_item&quot;&gt;
        &lt;c:url value=&quot;/link/find/ByCategory/form&quot; var=&quot;finder_findlinksbycategory_menu_item_url&quot;/&gt;
        &lt;a href=&quot;${finder_findlinksbycategory_menu_item_url}&quot;&gt;
            &lt;spring:message arguments=&quot;Category&quot; code=&quot;global.menu.find&quot;/&gt;
        &lt;/a&gt;
    &lt;/li&gt;
&lt;/security:authorize&gt;</pre></div></div>

<p>Finally, run the following command to startup Tomcat and start refining your UI.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn tomcat:run</pre></div></div>

<p>Stay tuned for Part 2 of this series!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2009/12/spring-roo-sample-app-tutorial-part-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Spring LDAP Group Authorization Tip</title>
		<link>http://blogs.sourceallies.com/2009/10/spring-ldap-group-authorization-tip/</link>
		<comments>http://blogs.sourceallies.com/2009/10/spring-ldap-group-authorization-tip/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 01:51:30 +0000</pubDate>
		<dc:creator>Matt Vincent</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Granted Authorities]]></category>
		<category><![CDATA[Group Authorization]]></category>
		<category><![CDATA[Spring LDAP]]></category>
		<category><![CDATA[Spring Security]]></category>

		<guid isPermaLink="false">http://blogs.sourceallies.com/?p=271</guid>
		<description><![CDATA[The folks at Spring have made it extremely easy to allow your application authenticate and authorize users with Spring LDAP.  This blog entry explains how to check your directory structure and use some sparsely documented Spring LDAP parameters ({0} and {1}) to get everything working. 
In your Spring Security configuration, pointing to your directory [...]]]></description>
			<content:encoded><![CDATA[<p>The folks at Spring have made it extremely easy to allow your application authenticate and authorize users with <a href="http://www.springsource.org/ldap">Spring LDAP</a>.  This blog entry explains how to check your directory structure and use some sparsely documented Spring LDAP parameters ({0} and {1}) to get everything working. </p>
<p>In your <a href="http://static.springsource.org/spring-security/site/">Spring Security</a> configuration, pointing to your directory is straight forward:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ldap-server</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ldapServer&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;ldap://dir.yourdomain.com:389/&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>But in configuring the ldap-authentication-provider, you need to know a few things about your directory of course!  We recommend using <a href="http://directory.apache.org/studio/">Apache Directory Studio</a> to browse your directory &#8211; it&#8217;s a fantastic application.</p>
<p>If you&#8217;re more of a command-line person, just use <a href="http://docs.sun.com/source/816-6400-10/lsearch.html">ldapsearch</a> (example below):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ldapsearch <span style="color: #660033;">-H</span> ldap:<span style="color: #000000; font-weight: bold;">//</span>dir.yourdomain.com:<span style="color: #000000;">389</span> <span style="color: #660033;">-ZZ</span> <span style="color: #660033;">-x</span> 
<span style="color: #660033;">-D</span> <span style="color: #ff0000;">&quot;cn=AdminUser,dc=yourdomain,dc=com&quot;</span> <span style="color: #660033;">-W</span> <span style="color: #660033;">-b</span> <span style="color: #ff0000;">&quot;cn=users,ou=groups,dc=yourdomain,dc=com&quot;</span> 
<span style="color: #660033;">-s</span> base <span style="color: #660033;">-a</span> always <span style="color: #ff0000;">&quot;(objectClass=*)&quot;</span> <span style="color: #ff0000;">&quot;*&quot;</span></pre></div></div>

<p>Once connected to your directory, you&#8217;ll need to figure out how your groups are configured.  Specifically, you&#8217;ll want to know if your configuration looks like </p>
<p>Example A:</p>
<ul>
<li> dc=yourdomain,dc=com</li>
<ul>
<li>ou=groups</li>
<ul>
<li>cn=users</li>
<ul>
<li><strong>memberUid=USERNAME</strong></li>
</ul>
</ul>
</ul>
</ul>
<p>or Example B:</p>
<ul>
<li> dc=yourdomain,dc=com</li>
<ul>
<li>ou=groups</li>
<ul>
<li>cn=users</li>
<ul>
<li> <strong>memberUid=uid= USERNAME,ou=people,dc= yourdomain,dc=com</strong></li>
</ul>
</ul>
</ul>
</ul>
<p>If it&#8217;s like Example A, you&#8217;ll want your config like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ldap-authentication-provider</span> <span style="color: #000066;">server-ref</span>=<span style="color: #ff0000;">&quot;ldapServer&quot;</span>  </span>
<span style="color: #009900;">	<span style="color: #000066;">user-search-base</span>=<span style="color: #ff0000;">&quot;ou=people,dc=yourdomain,dc=com&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">user-search-filter</span>=<span style="color: #ff0000;">&quot;(uid={0})&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-role-attribute</span>=<span style="color: #ff0000;">&quot;cn&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-search-base</span>=<span style="color: #ff0000;">&quot;ou=groups,dc=yourdomain,dc=com&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-search-filter</span>=<span style="color: #ff0000;">&quot;(memberUid={1})&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">role-prefix</span>=<span style="color: #ff0000;">&quot;ROLE_&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>otherwise, you&#8217;ll want this config:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ldap-authentication-provider</span> <span style="color: #000066;">server-ref</span>=<span style="color: #ff0000;">&quot;ldapServer&quot;</span>  </span>
<span style="color: #009900;">	<span style="color: #000066;">user-search-base</span>=<span style="color: #ff0000;">&quot;ou=people,dc=yourdomain,dc=com&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">user-search-filter</span>=<span style="color: #ff0000;">&quot;(uid={0})&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-role-attribute</span>=<span style="color: #ff0000;">&quot;cn&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-search-base</span>=<span style="color: #ff0000;">&quot;ou=groups,dc=yourdomain,dc=com&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">group-search-filter</span>=<span style="color: #ff0000;">&quot;(memberUid={0})&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">role-prefix</span>=<span style="color: #ff0000;">&quot;ROLE_&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Note the difference in the <em>group-search-filter</em>:</p>
<ul>
<li><strong>{0}</strong> contains the username with the entire ldap base. </li>
<li><strong>{1}</strong> only contains username. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.sourceallies.com/2009/10/spring-ldap-group-authorization-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

