usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rockers...@apache.org
Subject [1/3] incubator-usergrid git commit: Added new resetSuperUser method to reset the superuser.
Date Thu, 13 Nov 2014 01:04:42 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/master 464d10a4c -> 3e0ab8d3a


Added new resetSuperUser method to reset the superuser.


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

Branch: refs/heads/master
Commit: 52ff7b9a2475edfe0df60ee757104afc25914b3b
Parents: a367a5f
Author: grey <greyes@apigee.com>
Authored: Tue Sep 30 14:50:58 2014 -0700
Committer: grey <greyes@apigee.com>
Committed: Wed Oct 1 09:58:13 2014 -0700

----------------------------------------------------------------------
 .../usergrid/management/ManagementService.java  |  2 ++
 .../cassandra/ManagementServiceImpl.java        | 20 +++++++++++++++++++-
 .../apache/usergrid/tools/ResetSuperUser.java   | 19 ++++++++++++++++---
 3 files changed, 37 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/52ff7b9a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
index a7c4752..865f296 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
@@ -305,6 +305,8 @@ public interface ManagementService {
 
     public abstract void provisionSuperuser() throws Exception;
 
+    public void resetSuperUser(String username, String password, String email) throws Exception;
+
     public List<OrganizationInfo> getOrganizations( UUID startResult, int count ) throws
Exception;
 
     /** Add the properties to the organization */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/52ff7b9a/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 a94d292..bb288d3 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
@@ -340,12 +340,30 @@ public class ManagementServiceImpl implements ManagementService {
             }
         }
         else {
-            logger.warn(
+            System.out.println(
                     "Missing values for superuser account, check properties.  Skipping superuser
account setup..." );
         }
     }
 
 
+    @Override
+    public void resetSuperUser(String username, String password, String email) throws Exception
{
+        //final AccountCreationProps.SuperUser superUser = properties.getSuperUser();
+        //this.getAdminUser
+        UserInfo user = this.getAdminUserByUsername( username );
+        if ( user == null ) {
+            try {
+                createAdminUser( username, "Super User", email, password, true, false );
+            }catch(Exception e){
+
+            }
+        }
+        else {
+            this.setAdminUserPassword( user.getUuid(), password );
+        }
+    }
+
+
     public String generateOAuthSecretKey( AuthPrincipalType type ) {
         long timestamp = System.currentTimeMillis();
         ByteBuffer bytes = ByteBuffer.allocate( 20 );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/52ff7b9a/stack/tools/src/main/java/org/apache/usergrid/tools/ResetSuperUser.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/ResetSuperUser.java b/stack/tools/src/main/java/org/apache/usergrid/tools/ResetSuperUser.java
index 2a5892e..c188ff2 100644
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/ResetSuperUser.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/ResetSuperUser.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.tools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.management.AccountCreationProps;
+import org.apache.usergrid.management.cassandra.AccountCreationPropsImpl;
 import org.apache.usergrid.management.cassandra.ManagementServiceImpl;
 
 import org.apache.commons.cli.CommandLine;
@@ -90,15 +91,27 @@ public class ResetSuperUser extends ToolBase {
         startSpring();
 
         // force the props to be set
-        AccountCreationProps props = ( ( ManagementServiceImpl ) managementService ).getAccountCreationProps();
+        AccountCreationProps props =  ( ( ManagementServiceImpl ) managementService ).getAccountCreationProps();
 
         props.setProperty( PROPERTIES_SYSADMIN_LOGIN_ALLOWED, "true" );
         props.setProperty( PROPERTIES_SYSADMIN_LOGIN_NAME, line.getOptionValue( "username"
) );
         props.setProperty( PROPERTIES_SYSADMIN_LOGIN_EMAIL, line.getOptionValue( "email"
) );
         props.setProperty( PROPERTIES_SYSADMIN_LOGIN_PASSWORD, line.getOptionValue( "password"
) );
 
-        logger.info( "Starting superuser provision" );
 
-        managementService.provisionSuperuser();
+
+
+        System.out.println( "Starting superuser provision" );
+
+        try {
+            ( ( ManagementServiceImpl ) managementService )
+                    .resetSuperUser( (String)line.getOptionValue( "username" ), (String)line.getOptionValue(
"password" ),
+                            (String) line.getOptionValue( "email" ) );
+        }catch(Exception e){
+                    throw new Exception( e.toString());
+        }
+
+        System.out.println("ResetSuperUser has been reset");
+
     }
 }


Mime
View raw message