directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1709633 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/
Date Tue, 20 Oct 2015 16:12:20 GMT
Author: elecharny
Date: Tue Oct 20 16:12:19 2015
New Revision: 1709633

URL: http://svn.apache.org/viewvc?rev=1709633&view=rev
Log:
o Added an abstract Anonymizer
o Injected the SchemaManager in anonymizers

Added:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/DefaultAnonymizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java?rev=1709633&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
(added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/AbstractAnonymizer.java
Tue Oct 20 16:12:19 2015
@@ -0,0 +1,42 @@
+/*
+ *   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.api.ldap.model.ldif.anonymizer;
+
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+
+/**
+ * An abstract class implementing the default behavior of an Aninymizer instance
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class AbstractAnonymizer<K> implements Anonymizer<K>
+{
+    /** The SchemaManager instance */
+    protected SchemaManager schemaManager;
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setSchemaManager( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+    }
+}

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java?rev=1709633&r1=1709632&r2=1709633&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/Anonymizer.java
Tue Oct 20 16:12:19 2015
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.directory.api.ldap.model.entry.Attribute;
 import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
 
 
 /**
@@ -42,4 +43,12 @@ public interface Anonymizer<K>
      * @return The anonymized attribute
      */
     Attribute anonymize( Map<Value<K>, Value<K>> valueMap, Attribute attribute
);
+    
+    
+    /**
+     * Inject a SchemaManager instance in this Anonymizer
+     *
+     * @param schemaManager The SchemaManager instance
+     */
+    void setSchemaManager( SchemaManager schemaManager );
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java?rev=1709633&r1=1709632&r2=1709633&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/BinaryAnonymizer.java
Tue Oct 20 16:12:19 2015
@@ -36,7 +36,7 @@ import org.apache.directory.api.ldap.mod
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class BinaryAnonymizer implements Anonymizer<byte[]>
+public class BinaryAnonymizer extends AbstractAnonymizer<byte[]>
 {
     /** Create a random generator */
     Random random = new Random( System.currentTimeMillis() );
@@ -45,7 +45,6 @@ public class BinaryAnonymizer implements
     /**
      * Anonymize an attribute using pure random values (either chars of bytes, depending
on the Attribute type)
      */
-    @Override
     public Attribute anonymize( Map<Value<byte[]>, Value<byte[]>> valueMap,
Attribute attribute )
     {
         Attribute result = new DefaultAttribute( attribute.getAttributeType() );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/DefaultAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/DefaultAnonymizer.java?rev=1709633&r1=1709632&r2=1709633&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/DefaultAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/DefaultAnonymizer.java
Tue Oct 20 16:12:19 2015
@@ -32,11 +32,11 @@ import org.apache.directory.api.ldap.mod
 
 
 /**
- * TODO DefaultAnonymizer.
+ * A DefaultAnonymizer. It take a value and change it to a random String
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultAnonymizer<K> implements Anonymizer<K>
+public class DefaultAnonymizer<K> extends AbstractAnonymizer<K>
 {
     /** Create a random generator */
     Random random = new Random( System.nanoTime() );
@@ -45,7 +45,6 @@ public class DefaultAnonymizer<K> implem
     /**
      * Anonymize an attribute using pure random values (either chars of bytes, depending
on the Attribute type)
      */
-    @Override
     public Attribute anonymize( Map<Value<K>, Value<K>> valueMap, Attribute
attribute )
     {
         Attribute result = new DefaultAttribute( attribute.getAttributeType() );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java?rev=1709633&r1=1709632&r2=1709633&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
Tue Oct 20 16:12:19 2015
@@ -32,11 +32,11 @@ import org.apache.directory.api.ldap.mod
 
 
 /**
- * A default anonymizer for attributes that is an Integer
+ * A default anonymizer for attributes that is an Integer. the initial value is randomized
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class IntegerAnonymizer implements Anonymizer<String>
+public class IntegerAnonymizer extends AbstractAnonymizer<String>
 {
     /** Create a random generator */
     Random random = new Random( System.currentTimeMillis() );
@@ -45,7 +45,6 @@ public class IntegerAnonymizer implement
     /**
      * Anonymize an attribute using pure random values (either chars of bytes, depending
on the Attribute type)
      */
-    @Override
     public Attribute anonymize( Map<Value<String>, Value<String>> valueMap,
Attribute attribute )
     {
         Attribute result = new DefaultAttribute( attribute.getAttributeType() );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java?rev=1709633&r1=1709632&r2=1709633&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/StringAnonymizer.java
Tue Oct 20 16:12:19 2015
@@ -36,7 +36,7 @@ import org.apache.directory.api.ldap.mod
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StringAnonymizer implements Anonymizer<String>
+public class StringAnonymizer extends AbstractAnonymizer<String>
 {
     /** Create a random generator */
     Random random = new Random( System.currentTimeMillis() );
@@ -45,7 +45,6 @@ public class StringAnonymizer implements
     /**
      * Anonymize an attribute using pure random values (either chars of bytes, depending
on the Attribute type)
      */
-    @Override
     public Attribute anonymize( Map<Value<String>, Value<String>> valueMap,
Attribute attribute )
     {
         Attribute result = new DefaultAttribute( attribute.getAttributeType() );



Mime
View raw message