ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [41/60] [abbrv] ignite git commit: IGNITE-5080 - Fixes in SecurityBasicPermissionSet
Date Thu, 04 May 2017 11:32:45 GMT
IGNITE-5080 - Fixes in SecurityBasicPermissionSet


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2f7172cb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2f7172cb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2f7172cb

Branch: refs/heads/ignite-5075-cacheStart
Commit: 2f7172cb5c7af8e61cba00d6ec5e4d6f76b635e4
Parents: eb6a169
Author: Valentin Kulichenko <valentin.kulichenko@gmail.com>
Authored: Fri Apr 28 14:53:33 2017 +0200
Committer: Valentin Kulichenko <valentin.kulichenko@ing.be>
Committed: Tue May 2 12:55:37 2017 +0200

----------------------------------------------------------------------
 .../security/SecurityBasicPermissionSet.java    | 89 ++++++++++++++------
 1 file changed, 65 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2f7172cb/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityBasicPermissionSet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityBasicPermissionSet.java
b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityBasicPermissionSet.java
index 7521dff..44166d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityBasicPermissionSet.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityBasicPermissionSet.java
@@ -17,10 +17,12 @@
 
 package org.apache.ignite.plugin.security;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
@@ -33,16 +35,20 @@ public class SecurityBasicPermissionSet implements SecurityPermissionSet
{
     private static final long serialVersionUID = 0L;
 
     /** Cache permissions. */
-    private Map<String, Collection<SecurityPermission>> cachePerms = new HashMap<>();
+    @GridToStringInclude
+    private Map<String, Collection<SecurityPermission>> cachePermissions = new
HashMap<>();
 
     /** Task permissions. */
-    private Map<String, Collection<SecurityPermission>> taskPerms = new HashMap<>();
+    @GridToStringInclude
+    private Map<String, Collection<SecurityPermission>> taskPermissions = new
HashMap<>();
 
     /** Service permissions. */
-    private Map<String, Collection<SecurityPermission>> srvcPerms = new HashMap<>();
+    @GridToStringInclude
+    private Map<String, Collection<SecurityPermission>> servicePermissions =
new HashMap<>();
 
     /** System permissions. */
-    private Collection<SecurityPermission> sysPerms = new ArrayList<>();
+    @GridToStringInclude
+    private Collection<SecurityPermission> systemPermissions;
 
     /** Default allow all. */
     private boolean dfltAllowAll;
@@ -50,37 +56,43 @@ public class SecurityBasicPermissionSet implements SecurityPermissionSet
{
     /**
      * Setter for set cache permission map.
      *
-     * @param cachePerms Cache permissions.
+     * @param cachePermissions Cache permissions.
      */
-    public void setCachePermissions(Map<String, Collection<SecurityPermission>>
cachePerms) {
-        this.cachePerms = cachePerms;
+    public void setCachePermissions(Map<String, Collection<SecurityPermission>>
cachePermissions) {
+        A.notNull(cachePermissions, "cachePermissions");
+
+        this.cachePermissions = cachePermissions;
     }
 
     /**
      * Setter for set task permission map.
      *
-     * @param taskPerms Task permissions.
+     * @param taskPermissions Task permissions.
      */
-    public void setTaskPermissions(Map<String, Collection<SecurityPermission>>
taskPerms) {
-        this.taskPerms = taskPerms;
+    public void setTaskPermissions(Map<String, Collection<SecurityPermission>>
taskPermissions) {
+        A.notNull(taskPermissions, "taskPermissions");
+
+        this.taskPermissions = taskPermissions;
     }
 
     /**
      * Setter for set service permission map.
      *
-     * @param srvcPerms Service permissions.
+     * @param servicePermissions Service permissions.
      */
-    public void setServicePermissions(Map<String, Collection<SecurityPermission>>
srvcPerms) {
-        this.srvcPerms = srvcPerms;
+    public void setServicePermissions(Map<String, Collection<SecurityPermission>>
servicePermissions) {
+        A.notNull(taskPermissions, "servicePermissions");
+
+        this.servicePermissions = servicePermissions;
     }
 
     /**
-     * Setter for set collection  system permission.
+     * Setter for set collection system permission.
      *
-     * @param sysPerms System permissions.
+     * @param systemPermissions System permissions.
      */
-    public void setSystemPermissions(Collection<SecurityPermission> sysPerms) {
-        this.sysPerms = sysPerms;
+    public void setSystemPermissions(Collection<SecurityPermission> systemPermissions)
{
+        this.systemPermissions = systemPermissions;
     }
 
     /**
@@ -94,22 +106,22 @@ public class SecurityBasicPermissionSet implements SecurityPermissionSet
{
 
     /** {@inheritDoc} */
     @Override public Map<String, Collection<SecurityPermission>> cachePermissions()
{
-        return cachePerms;
+        return cachePermissions;
     }
 
     /** {@inheritDoc} */
     @Override public Map<String, Collection<SecurityPermission>> taskPermissions()
{
-        return taskPerms;
+        return taskPermissions;
     }
 
     /** {@inheritDoc} */
     @Override public Map<String, Collection<SecurityPermission>> servicePermissions()
{
-        return srvcPerms;
+        return servicePermissions;
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public Collection<SecurityPermission> systemPermissions() {
-        return sysPerms;
+        return systemPermissions;
     }
 
     /** {@inheritDoc} */
@@ -118,6 +130,35 @@ public class SecurityBasicPermissionSet implements SecurityPermissionSet
{
     }
 
     /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (!(o instanceof SecurityBasicPermissionSet))
+            return false;
+
+        SecurityBasicPermissionSet other = (SecurityBasicPermissionSet)o;
+
+        return dfltAllowAll == other.dfltAllowAll &&
+            F.eq(cachePermissions, other.cachePermissions) &&
+            F.eq(taskPermissions, other.taskPermissions) &&
+            F.eq(servicePermissions, other.servicePermissions) &&
+            F.eq(systemPermissions, other.systemPermissions);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int res = (dfltAllowAll ? 1 : 0);
+
+        res = 31 * res + (cachePermissions != null ? cachePermissions.hashCode() : 0);
+        res = 31 * res + (taskPermissions != null ? taskPermissions.hashCode() : 0);
+        res = 31 * res + (servicePermissions != null ? servicePermissions.hashCode() : 0);
+        res = 31 * res + (systemPermissions != null ? systemPermissions.hashCode() : 0);
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(SecurityBasicPermissionSet.class, this);
     }


Mime
View raw message