You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by ilgrosso <il...@apache.org> on 2016/04/26 12:56:13 UTC

Re: Getting 500 when I try to Authorize an user from syncope database

srikanth.april30 wrote
> Hi Syncope Team,
> 
> I am working on a requirement where I need to authorize a user with
> syncope database, means validate the user with the syncope database and
> send a response as authorized user or not. By using a Java Client I have
> to achieve this. My current environment is below: 
> 
> 1.) Apache Syncope-2.0.0-M2.
> 2.) MySql
> 3.) Java 1.8
> 4.) Tomcat 8
> 5.) Ubuntu Operating System.
> 
> So far I have installed Syncope-2.0.0-M2 using
> syncope-installer-2.0.0-M2-uber.jar file and able to configure MySql
> database and created two users and roles in syncope. Syncope is running at
> http://localhost:8080/syncope-console/ in my local system. So far I have
> created a Java client and was able to connect to syncope and was able to
> fetch all users.
> Using the URL "http://localhost:8080/syncope/rest/users" I was able to
> connect to syncope from Java Client and getting a list of all users as
> response. 
> 
> But what now I need is when I am trying the URL
> http://localhost:8080/syncope/rest/users/search?_s=surname==smith 
> and search for a particular user the response is getting as below: 
> 
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <syncope:error xmlns:syncope="http://syncope.apache.org/2.0">
> <elements>
> <element>
> NullPointerException: 
> </element>
> </elements>
> <status>
> 500
> </status>
> <type>
> Unknown
> </type>
> </syncope:error>
> Am I not using the right URL or is there is any mistake in the URL? Any
> help would be much useful for me ?
> 
> Thanks
> Srikanth

Hi Srikanth,
related to your example above, the URL should have been

http://localhost:8080/syncope/rest/users/search?fiql=surname%3D%3Dsmith

This should work.

In case you are running the query against Syncope from Java, I would suggest
to empower the Java SyncopeClient library which provides several goodies to
simplify your work.

The query above can be obtained, for example, by the following Java code

SyncopeClient syncopeClient = new SyncopeClientFactoryBean().
        setAddress("http://localhost:8080/syncope/rest/").
        create("admin", "password");
UserService service = syncopeClient.getService(UserService.class);

service.search(new AnySearchQuery.Builder().fiql(
SyncopeClient.getUserSearchConditionBuilder().is("surname").equalTo("smith").query()).
build());

This requires the sole Maven dependency:

    <dependency>
      <groupId>org.apache.syncope.client</groupId>
      <artifactId>syncope-client-lib</artifactId>
      <version>2.0.0-M2</version>
    </dependency>

HTH
Regards.

--
View this message in context: http://syncope-user.1051894.n5.nabble.com/Getting-500-when-I-try-to-Authorize-an-user-from-syncope-database-tp5708417p5708423.html
Sent from the syncope-user mailing list archive at Nabble.com.

Re: Getting 500 when I try to Authorize an user from syncope database

Posted by ilgrosso <il...@apache.org>.
srikanth.april30 wrote
> Thanks  ilgrosso for your reply.
> I have already sent a subscription request to user@syncope.apache.org.
> Waiting for the approval.

There is no approval: first you sent a request, then the system replies with
an e-mail where it says how to confirm such a request; normally, just
replying to this e-mail will finally subscribe you.


srikanth.april30 wrote
> On your reply for token and tokenExipreTime fields:
> Sorry I am not clear about your answer. Could you please explain a bit
> more on how can I populate values into these fields (token and
> tokenExpireTime) through syncope-console User Interface?

You cannot.
Such values are meant to be manipulated by workflow actions.
This happens, for example, for double opt-in and password reset.

Regards.

--
View this message in context: http://syncope-user.1051894.n5.nabble.com/Getting-500-when-I-try-to-Authorize-an-user-from-syncope-database-tp5708417p5708427.html
Sent from the syncope-user mailing list archive at Nabble.com.

Re: Getting 500 when I try to Authorize an user from syncope database

Posted by ilgrosso <il...@apache.org>.
Hi,
I see you are still not subscribing to the mailing list, so one can only see
that you are posting by visiting Nabble. Which does not happen often, at
least for me.
Please subscribe, it's fairly easy.


srikanth.april30 wrote
> Thanks  ilgrosso for your reply. I have integrated the example code that
> you have given and it's working fine. But I have a question here....
> When I checked the rest api at this below url 
> https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade#RESTAPIupgrade-UserService
> 
> and could see that under User Service CRUD operations table, having a new
> URL GET /users?username={username} 
> which returns a single user matching the provided username. I have tried
> this but could see all the users are returning as response. In my example
> i have used like below 
> http://localhost:8080/syncope/rest/users?username={administrator}
> or 
> http://localhost:8080/syncope/rest/users?username=administrator. 
> Am I doing any wrong here ? Could  you please correct me ? 

The wiki page you mention above is about upgrading REST API from Syncope 1.0
to Syncope 1.1.
You are running 2.0.0-M2, so that page is clearly not applicable.

The full REST documentation for last stable version (2.0.0-M2 currently) is
available at

http://syncope.apache.org/rest/2.0/index.html

Please check there.


srikanth.april30 wrote
> Also I have one more question on User token and tokenExpireTime creation
> fields while creating user. When I logging into syncope-console UI and
> creating user I could see two columns with names token and
> tokenExpireTime, but not able to enter values into these fields. Could you
> please help me out on how can I populate values into these columns?

Such fields are there for internal usage, whenever it is required to set a
random, time-limited, value for users - say double opt-in, password reset,
...
In general, things that you control from workflow.

HTH
Regards.

--
View this message in context: http://syncope-user.1051894.n5.nabble.com/Getting-500-when-I-try-to-Authorize-an-user-from-syncope-database-tp5708417p5708425.html
Sent from the syncope-user mailing list archive at Nabble.com.