directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r519813 - in /directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw: ./ protocol/ service/
Date Mon, 19 Mar 2007 03:22:58 GMT
Author: erodriguez
Date: Sun Mar 18 20:22:58 2007
New Revision: 519813

URL: http://svn.apache.org/viewvc?view=rev&rev=519813
Log:
Clean-up of Change Password protocol configuration.
o  Enhancements to support Spring.
o  Removal of all code related to map-based configuration.
o  Some parameter names standardized with other protocol providers.

Modified:
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java
    directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordConfiguration.java
Sun Mar 18 20:22:58 2007
@@ -21,21 +21,17 @@
 
 
 import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.configuration.ConfigurationException;
 import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
-import org.apache.directory.server.protocol.shared.LoadStrategy;
 import org.apache.directory.server.protocol.shared.ServiceConfiguration;
 
 
 /**
+ * Contains the configuration parameters for the Change Password protocol provider.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -43,303 +39,179 @@
 {
     private static final long serialVersionUID = 3509208713288140629L;
 
-    /** the prop key const for changepw.principal */
-    private static final String PRINCIPAL_KEY = "principal";
+    /** The default change password principal. */
+    private static final String SERVICE_PRINCIPAL_DEFAULT = "kadmin/changepw@EXAMPLE.COM";
 
-    /** the default change password principal */
-    private static final String DEFAULT_PRINCIPAL = "kadmin/changepw@EXAMPLE.COM";
+    /** The default change password base DN. */
+    public static final String SEARCH_BASEDN_DEFAULT = "ou=users,dc=example,dc=com";
 
-    /** the default change password base DN */
-    public static final String CHANGEPW_ENTRY_BASEDN = "ou=users,dc=example,dc=com";
+    /** The default change password realm. */
+    private static final String REALM_DEFAULT = "EXAMPLE.COM";
 
-    /** the prop key const for primary.realm */
-    private static final String REALM_KEY = "realm";
+    /** The default change password port. */
+    private static final int IP_PORT_DEFAULT = 464;
 
-    /** the default change password realm */
-    private static final String DEFAULT_REALM = "EXAMPLE.COM";
-
-    /** the default change password port */
-    private static final String DEFAULT_IP_PORT = "464";
-
-    /** the prop key const for encryption.types */
-    private static final String ENCRYPTION_TYPES_KEY = "encryption.types";
-
-    /** the default encryption types */
-    public static final String[] DEFAULT_ENCRYPTION_TYPES = new String[]
+    /** The default encryption types. */
+    public static final String[] ENCRYPTION_TYPES_DEFAULT = new String[]
         { "des-cbc-md5" };
 
-    /** the prop key const for allowable.clockskew */
-    private static final String ALLOWABLE_CLOCKSKEW_KEY = "allowable.clockskew";
-
-    /** the default changepw buffer size */
+    /** The default changepw buffer size. */
     private static final long DEFAULT_ALLOWABLE_CLOCKSKEW = 5 * MINUTE;
 
-    /** the prop key const for empty.addresses.allowed */
-    private static final String EMPTY_ADDRESSES_ALLOWED_KEY = "empty.addresses.allowed";
-
-    /** the default empty addresses */
+    /** The default empty addresses. */
     private static final boolean DEFAULT_EMPTY_ADDRESSES_ALLOWED = true;
 
-    /** the prop key constants for password policy */
-    public static final String PASSWORD_LENGTH_KEY = "password.length";
-    public static final String CATEGORY_COUNT_KEY = "category.count";
-    public static final String TOKEN_SIZE_KEY = "token.size";
-
-    /** the default change password password policies */
+    /** The default change password password policy for password length. */
     public static final int DEFAULT_PASSWORD_LENGTH = 6;
-    public static final int DEFAULT_CATEGORY_COUNT = 3;
-    public static final int DEFAULT_TOKEN_SIZE = 3;
-
-    private static final String DEFAULT_PID = "org.apache.changepw";
-    private static final String DEFAULT_NAME = "Apache Change Password Service";
-    private static final String DEFAULT_PREFIX = "changepw.";
-
-    private EncryptionType[] encryptionTypes;
-
-
-    /**
-     * Creates a new instance with default settings.
-     */
-    public ChangePasswordConfiguration()
-    {
-        this( getDefaultConfig(), LoadStrategy.LDAP );
-    }
-
-
-    /**
-     * Creates a new instance with default settings that operates on the
-     * {@link DirectoryService} with the specified ID.
-     */
-    public ChangePasswordConfiguration(String instanceId)
-    {
-        this( getDefaultConfig(), LoadStrategy.LDAP );
-        setInstanceId( instanceId );
-    }
-
-
-    public ChangePasswordConfiguration( Map<String, String> properties )
-    {
-        this( properties, LoadStrategy.LDAP );
-    }
-
 
-    public ChangePasswordConfiguration( Map<String, String> properties, int strategy
)
-    {
-        if ( properties == null )
-        {
-            configuration = getDefaultConfig();
-        }
-        else
-        {
-            loadProperties( DEFAULT_PREFIX, properties, strategy );
-        }
-
-        int port = getPort();
-
-        if ( port < 1 || port > 0xFFFF )
-        {
-            throw new ConfigurationException( "Invalid value:  " + IP_PORT_KEY + "=" + port
);
-        }
+    /** The default change password password policy for category count. */
+    public static final int DEFAULT_CATEGORY_COUNT = 3;
 
-        prepareEncryptionTypes();
-    }
+    /** The default change password password policy for token size. */
+    public static final int DEFAULT_TOKEN_SIZE = 3;
 
+    /** The default service PID. */
+    private static final String SERVICE_PID_DEFAULT = "org.apache.changepw";
 
-    public static Map<String, String> getDefaultConfig()
-    {
-        Map<String, String> defaults = new HashMap<String, String>();
+    /** The default service name. */
+    private static final String SERVICE_NAME_DEFAULT = "Apache Change Password Service";
 
-        defaults.put( SERVICE_PID, DEFAULT_PID );
-        defaults.put( IP_PORT_KEY, DEFAULT_IP_PORT );
+    /** The encryption types. */
+    private EncryptionType[] encryptionTypes;
 
-        return defaults;
-    }
+    /** The primare realm. */
+    private String primaryRealm = REALM_DEFAULT;
 
+    /** The service principal. */
+    private String servicePrincipal = SERVICE_PRINCIPAL_DEFAULT;
 
-    public boolean isDifferent( Dictionary config )
-    {
-        int port = getPort();
+    /** The allowable clock skew. */
+    private long allowableClockSkew = DEFAULT_ALLOWABLE_CLOCKSKEW;
 
-        if ( port == Integer.parseInt( ( String ) config.get( IP_PORT_KEY ) ) )
-        {
-            return false;
-        }
+    /** Whether empty addresses are allowed. */
+    private boolean isEmptyAddressesAllowed = DEFAULT_EMPTY_ADDRESSES_ALLOWED;
 
-        return true;
-    }
+    /** The policy for password length. */
+    private int policyPasswordLength;
 
+    /** The policy for category count. */
+    private int policyCategoryCount;
 
-    public String getName()
-    {
-        return DEFAULT_NAME;
-    }
+    /** The policy for token size. */
+    private int policyTokenSize;
 
 
-    public int getPort()
+    /**
+     * Creates a new instance of ChangePasswordConfiguration.
+     */
+    public ChangePasswordConfiguration()
     {
-        String key = IP_PORT_KEY;
+        super.setServiceName( SERVICE_NAME_DEFAULT );
+        super.setIpPort( IP_PORT_DEFAULT );
+        super.setServicePid( SERVICE_PID_DEFAULT );
+        super.setSearchBaseDn( SEARCH_BASEDN_DEFAULT );
 
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return Integer.parseInt( DEFAULT_IP_PORT );
+        prepareEncryptionTypes();
     }
 
 
+    /**
+     * Returns the primary realm.
+     *
+     * @return The primary realm.
+     */
     public String getPrimaryRealm()
     {
-        String key = REALM_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return get( key );
-        }
-
-        return DEFAULT_REALM;
+        return primaryRealm;
     }
 
 
+    /**
+     * Returns the encryption types.
+     *
+     * @return The encryption types.
+     */
     public EncryptionType[] getEncryptionTypes()
     {
         return encryptionTypes;
     }
 
 
-    public Map<String, String> getProperties()
-    {
-        // Request that the krb5key value be returned as binary
-        configuration.put( "java.naming.ldap.attributes.binary", "krb5Key" );
-
-        return configuration;
-    }
-
-
-    public long getClockSkew()
-    {
-        String key = ALLOWABLE_CLOCKSKEW_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return MINUTE * Long.parseLong( get( key ) );
-        }
-
-        return DEFAULT_ALLOWABLE_CLOCKSKEW;
-    }
-
-
-    public int getBufferSize()
-    {
-        String key = BUFFER_SIZE_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return DEFAULT_BUFFER_SIZE;
-    }
-
-
-    public KerberosPrincipal getChangepwPrincipal()
+    /**
+     * Returns the allowable clock skew.
+     *
+     * @return The allowable clock skew.
+     */
+    public long getAllowableClockSkew()
     {
-        String key = PRINCIPAL_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return new KerberosPrincipal( get( key ) );
-        }
-
-        return new KerberosPrincipal( DEFAULT_PRINCIPAL );
+        return allowableClockSkew;
     }
 
 
-    public String getEntryBaseDn()
+    /**
+     * Returns the Change Password service principal.
+     *
+     * @return The Change Password service principal.
+     */
+    public KerberosPrincipal getServicePrincipal()
     {
-        String key = ENTRY_BASEDN_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return get( key );
-        }
-
-        return CHANGEPW_ENTRY_BASEDN;
+        return new KerberosPrincipal( servicePrincipal );
     }
 
 
+    /**
+     * Returns whether empty addresses are allowed.
+     *
+     * @return Whether empty addresses are allowed.
+     */
     public boolean isEmptyAddressesAllowed()
     {
-        String key = EMPTY_ADDRESSES_ALLOWED_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return "true".equalsIgnoreCase( get( key ) );
-        }
-
-        return DEFAULT_EMPTY_ADDRESSES_ALLOWED;
+        return isEmptyAddressesAllowed;
     }
 
 
+    /**
+     * Returns the password length.
+     *
+     * @return The password length.
+     */
     public int getPasswordLengthPolicy()
     {
-        String key = PASSWORD_LENGTH_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return DEFAULT_PASSWORD_LENGTH;
+        return policyPasswordLength;
     }
 
 
+    /**
+     * Returns the category count.
+     *
+     * @return The category count.
+     */
     public int getCategoryCountPolicy()
     {
-        String key = CATEGORY_COUNT_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return DEFAULT_CATEGORY_COUNT;
+        return policyCategoryCount;
     }
 
 
+    /**
+     * Returns the token size.
+     *
+     * @return The token size.
+     */
     public int getTokenSizePolicy()
     {
-        String key = TOKEN_SIZE_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            return Integer.parseInt( get( key ) );
-        }
-
-        return DEFAULT_TOKEN_SIZE;
+        return policyTokenSize;
     }
 
 
     private void prepareEncryptionTypes()
     {
-        String[] encryptionTypeStrings = null;
-
-        String key = ENCRYPTION_TYPES_KEY;
-
-        if ( configuration.containsKey( key ) )
-        {
-            encryptionTypeStrings = ( get( key ) ).split( "\\s" );
-        }
-        else
-        {
-            encryptionTypeStrings = DEFAULT_ENCRYPTION_TYPES;
-        }
+        String[] encryptionTypeStrings = ENCRYPTION_TYPES_DEFAULT;
 
         List<EncryptionType> encTypes = new ArrayList<EncryptionType>();
 
-        for ( String enc:encryptionTypeStrings )
+        for ( String enc : encryptionTypeStrings )
         {
-            for ( EncryptionType type:EncryptionType.VALUES )
+            for ( EncryptionType type : EncryptionType.VALUES )
             {
                 if ( type.toString().equalsIgnoreCase( enc ) )
                 {

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
Sun Mar 18 20:22:58 2007
@@ -59,8 +59,8 @@
         this.acceptor = acceptor;
         this.store = store;
 
-        String name = config.getName();
-        int port = config.getPort();
+        String name = config.getServiceName();
+        int port = config.getIpPort();
 
         try
         {
@@ -85,11 +85,11 @@
 
     public void destroy()
     {
-        acceptor.unbind( new InetSocketAddress( config.getPort() ) );
+        acceptor.unbind( new InetSocketAddress( config.getIpPort() ) );
 
         acceptor = null;
         handler = null;
 
-        log.debug( "{} has stopped listening on port {}", config.getName(), new Integer(
config.getPort() ) );
+        log.debug( "{} has stopped listening on port {}", config.getServiceName(), new Integer(
config.getIpPort() ) );
     }
 }

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/protocol/ChangePasswordProtocolHandler.java
Sun Mar 18 20:22:58 2007
@@ -130,7 +130,7 @@
 
             KerberosException ke = ( KerberosException ) e;
 
-            ErrorMessage errorMessage = getErrorMessage( config.getChangepwPrincipal(), ke
);
+            ErrorMessage errorMessage = getErrorMessage( config.getServicePrincipal(), ke
);
 
             ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
             modifier.setErrorMessage( errorMessage );

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/MonitorContext.java
Sun Mar 18 20:22:58 2007
@@ -61,7 +61,7 @@
                 ApplicationRequest authHeader = changepwContext.getAuthHeader();
                 Ticket ticket = changepwContext.getTicket();
                 ReplayCache replayCache = changepwContext.getReplayCache();
-                long clockSkew = changepwContext.getConfig().getClockSkew();
+                long clockSkew = changepwContext.getConfig().getAllowableClockSkew();
 
                 Authenticator authenticator = changepwContext.getAuthenticator();
                 KerberosPrincipal clientPrincipal = authenticator.getClientPrincipal();

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicket.java
Sun Mar 18 20:22:58 2007
@@ -42,7 +42,7 @@
         ChangePasswordConfiguration config = changepwContext.getConfig();
         Ticket ticket = changepwContext.getTicket();
         String primaryRealm = config.getPrimaryRealm();
-        KerberosPrincipal changepwPrincipal = config.getChangepwPrincipal();
+        KerberosPrincipal changepwPrincipal = config.getServicePrincipal();
 
         verifyTicket( ticket, primaryRealm, changepwPrincipal );
 

Modified: directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java?view=diff&rev=519813&r1=519812&r2=519813
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/protocol-changepw/src/main/java/org/apache/directory/server/changepw/service/VerifyServiceTicketAuthHeader.java
Sun Mar 18 20:22:58 2007
@@ -47,7 +47,7 @@
         ApplicationRequest authHeader = changepwContext.getAuthHeader();
         Ticket ticket = changepwContext.getTicket();
         EncryptionKey serverKey = changepwContext.getServerEntry().getEncryptionKey();
-        long clockSkew = changepwContext.getConfig().getClockSkew();
+        long clockSkew = changepwContext.getConfig().getAllowableClockSkew();
         ReplayCache replayCache = changepwContext.getReplayCache();
         boolean emptyAddressesAllowed = changepwContext.getConfig().isEmptyAddressesAllowed();
         InetAddress clientAddress = changepwContext.getClientAddress();



Mime
View raw message