You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by Ravindra Singareddy <si...@hotmail.com> on 2018/03/26 05:14:54 UTC
User Search Based on UserName, email or Key(UUID) by admin user
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
SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean()
.setAddress("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?
Thanks
Ravi
RE: User Search Based on UserName, email or Key(UUID) by admin user
Posted by Ravindra Singareddy <si...@hotmail.com>.
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<ma...@hotmail.com>
Sent: Monday, March 26, 2018 8:41 PM
To: user@syncope.apache.org<ma...@syncope.apache.org>
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ò<ma...@apache.org>
Sent: Monday, March 26, 2018 4:02 AM
To: user@syncope.apache.org<ma...@syncope.apache.org>
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/
RE: User Search Based on UserName, email or Key(UUID) by admin user
Posted by Ravindra Singareddy <si...@hotmail.com>.
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ò<ma...@apache.org>
Sent: Monday, March 26, 2018 4:02 AM
To: user@syncope.apache.org<ma...@syncope.apache.org>
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/
Re: User Search Based on UserName, email or Key(UUID) by admin user
Posted by Francesco Chicchiriccò <il...@apache.org>.
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").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/