Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: usergrid/usergrid
...
head fork: usergrid/usergrid
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 5 files changed
  • 0 commit comments
  • 5 contributors
View
18 sdks/php/lib/vendor/Apigee/Usergrid/Collection.php
@@ -274,5 +274,21 @@ public function get_prev_page() {
}
return FALSE;
}
+ public function serialize(){
+ $data = array();
+ $data->type = $this->type;
+ $data->qs = $this->qs;
+ $data->iterator = $this->iterator;
+ $data->previous = $this->previous;
+ $data->next = $this->next;
+ $data->cursor = $this->cursor;
+ $data->list=[];
+ $this->reset_entity_pointer();
+ while ($this->has_next_entity()) {
+ $entity = $this->get_next_entity();
+ array_push($data->list, $entity->get_json())
+ }
+ return json_encode($data);
+ }
-}
+}
View
90 sdks/php/lib/vendor/Apigee/Usergrid/Entity.php
@@ -200,19 +200,97 @@ public function destroy() {
}
public function connect($connection, $entity) {
- // TODO
+ $connectee=Entity::get_entity_id($entity);
+ $connecteeType=$entity->get("type");
+ if(!$connectee){
+ return "Error in connect. No UUID specified for connectee";
+ }
+
+ $connector=Entity::get_entity_id($this);
+ $connectorType=$this->get("type");
+ if(!$connector){
+ return "Error in connect. No UUID specified for connector";
+ }
+
+ $endpoint = $connectorType.'/'.$connector.'/'.$connection.'/'.$connecteeType.'/'.$connectee;
+ $result=$this->client->post($endpoint, array(), array());
+ $error=$result->get_error();
+ if($error){
+ return $result->get_error_message();
+ }else{
+ return $result->get_data();
+ }
+ }
+
+ public function disconnect($connection, $entity) {
+ $connectee=Entity::get_entity_id($entity);
+ $connecteeType=$entity->get("type");
+ if(!$connectee){
+ return "Error in disconnect. No UUID specified for connectee";
+ }
+
+ $connector=Entity::get_entity_id($this);
+ $connectorType=$this->get("type");
+ if(!$connector){
+ return "Error in disconnect. No UUID specified for connector";
+ }
+
+ $endpoint = $connectorType.'/'.$connector.'/'.$connection.'/'.$connecteeType.'/'.$connectee;
+
+ $result=$this->client->delete($endpoint, array(), array());
+ $error=$result->get_error();
+ if($error){
+ return $result->get_error_message();
+ }else{
+ return $result->get_data();
+ }
}
public static function get_entity_id($entity) {
- // TODO
+ $id = false;
+ if (Client::is_uuid($entity->get('uuid'))) {
+ $id = $entity->get('uuid');
+ } else {
+ if ($type == 'users') {
+ $id = $entity->get('username');
+ } else if ($entity->get('name')) {
+ $id = $entity->get('name');
+ }
+ }
+ return $id;
}
public function get_connections($connection) {
- // TODO
+ $connectorType = $this->get('type');
+ $connector = Entity::get_entity_id($this);
+ if (!$connector) {
+ return;
+ }
+
+ $endpoint = $connectorType . '/' . $connector . '/' . $connection . '/';
+ $result=$this->client->get($endpoint, array());
+ $this->set($connection,array());
+
+ $length = count($result->entities);
+ for ($i = 0; i < $length; $i++) {
+ if ($result['entities'][i]['type'] == 'user') {
+ $this[$connection][$result['entities'][i]['username']] = $result['entities'][i];
+ } else {
+ $this[$connection][$result['entities'][i]['name']] = $result['entities'][i];
+ }
+ }
}
- public function disconnect($connection, $entity) {
- // TODO
+ public function get_connecting($connection) {
+ $connectorType = $this->get('type');
+ $connector = Entity::get_entity_id($this);
+ if (!$connector) {
+ return;
+ }
+
+ $endpoint = $connectorType. '/' . $connector . '/connecting/' . $connection . '/';
+ $result=$this->client->get($endpoint, array());
+ return $result->get_data();
}
-}
+}
View
9 stack/services/src/main/java/org/apache/usergrid/management/AccountCreationProps.java
@@ -116,4 +116,13 @@
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();
+ }
}
View
47 stack/services/src/main/java/org/apache/usergrid/management/cassandra/AccountCreationPropsImpl.java
@@ -26,16 +26,19 @@
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 Properties getMailProperties() {
}
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);
+ }
+ }
}
View
43 stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -129,10 +129,7 @@
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 void setup() throws Exception {
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 UserInfo verifyAdminUserPasswordCredentials( String name, String password
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 Long getLastAdminPasswordChange( UUID userId ) throws Exception {
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 {

No commit comments for this range

Something went wrong with that request. Please try again.