directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r909081 - in /websites/staging/directory/trunk/content: ./ api/user-guide/2.10-ldap-connection-template.html
Date Sat, 17 May 2014 12:50:03 GMT
Author: buildbot
Date: Sat May 17 12:50:03 2014
New Revision: 909081

Log:
Staging update by buildbot for directory

Modified:
    websites/staging/directory/trunk/content/   (props changed)
    websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html

Propchange: websites/staging/directory/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat May 17 12:50:03 2014
@@ -1 +1 @@
-1595462
+1595466

Modified: websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
==============================================================================
--- websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
(original)
+++ websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
Sat May 17 12:50:03 2014
@@ -156,9 +156,9 @@
 <h1 id="210-why-use-the-ldapconnectiontemplate">2.10 - Why use the LdapConnectionTemplate</h1>
 <p>The LdapConnectionTemplate provides simplified access to the API functions.  It
does so by</p>
 <ul>
-<li>[Managing Connections]</li>
-<li>[Providing Factory Methods For Model Objects]</li>
-<li>Providing CRUD Methods</li>
+<li><a href="#managing-connections">Managing Connections</a></li>
+<li><a href="#providing-factory-methods-for-model-objects">Providing Factory
Methods For Model Objects</a></li>
+<li><a href="#providing-crud-methods">Providing CRUD Methods</a></li>
 <li>Handling Search Result Iteration</li>
 <li>Providing Simplified, Password Policy Aware, Authentication/Password Modification
Methods</li>
 </ul>
@@ -201,59 +201,12 @@
 <p>The connection template implements an interface called ModelFactory.  Any implementation
of this factory can be injected into the template once it is constructed.  By default, it
uses ModelFactoryImpl which in turn constructs the standard Apache LDAP API model objects.
 This abstractions frees you from having to be concerned with implementation details while
still giving you the power to override the default behavior as you see fit.</p>
 <div class="codehilite"><pre><span class="n">ModelFactory</span>
<span class="n">modelFactory</span> <span class="o">=</span> <span
class="k">new</span> <span class="n">MyCustomModelFactory</span><span
class="o">();</span>
 <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">setModelFactory</span><span class="o">(</span> <span class="n">modelFactory</span>
<span class="o">);</span>
-
-
-
-<span class="o">:::</span><span class="n">Java</span>
-<span class="n">LdapConnection</span> <span class="n">connection</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">LdapNetworkConnection</span><span
class="o">(</span> <span class="s">&quot;localhost&quot;</span><span
class="o">,</span> <span class="mi">389</span> <span class="o">);</span>
-</pre></div>
-
-
-<p>Here, we just created an unsafe connection locally, using the 389 port. Quite simple...</p>
-<h3 id="secure-connection">Secure connection</h3>
-<p>Although the <strong>LDAPS</strong> (<strong>LDAP</strong>
over <strong>SSL</strong>) is now considered as deprecated, many people continue
to use it. The big advantage of not using <strong>LDAPS</strong> is that you don't
need to setup two different listening ports (one for <strong>LDAP</strong> -389-
and another one for <strong>LDAPS</strong> -636- ).</p>
-<p>The only difference with the previous example is that we have to tell the connection
that it has to use <strong>SSL</strong>, by passing <strong><em>true</em></strong>
as a third parameter (incidentally, passing <strong><em>false</em></strong>
set a unsafe connection).</p>
-<p>Here is an example</p>
-<div class="codehilite"><pre><span class="n">LdapConnection</span>
<span class="n">connection</span> <span class="o">=</span> <span
class="k">new</span> <span class="n">LdapNetworkConnection</span><span
class="o">(</span> <span class="s">&quot;localhost&quot;</span><span
class="o">,</span> <span class="mi">636</span><span class="o">,</span>
<span class="kc">true</span> <span class="o">);</span>
-</pre></div>
-
-
-<h2 id="maintaining-the-connection-opened">Maintaining the connection opened</h2>
-<p>We keep the connection opened for a limited period of time, defaulting to 30 seconds.
This might be not long enough, so one can change this delay by calling the <em>setTimeOut()</em>
method :</p>
-<div class="codehilite"><pre><span class="n">LdapConnection</span>
<span class="n">connection</span> <span class="o">=</span> <span
class="k">new</span> <span class="n">LdapNetworkConnection</span><span
class="o">(</span> <span class="s">&quot;localhost&quot;</span><span
class="o">,</span> <span class="mi">389</span> <span class="o">);</span>
-<span class="n">connection</span><span class="o">.</span><span
class="na">setTimeOut</span><span class="o">(</span> <span class="mi">0</span>
<span class="o">);</span>
-<span class="o">...</span>
-<span class="n">connection</span><span class="o">.</span><span
class="na">close</span><span class="o">();</span>
-</pre></div>
-
-
-<blockquote>
-<p><strong>Note:</strong> Setting a value equal or below 0 will keep the
connection opened for ever (or a soon as the connection is not explicitly closed).</p>
-</blockquote>
-<h2 id="closing-the-connection">Closing the connection</h2>
-<p>Once you don't need to use the connection anymore (remember that hodling a connection
keeps a session opened on the server, and a socket opened between the client and the server),
then you have to close it. This is done by calling the <em>close()</em> method
:</p>
-<div class="codehilite"><pre><span class="n">LdapConnection</span>
<span class="n">connection</span> <span class="o">=</span> <span
class="k">new</span> <span class="n">LdapNetworkConnection</span><span
class="o">(</span> <span class="s">&quot;localhost&quot;</span><span
class="o">,</span> <span class="mi">389</span> <span class="o">);</span>
-<span class="o">...</span>
-<span class="n">connection</span><span class="o">.</span><span
class="na">close</span><span class="o">();</span>
-</pre></div>
-
-
-<h2 id="using-a-pool-of-connections">Using a pool of connections</h2>
-<p>Creating a connection is expensive. If you are to reuse a connection over and over,
or if you are writing an application that will need many LDAP conenctions, you may want to
use a pool of connections.</p>
-<p>This is slightly more complex than simply opening a new connection, as you have
a lot of parametrs that can come into play when creating a pool.
-Here is an example of creation of a pool of connections :</p>
-<div class="codehilite"><pre><span class="n">LdapConnectionConfig</span>
<span class="n">config</span> <span class="o">=</span> <span class="k">new</span>
<span class="n">LdapConnectionConfig</span><span class="o">();</span>
-<span class="n">config</span><span class="o">.</span><span class="na">setLdapHost</span><span
class="o">(</span> <span class="s">&quot;localhost&quot;</span>
<span class="o">);</span>
-<span class="n">config</span><span class="o">.</span><span class="na">setLdapPort</span><span
class="o">(</span> <span class="mi">389</span> <span class="o">);</span>
-<span class="n">config</span><span class="o">.</span><span class="na">setName</span><span
class="o">(</span> <span class="s">&quot;uid=admin,ou=system&quot;</span>
<span class="o">);</span>
-<span class="n">config</span><span class="o">.</span><span class="na">setCredentials</span><span
class="o">(</span> <span class="s">&quot;secret&quot;</span>
<span class="o">);</span>
-<span class="n">PoolableLdapConnectionFactory</span> <span class="n">factory</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">PoolableLdapConnectionFactory</span><span
class="o">(</span> <span class="n">config</span> <span class="o">);</span>
-<span class="n">LdapConnectionPool</span> <span class="n">pool</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">LdapConnectionPool</span><span
class="o">(</span> <span class="n">factory</span> <span class="o">);</span>
-<span class="n">pool</span><span class="o">.</span><span class="na">setTestOnBorrow</span><span
class="o">(</span> <span class="kc">true</span> <span class="o">);</span>
 </pre></div>
 
 
-<p>Here, we just have created a pool of connections which all are unthenticated using
the administrator user. You can create anonymous connections, it's just a matter of not setting
any name or credentials in the config.</p>
+<h2 id="providing-crud-methods">Providing CRUD Methods</h2>
+<h2 id="handling-search-result-iteration">Handling Search Result Iteration</h2>
+<h2 id="providing-simplified-password-policy-aware-authenticationpassword-modification-methods">Providing
Simplified, Password Policy Aware, Authentication/Password Modification Methods</h2>
 
 
     <div class="nav">



Mime
View raw message