Apply comments for MDSAL Store 17/30317/2
authorSharon Aicler <saichler@cisco.com>
Sat, 28 Nov 2015 14:53:08 +0000 (14:53 +0000)
committerSharon Aicler <saichler@cisco.com>
Sat, 28 Nov 2015 15:12:57 +0000 (07:12 -0800)
This reverts commit 7050d9954aed918d6b6bca4ccaec803a33f83a1d.

Change-Id: I450370f72888a54790d2c3e1077adab96a22bc40
Signed-off-by: Sharon Aicler <saichler@cisco.com>
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/IDMStoreException.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/IDMStoreUtil.java
aaa-authn-api/src/main/java/org/opendaylight/aaa/api/IIDMStore.java
aaa-authn-mdsal-store/aaa-authn-mdsal-store-impl/src/main/java/org/opendaylight/aaa/authn/mdsal/store/DataEncrypter.java
aaa-authn-mdsal-store/aaa-authn-mdsal-store-impl/src/main/java/org/opendaylight/aaa/authn/mdsal/store/IDMObject2MDSAL.java
aaa-authn-mdsal-store/aaa-authn-mdsal-store-impl/src/main/java/org/opendaylight/aaa/authn/mdsal/store/IDMStore.java
aaa-idmlight/src/main/java/org/opendaylight/aaa/idm/IdmLightApplication.java
aaa-idmlight/src/main/java/org/opendaylight/aaa/idm/rest/RoleHandler.java
aaa-idmlight/src/main/java/org/opendaylight/aaa/idm/rest/UserHandler.java

index 97943bb759d434b81fd9aeb4b9bd490c90b96c1b..a3eff2f06b426d6b21f2f432370cf40b680fb7be 100644 (file)
@@ -1,7 +1,22 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.aaa.api;
 
-@SuppressWarnings("serial")
+/*
+ * @author - Sharon Aicler (saichler@cisco.com)
+ */
 public class IDMStoreException extends Exception{
+
+    private static final long serialVersionUID = -7534127680943957878L;
+
+    public IDMStoreException(Exception e){
+        super(e);
+    }
     public IDMStoreException(String msg){
         super(msg);
     }
index ff65f0eaca7e458756002f8eb890329d775b9925..dcc4c1684bcd49fa6a441e442170c46f891950ab 100644 (file)
@@ -1,6 +1,25 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.aaa.api;
 
+import javax.naming.OperationNotSupportedException;
+/*
+ *  This class is a utility to construct the different elements keys for the different data stores.
+ *  For not making mistakes around the code constructing an element key, this class standardize the
+ *  way the key is constructed to be used by the different data stores.
+ *
+ *  @author - Sharon Aicler (saichler@cisco.com)
+ */
+
 public class IDMStoreUtil {
+    private IDMStoreUtil() throws OperationNotSupportedException{
+        throw new OperationNotSupportedException();
+    }
     public static String createDomainid(String domainName){
         return domainName;
     }
index 711bac1f1ec2c9ca2aca546a905b42d629d97756..e0f4ffbf1bd6417afa0c2b1dde0f3e9285179e70 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.aaa.api;
 
 import org.opendaylight.aaa.api.model.Domain;
@@ -8,10 +15,11 @@ import org.opendaylight.aaa.api.model.Role;
 import org.opendaylight.aaa.api.model.Roles;
 import org.opendaylight.aaa.api.model.User;
 import org.opendaylight.aaa.api.model.Users;
-
+/**
+ * @author - Sharon Aicler (saichler@cisco.com)
+ **/
 public interface IIDMStore {
-    public static final String DEFAULT_DOMAIN = "sdn";
-    public static final int MAX_FIELD_LEN = 256;
+    public String DEFAULT_DOMAIN = "sdn";
     //Domain methods
     public Domain writeDomain(Domain domain) throws IDMStoreException;
     public Domain readDomain(String domainid) throws IDMStoreException;
index 8831a72f36571115396e892cad5075d293773286..685741b4e76e8d93779097db64290b47a050de2e 100644 (file)
@@ -19,7 +19,9 @@ import javax.crypto.spec.PBEKeySpec;
 import javax.crypto.spec.SecretKeySpec;
 import javax.xml.bind.DatatypeConverter;
 import java.security.spec.KeySpec;
-
+/**
+ * @author - Sharon Aicler (saichler@cisco.com)
+ **/
 public class DataEncrypter {
 
     final protected SecretKey k;
index 593c71c6b145ee4140aa1eb2ea53b0006fb09db3..40f2251ffd9ddf0cbf05acb6693ca11a1fa3f688 100644 (file)
@@ -31,6 +31,10 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
  */
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+/**
+ * @author Sharon Aicler - saichler@cisco.com
+ *
+ */
 public abstract class IDMObject2MDSAL {
     private static final Logger LOGGER = LoggerFactory.getLogger(IDMObject2MDSAL.class);
     //this is a Map mapping between the class type of the IDM Model object to a structure containing the corresponding setters and getter methods
index b475bbee30a602454a73a04739dc6585899f0dc6..e43b69e6ae725d2006a0c242d325578358edf12f 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.aaa.authn.mdsal.store;
 
 import java.util.List;
@@ -13,7 +20,10 @@ import org.opendaylight.aaa.api.model.Role;
 import org.opendaylight.aaa.api.model.Roles;
 import org.opendaylight.aaa.api.model.User;
 import org.opendaylight.aaa.api.model.Users;
-
+/**
+ * @author Sharon Aicler - saichler@cisco.com
+ *
+ */
 public class IDMStore implements IIDMStore{
     private final IDMMDSALStore mdsalStore;
 
index cafa2f14eaf42d62361cb6630e15dcbb8091c203..a8ffbaed1645402956a34c014b553e4da8c86627 100644 (file)
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
  */
 public class IdmLightApplication extends Application {
     private static Logger logger = LoggerFactory.getLogger(IdmLightApplication.class);
-
+    public static final int MAX_FIELD_LEN = 256;
     public IdmLightApplication() {
         try {
             StoreBuilder.init();
index a13f3c670bb7d1ff59f7f8585270fd1e283dae7a..f2478a8670944dcbd80beb489738f6bc239e48e2 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.aaa.api.IIDMStore;
 import org.opendaylight.aaa.api.model.IDMError;
 import org.opendaylight.aaa.api.model.Role;
 import org.opendaylight.aaa.api.model.Roles;
+import org.opendaylight.aaa.idm.IdmLightApplication;
 import org.opendaylight.aaa.idm.IdmLightProxy;
 import org.opendaylight.aaa.idm.ServiceLocator;
 import org.slf4j.Logger;
@@ -85,24 +86,24 @@ public class RoleHandler {
          if (role.getName()==null) {
             return new IDMError(404,"name must be defined on role create","").response();
          }
-         else if (role.getName().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"role name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (role.getName().length()> IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"role name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // domain
          if (role.getDomainid()==null) {
             return new IDMError(404,"The role's domain must be defined on role when creating a role.","").response();
          }
-         else if (role.getDomainid().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"role domain max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (role.getDomainid().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"role domain max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // description
          if (role.getDescription()==null) {
             role.setDescription("");
          }
-         else if (role.getDescription().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"role description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (role.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"role description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          role = ServiceLocator.INSTANCE.getStore().writeRole(role);
@@ -126,13 +127,13 @@ public class RoleHandler {
 
          // name
          // TODO: names should be unique
-         if ((role.getName()!=null) && (role.getName().length()>IIDMStore.MAX_FIELD_LEN)) {
-            return new IDMError(400,"role name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         if ((role.getName()!=null) && (role.getName().length()>IdmLightApplication.MAX_FIELD_LEN)) {
+            return new IDMError(400,"role name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // description
-         if ((role.getDescription()!=null) && (role.getDescription().length()>IIDMStore.MAX_FIELD_LEN)) {
-            return new IDMError(400,"role description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         if ((role.getDescription()!=null) && (role.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN)) {
+            return new IDMError(400,"role description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          role = ServiceLocator.INSTANCE.getStore().updateRole(role);
index 23904cc7964b31ed0340bcf117e640dd665fdee8..fc5b3184c3bafd3af0e0ac624f485b66d4e9370d 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.aaa.api.IIDMStore;
 import org.opendaylight.aaa.api.model.IDMError;
 import org.opendaylight.aaa.api.model.User;
 import org.opendaylight.aaa.api.model.Users;
+import org.opendaylight.aaa.idm.IdmLightApplication;
 import org.opendaylight.aaa.idm.IdmLightProxy;
 import org.opendaylight.aaa.idm.ServiceLocator;
 import org.slf4j.Logger;
@@ -99,40 +100,40 @@ public class UserHandler {
          if (user.getName()==null) {
             return new IDMError(400,"user name is required","").response();
          }
-         else if (user.getName().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"user name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (user.getName().length()> IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"user name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // domain id/name is required
          if (user.getDomainid()==null) {
             return new IDMError(400,"user domain is required","").response();
          }
-         else if (user.getDomainid().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"user domain max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (user.getDomainid().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"user domain max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // user description is optional
          if (user.getDescription()==null) {
             user.setDescription("");
          }
-         else if (user.getDescription().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"user description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (user.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"user description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // user email is optional
          if (user.getEmail()==null) {
             user.setEmail("");
          }
-         else if (user.getEmail().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"user email max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (user.getEmail().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"user email max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // user password optional and will default if not provided
          if (user.getPassword()==null) {
             user.setPassword(DEFAULT_PWD);
          }
-         else if (user.getPassword().length()>IIDMStore.MAX_FIELD_LEN) {
-            return new IDMError(400,"user password max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+         else if (user.getPassword().length()>IdmLightApplication.MAX_FIELD_LEN) {
+            return new IDMError(400,"user password max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
          }
 
          // create user