Skip to content
Permalink
Browse files
o Update artifact name and urls
o Update to ApacheDS 1.5.5 and Jetty 6.1.21
o Set archetype version to 1.5.5-SNAPSHOT to indicate that is works with ApacheDS 1.5.5 only



git-svn-id: https://svn.apache.org/repos/asf/directory/samples/trunk@835609 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
seelmann committed Nov 12, 2009
1 parent e9f7d88 commit 9ebfa712528b66942e91513f612d4d883cba6083
Showing 8 changed files with 123 additions and 228 deletions.
@@ -25,12 +25,12 @@
<archetypes>
<archetype>
<groupId>org.apache.directory.samples</groupId>
<artifactId>apacheds-webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<artifactId>apacheds-archetype-webapp</artifactId>
<version>1.5.5-SNAPSHOT</version>
<!-- FIX ME after the first release
<version>RELEASE</version>
-->
<description>Creates ApacheDS as an embedded Web Application</description>
</archetype>
</archetypes>
</archetype-catalog>
</archetype-catalog>
@@ -28,10 +28,11 @@ under the License.
</parent>

<groupId>org.apache.directory.samples</groupId>
<artifactId>apacheds-webapp</artifactId>
<artifactId>apacheds-archetype-webapp</artifactId>
<packaging>maven-archetype</packaging>
<name>Archetype to embed ApacheDS as a Web Application</name>
<version>1.0-SNAPSHOT</version>
<name>ApacheDS Archetype Web Application</name>
<description>Archetype to embed ApacheDS as a Web Application</description>
<version>1.5.5-SNAPSHOT</version>

<prerequisites>
<maven>2.0.9</maven>
@@ -45,9 +46,9 @@ under the License.
</issueManagement>

<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/directory/samples/trunk/apacheds-webapp/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/samples/trunk/apacheds-webapp/</developerConnection>
<url>https://svn.apache.org/repos/asf/directory/samples/trunk/apacheds-webapp/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/directory/samples/trunk/apacheds-archetype-webapp/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/directory/samples/trunk/apacheds-archetype-webapp/</developerConnection>
<url>https://svn.apache.org/viewvc/directory/samples/trunk/apacheds-archetype-webapp/</url>
</scm>

<distributionManagement>
@@ -58,7 +59,7 @@ under the License.
</distributionManagement>

<properties>
<distMgmtSiteUrl>scpexe://people.apache.org/www/directory.apache.org/samples/apacheds-webapp/gen-docs/${version}/</distMgmtSiteUrl>
<distMgmtSiteUrl>scpexe://people.apache.org/www/directory.apache.org/samples/apacheds-archetype-webapp/gen-docs/${version}/</distMgmtSiteUrl>
<skin.version>1.0.0</skin.version>
</properties>

@@ -67,13 +68,13 @@ under the License.
<extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.0-alpha-3</version>
<version>2.0-alpha-4</version>
</extension>
</extensions>
<plugins>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.0-alpha-3</version>
<version>2.0-alpha-4</version>
<extensions>true</extensions>
</plugin>
</plugins>
@@ -17,7 +17,7 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<archetype-descriptor name="apacheds-webapp">
<archetype-descriptor name="apacheds-archetype-webapp">
<requiredProperties>
<requiredProperty key="groupId">
<defaultValue>org.example</defaultValue>
@@ -18,7 +18,7 @@ specific language governing permissions and limitations
under the License.
-->
<archetype>
<id>apacheds-webapp</id>
<id>apacheds-archetype-webapp</id>
<sources>
<source>src/main/java/RootDseServlet.java</source>
<source>src/main/java/StartStopListener.java</source>
@@ -47,7 +47,7 @@ under the License.
<plugin>
<artifactId>maven-jetty-plugin</artifactId>
<groupId>org.mortbay.jetty</groupId>
<version>6.1.10</version>
<version>6.1.21</version>
<configuration>
<contextPath>/ApacheDS</contextPath>
<connectors>
@@ -61,155 +61,15 @@ under the License.
</build>

<dependencies>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-bootstrap-extract</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-bootstrap-partition</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-avl</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-cursor</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-entry</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-jndi</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-shared</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-jdbm</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-jdbm-store</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-protocol-ldap</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-protocol-shared</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-schema-bootstrap</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-schema-registries</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-utils</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-xdbm-base</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-xdbm-search</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-filter-ssl</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-asn1</artifactId>
<version>0.9.12</version>
</dependency>
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-asn1-codec</artifactId>
<version>0.9.12</version>
</dependency>
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-bouncycastle-reduced</artifactId>
<version>0.9.12</version>
</dependency>
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-ldap</artifactId>
<version>0.9.12</version>
</dependency>
<dependency>
<groupId>org.apache.directory.shared</groupId>
<artifactId>shared-ldap-constants</artifactId>
<version>0.9.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.2</version>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<version>1.5.6</version>
</dependency>
<dependency>
<artifactId>servlet-api</artifactId>
@@ -19,6 +19,7 @@
*/
package ${package};


import java.io.PrintWriter;
import java.util.Hashtable;

@@ -39,73 +40,81 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.jndi.CoreContextFactory;


/**
* A servlet which displays the Root DSE of the embedded server.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory
* Project</a>
*/
public class RootDseServlet extends HttpServlet {
public class RootDseServlet extends HttpServlet
{

private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException {

try {
resp.setContentType("text/plain");
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException
{
try
{
resp.setContentType( "text/plain" );
PrintWriter out = resp.getWriter();

out.println("*** ApacheDS RootDSE ***\n");
out.println( "*** ApacheDS RootDSE ***\n" );

DirContext ctx = new InitialDirContext(this.createEnv());
DirContext ctx = new InitialDirContext( this.createEnv() );

SearchControls ctls = new SearchControls();
ctls.setReturningAttributes(new String[] { "*", "+" });
ctls.setSearchScope(SearchControls.OBJECT_SCOPE);
ctls.setReturningAttributes( new String[]
{ "*", "+" } );
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );

NamingEnumeration<SearchResult> result = ctx.search("",
"(objectClass=*)", ctls);
if (result.hasMore()) {
NamingEnumeration<SearchResult> result = ctx.search( "", "(objectClass=*)", ctls );
if ( result.hasMore() )
{
SearchResult entry = result.next();
Attributes as = entry.getAttributes();

NamingEnumeration<String> ids = as.getIDs();
while (ids.hasMore()) {
while ( ids.hasMore() )
{
String id = ids.next();
Attribute attr = as.get(id);
for (int i = 0; i < attr.size(); ++i) {
out.println(id + ": " + attr.get(i));
Attribute attr = as.get( id );
for ( int i = 0; i < attr.size(); ++i )
{
out.println( id + ": " + attr.get( i ) );
}
}
}
ctx.close();

out.flush();
} catch (Exception e) {
throw new ServletException(e);
}
catch ( Exception e )
{
throw new ServletException( e );
}
}


/**
* Creates an environment configuration for JNDI access.
*/
protected Hashtable<Object, Object> createEnv() {

protected Hashtable<Object, Object> createEnv()
{
// Fetch directory service from servlet context
ServletContext servletContext = this.getServletContext();
DirectoryService directoryService = (DirectoryService) servletContext
.getAttribute(DirectoryService.JNDI_KEY);
DirectoryService directoryService = ( DirectoryService ) servletContext
.getAttribute( DirectoryService.JNDI_KEY );

Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(DirectoryService.JNDI_KEY, directoryService);
env.put(Context.PROVIDER_URL, "");
env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class
.getName());

env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put( DirectoryService.JNDI_KEY, directoryService );
env.put( Context.PROVIDER_URL, "" );
env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );

env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.SECURITY_AUTHENTICATION, "simple" );

return env;
}

0 comments on commit 9ebfa71

Please sign in to comment.