directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1581983 - in /directory/apacheds/trunk: installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/ protocol-ldap/src/main/java/org/apac...
Date Wed, 26 Mar 2014 18:20:07 GMT
Author: elecharny
Date: Wed Mar 26 18:20:06 2014
New Revision: 1581983

URL: http://svn.apache.org/r1581983
Log:
o Added the support for the WhoAmI extended operation in the server
o Removed a useless method in PwdModifyHandler and BindRequestHandler


Added:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/WhoAmIHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/WhoAmIIT.java
Modified:
    directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java
    directory/apacheds/trunk/server-config/src/main/resources/config.ldif

Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf?rev=1581983&r1=1581982&r2=1581983&view=diff
==============================================================================
--- directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
(original)
+++ directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
Wed Mar 26 18:20:06 2014
@@ -36,7 +36,7 @@ wrapper.java.additional.3=-Dapacheds.log
 wrapper.java.additional.4=-Dapacheds.run.dir=${double.quote}%INSTANCE_DIRECTORY%/run${double.quote}
 wrapper.java.additional.5=-Dapacheds.instance=${double.quote}%INSTANCE%${double.quote}
 wrapper.java.additional.6=-Dapacheds.controls=${double.quote}org.apache.directory.api.ldap.codec.controls.cascade.CascadeFactory,org.apache.directory.api.ldap.codec.controls.manageDsaIT.ManageDsaITFactory,org.apache.directory.api.ldap.codec.controls.search.entryChange.EntryChangeFactory,org.apache.directory.api.ldap.codec.controls.search.pagedSearch.PagedResultsFactory,org.apache.directory.api.ldap.codec.controls.search.persistentSearch.PersistentSearchFactory,org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory,org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory,org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory${double.quote}
-wrapper.java.additional.8=-Dapacheds.extendedOperations=${double.quote}org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory${double.quote}
+wrapper.java.additional.8=-Dapacheds.extendedOperations=${double.quote}org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulShutdown.GracefulShutdownFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory,org.apache.directory.api.ldap.extras.extended.ads_impl.whoAmI.WhoAmIFactory${double.quote}
 
 # Initial Java Heap Size (in MB)
 #wrapper.java.initmemory=384

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java?rev=1581983&r1=1581982&r2=1581983&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/PwdModifyHandler.java
Wed Mar 26 18:20:06 2014
@@ -329,16 +329,6 @@ public class PwdModifyHandler implements
     /**
      * {@inheritDoc}
      */
-    public static PasswordModifyResponse getPwdModifyResponse()
-    {
-        // build the PwdModifyResponse message with replicationContexts
-        return new PasswordModifyResponseImpl();
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public Set<String> getExtensionOids()
     {
         return EXTENSION_OIDS;

Added: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/WhoAmIHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/WhoAmIHandler.java?rev=1581983&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/WhoAmIHandler.java
(added)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/WhoAmIHandler.java
Wed Mar 26 18:20:06 2014
@@ -0,0 +1,102 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.server.ldap.handlers.extended;
+
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIRequest;
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIResponse;
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIResponseImpl;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.server.core.api.LdapPrincipal;
+import org.apache.directory.server.ldap.ExtendedOperationHandler;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.server.ldap.LdapSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * An handler to manage the WhoAmI extended request operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class WhoAmIHandler implements ExtendedOperationHandler<WhoAmIRequest, WhoAmIResponse>
+{
+    private static final Logger LOG = LoggerFactory.getLogger( WhoAmIHandler.class );
+    public static final Set<String> EXTENSION_OIDS;
+
+    static
+    {
+        Set<String> set = new HashSet<String>( 2 );
+        set.add( WhoAmIRequest.EXTENSION_OID );
+        set.add( WhoAmIResponse.EXTENSION_OID );
+        EXTENSION_OIDS = Collections.unmodifiableSet( set );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return WhoAmIRequest.EXTENSION_OID;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void handleExtendedOperation( LdapSession requestor, WhoAmIRequest req ) throws
Exception
+    {
+        LOG.debug( "WhoAmI requested" );
+
+        LdapPrincipal ldapPrincipal = requestor.getCoreSession().getAuthenticatedPrincipal();
+        
+        WhoAmIResponse whoAmIResponse = new WhoAmIResponseImpl( req.getMessageId(), ResultCodeEnum.SUCCESS
);
+
+        String authzId = "dn:" + ldapPrincipal.getDn();
+        whoAmIResponse.setAuthzId( Strings.getBytesUtf8( authzId ) );
+        
+        // write the response
+        requestor.getIoSession().write( whoAmIResponse );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Set<String> getExtensionOids()
+    {
+        return EXTENSION_OIDS;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setLdapServer( LdapServer ldapServer )
+    {
+    }
+}

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java?rev=1581983&r1=1581982&r2=1581983&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java
Wed Mar 26 18:20:06 2014
@@ -90,7 +90,6 @@ public class BindRequestHandler extends 
      * @throws Exception If the authentication cannot be done
      */
     // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
     public void handleSimpleAuth( LdapSession ldapSession, BindRequest bindRequest ) throws
Exception
     {
         DirectoryService directoryService = ldapServer.getDirectoryService();

Modified: directory/apacheds/trunk/server-config/src/main/resources/config.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/resources/config.ldif?rev=1581983&r1=1581982&r2=1581983&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/resources/config.ldif (original)
+++ directory/apacheds/trunk/server-config/src/main/resources/config.ldif Wed Mar 26 18:20:06
2014
@@ -739,6 +739,14 @@ objectclass: ads-base
 objectclass: top
 ads-enabled: TRUE
 
+dn: ads-extendedOpId=whoAmIHandler,ou=extendedOpHandlers,ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
+ads-extendedOpId: whoAmIHandler
+ads-extendedOpHandlerclass: org.apache.directory.server.ldap.handlers.extended.WhoAmIHandler
+objectclass: ads-extendedOpHandler
+objectclass: ads-base
+objectclass: top
+ads-enabled: TRUE
+
 dn: ou=saslMechHandlers,ads-serverId=ldapServer,ou=servers,ads-directoryServiceId=default,ou=config
 ou: saslMechHandlers
 objectclass: organizationalUnit

Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/WhoAmIIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/WhoAmIIT.java?rev=1581983&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/WhoAmIIT.java
(added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/WhoAmIIT.java
Wed Mar 26 18:20:06 2014
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ * 
+ */
+package org.apache.directory.server.operations.extended;
+
+
+import static org.apache.directory.server.core.integ.IntegrationUtils.getAdminNetworkConnection;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIRequest;
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIRequestImpl;
+import org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIResponse;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.hash.Sha512PasswordHashingInterceptor;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.ldap.handlers.extended.WhoAmIHandler;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the RbacCreateSession extended operation
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+    transports =
+        { @CreateTransport(protocol = "LDAP") },
+    extendedOpHandlers =
+        { WhoAmIHandler.class },
+    allowAnonymousAccess = true)
+//disable changelog, for more info see DIRSERVER-1528
+@CreateDS(enableChangeLog = false, name = "RbacCreateSessionTest", additionalInterceptors
=
+    { Sha512PasswordHashingInterceptor.class })
+public class WhoAmIIT extends AbstractLdapTestUnit
+{
+    /**
+     * Test that the WhoAmI extended operation is handled correctly
+     */
+    @Test
+    public void testRbacCreateSessionExtendedOperation() throws Exception
+    {
+        LdapConnection adminConnection = getAdminNetworkConnection( getLdapServer() );
+
+        adminConnection.setTimeOut( 0L );
+
+        // Create a new RBAC session
+        WhoAmIRequest whoAmIRequest = new WhoAmIRequestImpl();
+
+        // Send the request
+        WhoAmIResponse whoAmIResponse = ( WhoAmIResponse ) adminConnection.extended( whoAmIRequest
);
+
+        assertEquals( ResultCodeEnum.SUCCESS, whoAmIResponse.getLdapResult().getResultCode()
);
+        assertTrue( whoAmIResponse.isDnAuthzId() );
+        assertEquals( "uid=admin,ou=system", whoAmIResponse.getDn().toString() );
+        adminConnection.close();
+    }
+}



Mime
View raw message