OIDCUserManager { public Principal updateUserInfo(BearerAccessToken accessToken) throws URISyntaxException, IOException, ParseException, OIDCException, XWikiException, QueryException { Principal principal = updateUserInfo(this.configuration.getUserInfoOIDCEndpoint(), this.configuration.getIdToken(), accessToken); this.configuration.resetUserInfoExpirationDate(); return principal; }  void updateUserInfoAsync(); void checkUpdateUserInfo(); Principal updateUserInfo(BearerAccessToken accessToken); Principal updateUserInfo(URI userInfoEndpoint, IDTokenClaimsSet idToken, BearerAccessToken accessToken); Principal updateUser(IDTokenClaimsSet idToken, UserInfo userInfo); Boolean syncXWikiGroupsMembership(String xwikiUserName, List<String> providerGroups, XWikiContext context); void logout();  }
@Test public void updateUserInfo() throws XWikiException, QueryException, OIDCException, ComponentLookupException, URISyntaxException { Issuer issuer = new Issuer("http: Subject subject = new Subject("subject"); IDTokenClaimsSet idToken = new IDTokenClaimsSet(issuer, subject, Collections.emptyList(), new Date(), new Date()); UserInfo userInfo = new UserInfo(subject); Address address = new Address(); address.setFormatted("address"); userInfo.setPreferredUsername("preferredUserName"); userInfo.setAddress(address); userInfo.setEmailAddress("mail@domain.com"); userInfo.setFamilyName("familyName"); userInfo.setGivenName("givenName"); userInfo.setPhoneNumber("phoneNumber"); userInfo.setLocale("fr"); userInfo.setZoneinfo("timezone"); userInfo.setWebsite(new URI("http: Map<String, Object> customClaim = new HashMap<>(); customClaim.put("customproperty1", "value"); customClaim.put("customproperty2", 42); customClaim.put("customproperty3", null); userInfo.setClaim("custom", customClaim); this.oldcore.getConfigurationSource().setProperty(OIDCClientConfiguration.PROP_USER_MAPPING, Arrays.asList("customproperty1=${oidc.user.custom.customproperty1:-}", "customproperty2=${oidc.user.custom.customproperty2:-}", "customproperty3=${oidc.user.custom.customproperty3:-}", "customproperty4=${oidc.user.custom.customproperty4:-}", "customproperty5=${notexistingpattern}")); BaseClass userClass = this.oldcore.getSpyXWiki().getUserClass(this.oldcore.getXWikiContext()); userClass.addTextField("customproperty1", "customproperty1", 30); userClass.addNumberField("customproperty2", "customproperty2", 30, "integer"); userClass.addTextField("customproperty3", "customproperty3", 30); userClass.addTextField("customproperty4", "customproperty4", 30); userClass.addTextField("customproperty5", "customproperty5", 30); XWikiDocument userClassDocument = this.oldcore.getSpyXWiki().getDocument(userClass.getDocumentReference(), this.oldcore.getXWikiContext()); userClassDocument.getXClass().apply(userClass, true); this.oldcore.getSpyXWiki().saveDocument(userClassDocument, this.oldcore.getXWikiContext()); Principal principal = this.manager.updateUser(idToken, userInfo); assertEquals("xwiki:XWiki.issuer-preferredUserName", principal.getName()); XWikiDocument userDocument = this.oldcore.getSpyXWiki().getDocument( new DocumentReference(this.oldcore.getXWikiContext().getWikiId(), "XWiki", "issuer-preferredUserName"), this.oldcore.getXWikiContext()); assertFalse(userDocument.isNew()); BaseObject userObject = userDocument.getXObject(userClass.getDocumentReference()); assertNotNull(userObject); assertEquals("address", userObject.getStringValue("address")); assertEquals("mail@domain.com", userObject.getStringValue("email")); assertEquals("familyName", userObject.getStringValue("last_name")); assertEquals("givenName", userObject.getStringValue("first_name")); assertEquals("phoneNumber", userObject.getStringValue("phone")); assertEquals("value", userObject.getStringValue("customproperty1")); assertEquals(42, userObject.getIntValue("customproperty2")); assertEquals("", userObject.getStringValue("customproperty3")); assertEquals("", userObject.getStringValue("customproperty4")); assertEquals("", userObject.getStringValue("customproperty5")); OIDCUser oidcObject = new OIDCUser(userDocument.getXObject(this.oidcClassReference)); assertNotNull(oidcObject); assertEquals("http: assertEquals("subject", oidcObject.getSubject()); }