Never Mind – Here is the code for searching user and converting to UserTO
SyncopeClient client = new
SyncopeClientFactoryBean().setAddress("http://localhost:9080/syncope/rest/")
.setUseCompression(true).setDomain("Master").setContentType(SyncopeClientFactoryBean.ContentType.JSON)
.create("admin", "password");
UserService userService = client.getService(UserService.class);
PagedResult<UserTO> matchingUsers = userService.search(new
AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM)
.fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo(userId).query()).build());
Just need to read docs..
Ref: https://ci.apache.org/projects/syncope/reference-guide.html#client-library
From: Ravindra Singareddy<mailto:[email protected]>
Sent: Monday, March 26, 2018 8:41 PM
To: [email protected]<mailto:[email protected]>
Subject: RE: User Search Based on UserName, email or Key(UUID) by admin user
Thanks Francesco, Users > GET /users/{key} works for key(UUID) and usernames.
We have usecase where user registers with email address, before registering
into system need to check, whether this email is already taken or not?
How do we get list of user(s) based on schema like “email”, “lastname” or any
other custom schema names?
I have tried with Get >
/users/{key}/{schemaType}/{schema}<http://localhost:9080/syncope/swagger/#!/95users/read_7>
http://localhost:9080/syncope/rest/users/email/PLAIN/abc%40xyz.com'
gives 404. But we have user exists with this email.
Thanks
Ravi
From: Francesco Chicchiriccò<mailto:[email protected]>
Sent: Monday, March 26, 2018 4:02 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: User Search Based on UserName, email or Key(UUID) by admin user
On 26/03/2018 07:14, Ravindra Singareddy wrote:
Hi All,
I need to read user by username, email or key(uuid) with the admin user. What
will be best approach?
I have used following code but giving "Could not find an Access Token for JWT
..” error
Are you able to access the Admin Console? If so, I don't see any reason why you
should get the error as above.
SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean()
.setAddress("http://localhost:9080/syncope/rest"<http://localhost:9080/syncope/rest>).setDomain("Master")
.setContentType(SyncopeClientFactoryBean.ContentType.JSON).setUseCompression(true);
SyncopeClient client = clientFactory.create("admin", "password");
UserService userService = client.getService(UserService.class);
UserTO userTO = userService.read("b4662c3c-3a7c-490c-a62c-3c3a7ca90c62");
Otherwise what will be the rest api to use for retrieving user data?
I'd suggest you to take a look at the Swagger UI, available under
/syncope/swagger/ if you have enabled it, under
Users > GET /users/{key}
Please note the "key" parameter description: "if value looks like a UUID then
it is interpreted as key, otherwise as a (user)name".
An example can be found at
http://syncope-vm.apache.org:9080/syncope/swagger/
HTH
Regards.
--
Francesco Chicchiriccò
Tirasa - Open Source Excellence
http://www.tirasa.net/
Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/