directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1684846 - in /directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model: SsfEnum.java SsfFeatureEnum.java SsfStrengthEnum.java
Date Thu, 11 Jun 2015 10:16:53 GMT
Author: elecharny
Date: Thu Jun 11 10:16:53 2015
New Revision: 1684846

URL: http://svn.apache.org/r1684846
Log:
o Renamed the SsfEnum to SsfFeature enum
o Added the SsfStrengthEnum

Added:
    directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfFeatureEnum.java
      - copied, changed from r1684163, directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfEnum.java
    directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfStrengthEnum.java
Removed:
    directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfEnum.java

Copied: directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfFeatureEnum.java
(from r1684163, directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfEnum.java)
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfFeatureEnum.java?p2=directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfFeatureEnum.java&p1=directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfEnum.java&r1=1684163&r2=1684846&rev=1684846&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfEnum.java
(original)
+++ directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfFeatureEnum.java
Thu Jun 11 10:16:53 2015
@@ -22,11 +22,11 @@ package org.apache.directory.studio.open
 import org.apache.directory.api.util.Strings;
 
 /**
- * An enumeratuon of all the possible SSF freatures.
+ * An enumeration of all the possible SSF features.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum SsfEnum
+public enum SsfFeatureEnum
 {
     SSF( "ssf" ),
     TRANSPORT( "transport" ),
@@ -37,7 +37,7 @@ public enum SsfEnum
     UPDATE_TLS( "update_tls" ),
     UPDATE_SASL( "update_sasl" ),
     SIMPLE_BIND( "simple_bind" ),
-    NONE( "" );
+    NONE( "---" );
     
     /** The associated Text */
     private String text;
@@ -45,7 +45,7 @@ public enum SsfEnum
     /**
      * Creates an SsfEnum instance
      */
-    private SsfEnum( String text )
+    private SsfFeatureEnum( String text )
     {
         this.text = text;
     }
@@ -65,7 +65,7 @@ public enum SsfEnum
      * @param feature The feature to retrieve
      * @return The SsfEnum instance found, or NONE.
      */
-    public static SsfEnum getSsf( String feature )
+    public static SsfFeatureEnum getSsf( String feature )
     {
         String ssfText = Strings.toLowerCase( feature );
         
@@ -76,42 +76,42 @@ public enum SsfEnum
         
         if ( TRANSPORT.text.equals( ssfText ) )
         {
-            return SSF;
+            return TRANSPORT;
         }
         
         if ( TLS.text.equals( ssfText ) )
         {
-            return SSF;
+            return TLS;
         }
         
         if ( SASL.text.equals( ssfText ) )
         {
-            return SSF;
+            return SASL;
         }
         
         if ( SIMPLE_BIND.text.equals( ssfText ) )
         {
-            return SSF;
+            return SIMPLE_BIND;
         }
         
         if ( UPDATE_SASL.text.equals( ssfText ) )
         {
-            return SSF;
+            return UPDATE_SASL;
         }
         
         if ( UPDATE_SSF.text.equals( ssfText ) )
         {
-            return SSF;
+            return UPDATE_SSF;
         }
         
         if ( UPDATE_TLS.text.equals( ssfText ) )
         {
-            return SSF;
+            return UPDATE_TLS;
         }
         
         if ( UPDATE_TRANSPORT.text.equals( ssfText ) )
         {
-            return SSF;
+            return UPDATE_TRANSPORT;
         }
         
         // Default...

Added: directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfStrengthEnum.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfStrengthEnum.java?rev=1684846&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfStrengthEnum.java
(added)
+++ directory/studio/trunk/plugins/openldap.common.ui/src/main/java/org/apache/directory/studio/openldap/common/ui/model/SsfStrengthEnum.java
Thu Jun 11 10:16:53 2015
@@ -0,0 +1,129 @@
+/*
+ *  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.studio.openldap.common.ui.model;
+
+/**
+ * An enumeration of all the possible SSF strengths.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum SsfStrengthEnum
+{
+    NONE( -1, "None" ),
+    NO_PROTECTION( 0, "No protection" ),
+    INTEGRITY_CHECK(1,  "Integrity check" ),
+    DES( 56, "DES" ),
+    THREE_DES( 112, "3DES" ),
+    AES_128( 128, "AES-128" ),
+    AES_256( 256, "AES-256" );
+    
+    /** The associated Text */
+    private String text;
+    
+    /** The SSF strength position */
+    private int nbBits;
+    /**
+     * Creates an SsfEnum instance
+     */
+    private SsfStrengthEnum( int nbBits, String text )
+    {
+        this.nbBits = nbBits;
+        this.text = text;
+    }
+
+    /**
+     * @return the text
+     */
+    public String getText()
+    {
+        return text;
+    }
+
+    /**
+     * @return the number of bits
+     */
+    public int getNbBits()
+    {
+        return nbBits;
+    }
+    
+    
+    /**
+     * Retrieve the instance associated to a String. Return NONE if not found.
+     * 
+     * @param feature The feature to retrieve
+     * @return The SsfEnum instance found, or NONE.
+     */
+    public static SsfStrengthEnum getSsfStrength( int nbBits )
+    {
+        switch ( nbBits )
+        {
+            case 0 : return NO_PROTECTION;
+            case 1 : return INTEGRITY_CHECK;
+            case 56 : return DES;
+            case 112 : return THREE_DES;
+            case 128 : return AES_128;
+            case 256 : return AES_256;
+            default : return NONE;
+        }
+    }
+    
+    /**
+     * Retrieve the instance associated to a String. Return NONE if not found.
+     * 
+     * @param feature The feature to retrieve
+     * @return The SsfEnum instance found, or NONE.
+     */
+    public static SsfStrengthEnum getSsfStrength( String name )
+    {
+        if ( NO_PROTECTION.text.equals( name ) )
+        {
+            return NO_PROTECTION;
+        }
+        
+        if ( INTEGRITY_CHECK.text.equals( name ) )
+        {
+            return INTEGRITY_CHECK;
+        }
+        
+        if ( DES.text.equals( name ) )
+        {
+            return DES;
+        }
+        
+        if ( THREE_DES.text.equals( name ) )
+        {
+            return THREE_DES;
+        }
+        
+        if ( AES_128.text.equals( name ) )
+        {
+            return AES_128;
+        }
+        
+        if ( AES_256.text.equals( name ) )
+        {
+            return AES_256;
+        }
+        
+        // Default...
+        return NONE;
+    }
+}



Mime
View raw message