usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [75/81] [abbrv] git commit: hand merge of conflicting work from USERGRID-77 (f564f0)
Date Thu, 13 Feb 2014 13:22:07 GMT
hand merge of conflicting work from USERGRID-77 (f564f0)


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

Branch: refs/heads/two-dot-o
Commit: afb02ccf74e9e8ebb411cb907d1145b18f5660b1
Parents: 40475c2
Author: zznate <zznate.m@gmail.com>
Authored: Sat Feb 8 08:54:31 2014 -0800
Committer: zznate <zznate.m@gmail.com>
Committed: Sat Feb 8 08:54:31 2014 -0800

----------------------------------------------------------------------
 .../management/AccountCreationProps.java        |  9 ++++
 .../cassandra/AccountCreationPropsImpl.java     | 47 +++++++++++++++++++-
 .../cassandra/ManagementServiceImpl.java        | 43 +++++-------------
 3 files changed, 67 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afb02ccf/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
b/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
index c66bfd9..79c3fab 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
@@ -116,4 +116,13 @@ public interface AccountCreationProps {
     public void setProperty( String name, String value );
 
     public Properties getMailProperties();
+
+    public SuperUser getSuperUser();
+
+    public static interface SuperUser{
+        boolean isEnabled();
+        String getUsername();
+        String getEmail();
+        String getPassword();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afb02ccf/stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
index 155d491..1c8a7f8 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
@@ -26,16 +26,19 @@ import org.apache.usergrid.management.AccountCreationProps;
 import static java.lang.Boolean.parseBoolean;
 
 import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.apache.usergrid.utils.ListUtils.anyNull;
 
 
 public class AccountCreationPropsImpl implements AccountCreationProps {
     private static final Logger logger = LoggerFactory.getLogger( AccountCreationPropsImpl.class
);
 
-    protected Properties properties;
+    protected final Properties properties;
+    private final SuperUser superUser;
 
 
     public AccountCreationPropsImpl( Properties properties ) {
         this.properties = properties;
+        this.superUser = new SuperUserImpl(properties);
     }
 
 
@@ -109,4 +112,46 @@ public class AccountCreationPropsImpl implements AccountCreationProps
{
         }
         return p;
     }
+
+    public SuperUser getSuperUser() {
+        return superUser;
+    }
+
+    protected static class SuperUserImpl implements SuperUser {
+        private final boolean enabled;
+        private final String username;
+        private final String email;
+        private final String password;
+
+        public SuperUserImpl(Properties properties) {
+            enabled = parseBoolean(properties.getProperty(PROPERTIES_SYSADMIN_LOGIN_ALLOWED));
+            username = properties.getProperty(PROPERTIES_SYSADMIN_LOGIN_NAME);
+            email = properties.getProperty(PROPERTIES_SYSADMIN_LOGIN_EMAIL);
+            password = properties.getProperty(PROPERTIES_SYSADMIN_LOGIN_PASSWORD);
+        }
+
+        @Override
+        public boolean isEnabled() {
+            return superuserEnabled();
+        }
+
+        @Override
+        public String getUsername() {
+            return username;
+        }
+
+        @Override
+        public String getEmail() {
+            return email;
+        }
+
+        @Override
+        public String getPassword() {
+            return password;
+        }
+
+        private boolean superuserEnabled() {
+            return enabled && !anyNull(username, email, password);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afb02ccf/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index d3923cf..ec67483 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -129,10 +129,7 @@ import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_MAI
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_ORGANIZATION_ACTIVATION_URL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SETUP_TEST_ACCOUNT;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_EMAIL;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_ALLOWED;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_EMAIL;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_NAME;
-import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_LOGIN_PASSWORD;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_NAME;
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_TEST_ACCOUNT_ADMIN_USER_PASSWORD;
@@ -321,37 +318,23 @@ public class ManagementServiceImpl implements ManagementService {
             logger.warn( "Test app creation disabled" );
         }
 
-        if ( superuserEnabled() ) {
+        if ( properties.getSuperUser().isEnabled() ) {
             provisionSuperuser();
         }
     }
 
 
-    public boolean superuserEnabled() {
-        boolean superuser_enabled = parseBoolean( properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_ALLOWED
) );
-        String superuser_username = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_NAME
);
-        String superuser_email = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL
);
-        String superuser_password = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_PASSWORD
);
-
-        return superuser_enabled && !anyNull( superuser_username, superuser_email,
superuser_password );
-    }
-
-
     @Override
     public void provisionSuperuser() throws Exception {
-        boolean superuser_enabled = parseBoolean( properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_ALLOWED
) );
-        String superuser_username = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_NAME
);
-        String superuser_email = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL
);
-        String superuser_password = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_PASSWORD
);
-
-        if ( !anyNull( superuser_username, superuser_email, superuser_password ) ) {
-            UserInfo user = this.getAdminUserByUsername( superuser_username );
+        final AccountCreationProps.SuperUser superUser = properties.getSuperUser();
+        if ( superUser.isEnabled() ) {
+            UserInfo user = this.getAdminUserByUsername( superUser.getUsername() );
             if ( user == null ) {
-                createAdminUser( superuser_username, "Super User", superuser_email, superuser_password,
-                        superuser_enabled, !superuser_enabled );
+                createAdminUser( superUser.getUsername(), "Super User", superUser.getEmail(),
superUser.getPassword(),
+                        superUser.isEnabled(), !superUser.isEnabled() );
             }
             else {
-                this.setAdminUserPassword( user.getUuid(), superuser_password );
+                this.setAdminUserPassword( user.getUuid(), superUser.getPassword() );
             }
         }
         else {
@@ -1246,14 +1229,13 @@ public class ManagementServiceImpl implements ManagementService {
         if ( verify( MANAGEMENT_APPLICATION_ID, user.getUuid(), password ) ) {
             userInfo = getUserInfo( MANAGEMENT_APPLICATION_ID, user );
 
-            boolean userIsSuperAdmin =
-                    properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL ).equals( userInfo.getEmail()
);
+            boolean userIsSuperAdmin = properties.getSuperUser().isEnabled() && properties.getSuperUser().getEmail().equals(userInfo.getEmail());
 
             boolean testUserEnabled = parseBoolean( properties.getProperty( PROPERTIES_SETUP_TEST_ACCOUNT
) );
 
             boolean userIsTestUser = !testUserEnabled ? false :
-                                     properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL
)
-                                               .equals( userInfo.getEmail() );
+                    properties.getProperty( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL )
+                            .equals( userInfo.getEmail() );
 
             if ( !userIsSuperAdmin && !userIsTestUser ) {
 
@@ -1489,9 +1471,8 @@ public class ManagementServiceImpl implements ManagementService {
 
         Map<UUID, String> organizations;
 
-        boolean superuser_enabled = parseBoolean( properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_ALLOWED
) );
-        String superuser_username = properties.getProperty( PROPERTIES_SYSADMIN_LOGIN_NAME
);
-        if ( superuser_enabled && ( superuser_username != null ) && superuser_username.equals(
user.getUsername() ) ) {
+        AccountCreationProps.SuperUser superUser = properties.getSuperUser();
+        if ( superUser.isEnabled() && superUser.getUsername().equals( user.getUsername()
) ) {
             organizations = buildOrgBiMap( getOrganizations( null, 10 ) );
         }
         else {


Mime
View raw message