On 08/04/2013 04:29, ZhiYing Yan wrote:
>
> 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.
>

Please take a look at EntitlementService#getMyEntitlements() [1], mapped
by CXF to

GET /entitlements/own

(see [2] for more details).

admin user, in fact, has assigned all defined entitlements (obtained via
GET /entitelements).

admin user is not a real user (stored into the SyncopeUser table), but a
virtual user only for administration purpose.

HTH
Regards.

[1]
https://svn.apache.org/repos/asf/syncope/branches/1_1_X/common/src/main/java/org/apache/syncope/common/services/EntitlementService.java
[2]
https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade#RESTAPIupgrade-EntitlementService

> *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