Difference between revisions of "GeoFence library"

From Gcube Wiki
Jump to: navigation, search
(getUserGroupByName(String userName))
(updateUserGroup(Group group))
Line 185: Line 185:
 
g.setEnabled(false);
 
g.setEnabled(false);
 
HttpStatus status = gf.updateUserGroup(g);
 
HttpStatus status = gf.updateUserGroup(g);
 +
</source>
 +
 +
===updateUserGroupById(String id, boolean enabled)===
 +
 +
Parameters List :
 +
*"id" : [String value] It's the userId of user you are looking for;
 +
*"enabled" : [boolena value] It's the enabled flag of group;
 +
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String id =  ...
 +
HttpStatus status = gf.updateUserGroupById(id, true);
 +
</source>
 +
 +
===updateUserGroupByName(String name, boolean enabled)===
 +
 +
Parameters List :
 +
*"id" : [String value] It's the userId of user you are looking for;
 +
*"enabled" : [boolena value] It's the enabled flag of group;
 +
 +
'''Invocation example'''
 +
<source lang="java5">
 +
String name =  ...
 +
HttpStatus status = gf.updateUserGroupByName(name, true);
 
</source>
 
</source>

Revision as of 17:58, 21 November 2017

This section aims to describe the Geofence library in order to help developers to manage users, groups, rules and instances in Geofence server. After configuring between Geofence server with GeoServer, for instance, it's possible create an user in Geofence and automatically it's possible to login (with this user) in GeoServer. Following is a list of methods, with all details to uderstand how invoke them.


Constructor

Parameters List :

  • "geofenceRestUrl" : [String value] The URL of Geofence instance;

Invocation example

GeoFence gf = new GeoFence("http://geofenceRestUrl/");

User section

getUserById(String id)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;

Invocation example

String id = ...;
GSUser user = gf.getUserById(id);
String userName = user.getName();

getUserByUsername(String userName)

Parameters List :

  • "userName" : [String value] It's the name of user you are looking for;

Invocation example

String userName = ...;
GSUser user = gf.getUserByUsername(userName);
String id = user.getId();

createUser(User user)

Parameters List :

  • "user" : [User value] It's the org.gcube.data.access.bean.User object you are creating;

Invocation example

User user = new User();
user.setExtId("id_1");
user.setName("test_1");
user.setPassword("test");
...
HttpStatus status = gf.createUser(user);

updateUser(User user)

Parameters List :

  • "user" : [User value] It's the org.gcube.data.access.bean.User object you are updating;

Invocation example

User user = new User();
user.setExtId("id_1");
user.setName("test_1");
user.setPassword("test_1");
user.setEmailAddress("test@email.com");
...
HttpStatus status = gf.updateUser(user);

updateUserById(String id, String password, String email, boolean admin, boolean enabled)

Parameters List :

  • "id" : [String value] It's the id of user;
  • "password" : [String value] It's the password of user.
  • "email" : [String value] It's the email of user.
  • "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
  • "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.

Invocation example

String id = ...;
HttpStatus status = gf.updateUserById(id, "new_pass", "test@email.com", false, false);

updateUserByUsername(String userName, String password, String email, boolean admin, boolean enabled)

Parameters List :

  • "userName" : [String value] It's the userName of user;
  • "password" : [String value] It's the password of user.
  • "email" : [String value] It's the email of user.
  • "admin" : [boolean value] It's the boolean flag to define if user is administrator or not.
  • "enabled" : [boolean value] It's the boolean flag to define if user is enabled or not.

Invocation example

String userName= ...;
HttpStatus status = gf.updateUserByUsername(userName, "new_pass", "test@email.com", true, true);

deleteUserById(String id, boolean removeAllRules)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;
  • "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;

Invocation example

String id = ...;
HttpStatus status = gf.deleteUserById(id, true);

deleteUserByUsername(String userName, boolean removeAllRules)

Parameters List :

  • "userName" : [String value] It's the userName of user you are looking for;
  • "removeAllRules" : [boolean value] It's a flag to remove all rules together to the user;

Invocation example

String userName = ...;
HttpStatus status = gf.deleteUserById(userName, false);

getUserList()

Invocation example

UserList userList = gf.getUserList();
List<Users> users = userList.getUsers();
int size = users.size();

UserGroup section

createUserGroup(UserGroup userGroup)

Parameters List :

  • "userGroup " : [UserGroup value] - It's the org.gcube.data.access.bean.UserGroup object you are creating.

Invocation example

UserGroup group = new UserGroup();
group.setExtId("ext_id_1");
group.setName("My group");
group.setDateCreation(new Date());
group.setEnabled(false);
HttpStatus status = gf.createUserGroup(group);

getUserGroupById(String id)

Parameters List :

  • "id" : [String value] It's the id of group you are looking for;

Invocation example

String id = ...;
Group g = gf.getUserGroupById(id);
String name = g.getName();

getUserGroupByName(String userName)

Parameters List :

  • "userName" : [String value] It's the userName of group you are looking for;

Invocation example

String userName = ...;
Group g = gf.getUserGroupByName(userName);
String id = g.getId();

updateUserGroup(Group group)

Parameters List :

  • "group" : [Group value] It's the Group object you are updating;

Invocation example

Group g =  ...
g.setEnabled(false);
HttpStatus status = gf.updateUserGroup(g);

updateUserGroupById(String id, boolean enabled)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;
  • "enabled" : [boolena value] It's the enabled flag of group;

Invocation example

String id =  ...	
HttpStatus status = gf.updateUserGroupById(id, true);

updateUserGroupByName(String name, boolean enabled)

Parameters List :

  • "id" : [String value] It's the userId of user you are looking for;
  • "enabled" : [boolena value] It's the enabled flag of group;

Invocation example

String name =  ...	
HttpStatus status = gf.updateUserGroupByName(name, true);