/
User Service (java)

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!

User Service (java)

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)

  • Get user's legal info

  • Migrate user to other namespace

  • Change password

  • Get/update custom permission

  • Get/update builtin and custom roles

  • Get/report strong identification

  • Get/update student info

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

Enterprise

Password requirements

Migrate namespace

Legal info

Student state

User Service Models

User

EmailAddress

Name

MobileNumber

Address

Consents

CustomerGroupInfo

Invite

StrongIdentification

PasswordUpdateResult

UserNamespaceMigrationOptions

LegalInfo

StudentStateInfo

Related content

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

The content on this site IS OUT OF DATE!

This space has been archived!