You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/08/25 14:32:38 UTC

[13/22] git commit: AMBARI-6933. Rolling restart not working. (swagle via mahadev)

AMBARI-6933. Rolling restart not working. (swagle via mahadev)


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

Branch: refs/heads/branch-alerts-dev
Commit: cc9ae3f6f05ebf933162c28c8ce9b11be9a3a94b
Parents: 0e7a267
Author: Mahadev Konar <ma...@apache.org>
Authored: Fri Aug 22 14:43:02 2014 -0700
Committer: Mahadev Konar <ma...@apache.org>
Committed: Fri Aug 22 14:43:06 2014 -0700

----------------------------------------------------------------------
 .../internal/InternalAuthenticationToken.java   | 30 +++++++++++++++-----
 1 file changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cc9ae3f6/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/internal/InternalAuthenticationToken.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/internal/InternalAuthenticationToken.java b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/internal/InternalAuthenticationToken.java
index 8752278..4494697 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/internal/InternalAuthenticationToken.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/internal/InternalAuthenticationToken.java
@@ -18,19 +18,26 @@
 
 package org.apache.ambari.server.security.authorization.internal;
 
+import java.util.Collection;
+import java.util.Collections;
+
 import org.apache.ambari.server.orm.entities.PermissionEntity;
 import org.apache.ambari.server.orm.entities.PrivilegeEntity;
+import org.apache.ambari.server.orm.entities.ResourceEntity;
+import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
 import org.apache.ambari.server.security.authorization.AmbariGrantedAuthority;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.userdetails.User;
-import java.util.Collection;
-import java.util.Collections;
 
 public class InternalAuthenticationToken implements Authentication {
-
+  private static final long serialVersionUID = 1L;
+  
   private static final String INTERNAL_NAME = "internal";
   private static final PrivilegeEntity ADMIN_PRIV_ENTITY = new PrivilegeEntity();
+  static{
+    createAdminPrivilegeEntity(ADMIN_PRIV_ENTITY);
+  }
 
   // used in ClustersImpl, checkPermissions
   private static final Collection<? extends GrantedAuthority> AUTHORITIES =
@@ -40,12 +47,22 @@ public class InternalAuthenticationToken implements Authentication {
   private String token;
   private boolean authenticated = false;
 
-  static{
+
+  private static void createAdminPrivilegeEntity(PrivilegeEntity entity) {
     PermissionEntity pe = new PermissionEntity();
     pe.setId(PermissionEntity.AMBARI_ADMIN_PERMISSION);
     pe.setPermissionName(PermissionEntity.AMBARI_ADMIN_PERMISSION_NAME);
-
-    ADMIN_PRIV_ENTITY.setPermission(pe);
+    
+    entity.setPermission(pe);
+    
+    ResourceEntity resource = new ResourceEntity();
+    resource.setId(1L);
+    
+    ResourceTypeEntity rte = new ResourceTypeEntity();
+    rte.setId(ResourceTypeEntity.CLUSTER_RESOURCE_TYPE);
+    rte.setName(ResourceTypeEntity.CLUSTER_RESOURCE_TYPE_NAME);
+    resource.setResourceType(rte);
+    entity.setResource(resource);
   }
 
   public InternalAuthenticationToken(String tokenString) {
@@ -81,7 +98,6 @@ public class InternalAuthenticationToken implements Authentication {
   public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
     this.authenticated = isAuthenticated;
   }
-
   @Override
   public String getName() {
     return INTERNAL_NAME;