NOTE: Trivore ID Documentation has moved to https://trivoreid.com

The content on this site IS OUT OF DATE!

This space has been archived!

Please go ahead to the new site!

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Wrapper for the '/user' API. Contains most of the user operations except profile functions, as profile service is disabled when Management API is used.

NB! If user is assigned to a group name (memberOf) that doesn't exist, then the new group will be created.

List of all options:

  • Get all users
  • Get one/create/modify/delete user
  • Verify email/phone with code or link (primary ones)
  • Get/update/delete custom user fields (dictionary with any keys/values)
  • Get/update user enterprise
  • Get password requirements (min and max password length)

Initialize service

TrivoreID sdk = TrivoreID.mgmtApiClient();

UserServiceImpl userService = new UserServiceImpl(sdk.userService());

User management

// find first 5 users, whose first name is John
Criteria criteria = new Criteria();
criteria.setFilter(Filter.equal("name.firstName", "John"));
criteria.setCount(5);
criteria.setStartIndex(0);

Page<User> page = userService.getAll(criteria);

// create new user
Mobile mobile = new Mobile("+3584012345678");
mobile.setTags(Arrays.asList("tag1", "tag2"));

Email email1 = new Email("example@example.com");
email1.setTags(Arrays.asList("tag3", "tag4"));

Email email2 = new Email("example2@example.com");
email2.getTags().add("tag5");

Address address = new Address();
address.setCountry("Country");
address.setLocality("FI");
address.setPostalCode("12345");
address.setRegion("Region");
address.setStreetAddress("Street Address");

Name name = new Name();
name.setFamilyName("Smith");
name.setMiddleName("Jr.");
name.setGivenName("John");

Consents consents = new Consents();
consents.setLocationing(true);
consents.setMarketingEmail(true);

User user = new User();
user.setNsCode("example");
user.setEmails(new LinkedHashSet<>(Arrays.asList(email1, email2)));
user.getMobiles().add(mobile);
user.getAddresses().add(address);
user.setName(name);
user.setUserAccountType(AccountType.PERSON);
user.setConsents(consents);

// memberOf should contain group ID. They will be checked, and if group ID doesn't exist, then
// this value will be replaced for it's id. If group name doesn't exist, then it will be created.
user.setMemberOf(new HashSet<>(Arrays.asList("group1", "group2")));

user = userService.create(user); // this will return new user with the generated ID

// get user by ID
User newUser = userService.get(user.getId());

// modify user
newUser.getMobiles().add(new Mobile("+3584012345689"));
userService.update(newUser);

// delete user
userService.delete(newUser.getId());

Email / Mobile verification

String userId = user.getId();
String returnUrl = "<return-link>";
int expirationDays = 5;

// send email verification link
userService.sendEmailVerification(userId);

// with the return URL and expiration days
userService.sendEmailVerification(userId, returnUrl, expirationDays);

// Send phone number verification link
userService.sendPhoneNumberVerificationLink(userId);

// with the return URL and expiration days
userService.sendPhoneNumberVerificationLink(userId, returnUrl, expirationDays);

// send phone number verification code
userService.sendPhoneNumberVerification(userId);

// after the code was received, the phone number can be verified with
String code = "<received-code>";
userService.checkPhoneNumberVerificationCode(userId, code);

CustomĀ user fields

CustomFieldsClass fields = userService.getCustomFields(userId, CustomFieldsClass.class);
fields.setField("example value");

// updating 
userService.updateCustomFields(userId, fields);

// clearing user's custom fields
userService.deleteCustomFields(userId);

Enterprise

// get and update the enterprice
Enterprise enterprise = userService.getEnterprise(userId);

enterprise.setBusinessId("businessId");
enterprise.setTradeName("Trade Name");

userService.saveEnterprise(userId, enterprise);

Password requirements

// this will return password requiremens for the namespace that user belongs to.
PasswordComplexity requirements = userService.getPasswordComplexity(userId);

Migrate namespace

// migrate user to another namespace
UserNamespaceMigrationOptions options = new UserNamespaceMigrationOptions();
options.setTargetNsCode("exampleNsCode");
options.setKeepEmails(false);

// this will create groups in the target namespace if they do not exist
options.setKeepGroups(true);

userService.migrateNamespace(userId, options);

Legal info

// Get the legal info of the user (legal info cannot be modified)
LegalInfo info = userService.getLegalInfo(userId);

Student state

// Get and update the user's student state info
StudentStateInfo info = userService.getStudentInfo(userId);

userService.updateStudentInfo(userId, info);

User Service Models

/wiki/spaces/TISpubdoc/pages/20515245

/wiki/spaces/TISpubdoc/pages/20515276

Names

Mobile

/wiki/spaces/TISpubdoc/pages/20515250

/wiki/spaces/TISpubdoc/pages/20515251

/wiki/spaces/TISpubdoc/pages/20515255

/wiki/spaces/TISpubdoc/pages/20515262

/wiki/spaces/TISpubdoc/pages/20515256

/wiki/spaces/TISpubdoc/pages/20515252

/wiki/spaces/TISpubdoc/pages/75825224

/wiki/spaces/TISpubdoc/pages/85491757

/wiki/spaces/TISpubdoc/pages/88277051

  • No labels