Yes, you understand right.
I want to the check the user configured in the 
src\main\resources\security.properties, with java code.
Thank you for reply and expecting your help.

Best regards!

Yan Zhiying


From: Francesco Chicchiriccò [mailto:[email protected]]
Sent: Wednesday, April 03, 2013 6:37 PM
To: [email protected]
Subject: Re: How to check if the syncope service url and administrator username 
and password are correct?

On 03/04/2013 10:16, ZhiYing Yan wrote:

Hello,

I have a question.

I don't want to check the users defined in the Syncope. What I need to check is 
the administrator.

I need to check if user uses correct administrator username and password to 
access the rest API like http://localhost:9080/syncope/cxf/users .



Now I uses the following code:

Try{

                String url="http://localhost:9080/syncope/cxf";;

          String name="admin";

         String password="password";

           WebClient client = WebClient.create(url, 
Collections.singletonList(new JacksonJsonProvider()));

            String authorizationHeader = "Basic " + 
Base64Utility.encode((name+":"+password).getBytes());

            client.header("Authorization", authorizationHeader);



            client = client.path("/users/count");


    // throw exception here if url or name or pwd is wrong.
        client.accept("application/json").get(Integer.class);

} catch (ServerWebApplicationException e) {
            if (401 == e.getStatus()) {
                rc.setMessage("Username or password is not correct");
                rc.setOk(false);
           } else {
                rc.setMessage(e.getMessage());
                rc.setOk(false);
            }
} catch (ClientWebApplicationException e) {
            rc.setMessage(e.getMessage());
            rc.setOk(false);

}



is there a special url to access, for example 
http://localhost:9080/syncope/cxf/authentication, and  response with full 
information?

Now to access /users/count is workaround.



Could you help me?

Let me check if I've understood your question: do you want to check if the 
authenticated user corresponds to the admin user configured under 
core/src/main/resources/security.properties?


--

Francesco Chicchiriccò



ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member

http://people.apache.org/~ilgrosso/

Reply via email to