You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by German Parente <ge...@usharesoft.com> on 2013/04/22 17:11:09 UTC

Syncope java api examples.

Hi all,

I am new to the product. I am intesting in using the Apache Syncope java 
api.

I am looking to simple examples about creating roles, assigning them to 
users and retrieving the information of users and roles.

I couldn't find that in your site.

Could you please send me pointers to some snippets as possible ?

Thanks a lot and regards,

German.


Re: Syncope java api examples.

Posted by German Parente <ge...@usharesoft.com>.
Hi Francesco,

Thanks a lot ! I will take a look at them.

Regards,

German

> On 22/04/2013 17:11, German Parente wrote:
>> Hi all,
>>
>> I am new to the product. I am intesting in using the Apache Syncope 
>> java api.
>>
>> I am looking to simple examples about creating roles, assigning them 
>> to users and retrieving the information of users and roles.
>>
>> I couldn't find that in your site.
>>
>> Could you please send me pointers to some snippets as possible?
>
> Unfortunately, such documentation is not yet available in a proper 
> format (but it is on the roadmap...)
>
> For the moment the best option is to take a look at the integration 
> tests' sources: users [1] / roles [2].
>
> Regards.
>
> [1] 
> http://svn.apache.org/repos/asf/syncope/tags/syncope-1.1.0/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
> [2] 
> http://svn.apache.org/repos/asf/syncope/tags/syncope-1.1.0/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
>


Re: Syncope java api examples.

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 22/04/2013 17:11, German Parente wrote:
> Hi all,
>
> I am new to the product. I am intesting in using the Apache Syncope 
> java api.
>
> I am looking to simple examples about creating roles, assigning them 
> to users and retrieving the information of users and roles.
>
> I couldn't find that in your site.
>
> Could you please send me pointers to some snippets as possible?

Unfortunately, such documentation is not yet available in a proper 
format (but it is on the roadmap...)

For the moment the best option is to take a look at the integration 
tests' sources: users [1] / roles [2].

Regards.

[1] 
http://svn.apache.org/repos/asf/syncope/tags/syncope-1.1.0/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
[2] 
http://svn.apache.org/repos/asf/syncope/tags/syncope-1.1.0/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java

-- 
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


Re: Question about deployment / java api vs. rest services

Posted by Nik <ni...@usharesoft.com>.
cool - thanks Fabio.

Nik
> On 07/05/2013 14:04, Nik wrote:
>> Hi Fabio,
>>
>> One further question I would like to ask wrt to this subject is.
>> How can I execute a db export from a CLI?
>>
>> I have tried the following using syncope-standalone-1.1.1:
>>
>> [nik@anvil apache-tomcat-7.0.39]$ curl -u admin:password -H 
>> "Content-Type: application/json" -X GET 
>> http://10.0.0.123:9080/syncope/cxf/configurations/dbDump
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <configuration>
>>     <key>dbDump</key>
>> </configuration>
>> [nik@anvil apache-tomcat-7.0.39]$
>>
>> without seeing any db xml output equivalent to the console export in 
>> a content.xml.
>
> Take a look at [2] for how to deal with internal storage import / 
> export and [3] for how to export via CLI.
>
> I have also fixed [4] for CXF export; in your case:
>
> curl -u admin:password -H "Content-Type: application/json" -X GET 
> http://10.0.0.123:9080/syncope/cxf/configurations/stream
>
> Regards.
>
>>> Hi German, please find my answers in-line.
>>>
>>> Il 06/05/2013 12:01, German Parente ha scritto:
>>>>
>>>> Hi all,
>>>>
>>>> my managers want me to implement the scenario I will describe. I 
>>>> will need some help to know how to address it.
>>>>
>>>> I have an application which basically consists in a REST web 
>>>> service. I have been asked to implement rbac feature to users 
>>>> connecting to the web service. The application is running in a 
>>>> virtual machine that is delivered to each customer asking for the 
>>>> product.
>>>>
>>>> Precise questions:
>>>>
>>>> 1) I will have to deploy syncope in the virtual machine for each 
>>>> customer using the product. Customer is not  supposed to use the 
>>>> console but an application must do the full initialization:
>>>>
>>>> - cleaning default stuff (users/roles, etc).
>>> You can avoid this step working onto the file 
>>> core/src/main/resources/content.xml.
>>> This file specifies the content that have to be loaded at first db 
>>> initialization.
>>> At startup time, Apache Syncope checks for syncope db tables: if no 
>>> content is found the content.xml file will be used to create the 
>>> default content.
>>>
>>> You can create your own content.xml file by configuring and 
>>> exporting your default content via console:
>>> 1. deploy syncope (or start in embedded mode)
>>> 2. make your configuration via console
>>> 3. export the configuration via console (main tab Configuration)
>>>> - creating resource and connectors
>>>> - configure them
>>>> - add users in the IDM from backend by reconciliation or 
>>>> synchronization.
>>>>
>>>> All initializing steps must be done by an application.
>>>>
>>>> Is there any example of how to do this ? A full configuration done 
>>>> from scratch where I could see how to achieve this ?
>>> As far as I remember it shouldn't exist any example of how to do this.
>>> You can take a look at integration tests [1]: looking into these 
>>> pieces of code you should be able to create your own configuration 
>>> application.
>>>>
>>>> Would it be better to use java api or rest interface ?
>>> REST API.
>>>>
>>>> 2) I have to address from my application the RBAC module getting 
>>>> user roles from syncope.
>>>>
>>>> Again, what would be the best approach ? Use java api or bare rest 
>>>> request calls ?
>>> REST calls are the right way to do this.
>>>>
>>>> Thanks a lot in advance,
>>>>
>>>> German
>>>
>>> [1] 
>>> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/
>
> [2] 
> https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=31819687
> [3] 
> https://cwiki.apache.org/confluence/display/SYNCOPE/Calling+RESTful+services+from+CLI#CallingRESTfulservicesfromCLI-Exportdatabasecontent
> [4] 
> https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade#RESTAPIupgrade-ConfigurationService
>


Re: Question about deployment / java api vs. rest services

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 07/05/2013 14:04, Nik wrote:
> Hi Fabio,
>
> One further question I would like to ask wrt to this subject is.
> How can I execute a db export from a CLI?
>
> I have tried the following using syncope-standalone-1.1.1:
>
> [nik@anvil apache-tomcat-7.0.39]$ curl -u admin:password -H 
> "Content-Type: application/json" -X GET 
> http://10.0.0.123:9080/syncope/cxf/configurations/dbDump
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <configuration>
>     <key>dbDump</key>
> </configuration>
> [nik@anvil apache-tomcat-7.0.39]$
>
> without seeing any db xml output equivalent to the console export in a 
> content.xml.

Take a look at [2] for how to deal with internal storage import / export 
and [3] for how to export via CLI.

I have also fixed [4] for CXF export; in your case:

curl -u admin:password -H "Content-Type: application/json" -X GET 
http://10.0.0.123:9080/syncope/cxf/configurations/stream

Regards.

>> Hi German, please find my answers in-line.
>>
>> Il 06/05/2013 12:01, German Parente ha scritto:
>>>
>>> Hi all,
>>>
>>> my managers want me to implement the scenario I will describe. I 
>>> will need some help to know how to address it.
>>>
>>> I have an application which basically consists in a REST web 
>>> service. I have been asked to implement rbac feature to users 
>>> connecting to the web service. The application is running in a 
>>> virtual machine that is delivered to each customer asking for the 
>>> product.
>>>
>>> Precise questions:
>>>
>>> 1) I will have to deploy syncope in the virtual machine for each 
>>> customer using the product. Customer is not  supposed to use the 
>>> console but an application must do the full initialization:
>>>
>>> - cleaning default stuff (users/roles, etc).
>> You can avoid this step working onto the file 
>> core/src/main/resources/content.xml.
>> This file specifies the content that have to be loaded at first db 
>> initialization.
>> At startup time, Apache Syncope checks for syncope db tables: if no 
>> content is found the content.xml file will be used to create the 
>> default content.
>>
>> You can create your own content.xml file by configuring and exporting 
>> your default content via console:
>> 1. deploy syncope (or start in embedded mode)
>> 2. make your configuration via console
>> 3. export the configuration via console (main tab Configuration)
>>> - creating resource and connectors
>>> - configure them
>>> - add users in the IDM from backend by reconciliation or 
>>> synchronization.
>>>
>>> All initializing steps must be done by an application.
>>>
>>> Is there any example of how to do this ? A full configuration done 
>>> from scratch where I could see how to achieve this ?
>> As far as I remember it shouldn't exist any example of how to do this.
>> You can take a look at integration tests [1]: looking into these 
>> pieces of code you should be able to create your own configuration 
>> application.
>>>
>>> Would it be better to use java api or rest interface ?
>> REST API.
>>>
>>> 2) I have to address from my application the RBAC module getting 
>>> user roles from syncope.
>>>
>>> Again, what would be the best approach ? Use java api or bare rest 
>>> request calls ?
>> REST calls are the right way to do this.
>>>
>>> Thanks a lot in advance,
>>>
>>> German
>>
>> [1] 
>> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/

[2] 
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=31819687
[3] 
https://cwiki.apache.org/confluence/display/SYNCOPE/Calling+RESTful+services+from+CLI#CallingRESTfulservicesfromCLI-Exportdatabasecontent
[4] 
https://cwiki.apache.org/confluence/display/SYNCOPE/REST+API+upgrade#RESTAPIupgrade-ConfigurationService

-- 
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


Re: Question about deployment / java api vs. rest services

Posted by Nik <ni...@usharesoft.com>.
Hi Fabio,

One further question I would like to ask wrt to this subject is.
How can I execute a db export from a CLI?

I have tried the following using syncope-standalone-1.1.1:

[nik@anvil apache-tomcat-7.0.39]$ curl -u admin:password -H 
"Content-Type: application/json" -X GET 
http://10.0.0.123:9080/syncope/cxf/configurations/dbDump
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
     <key>dbDump</key>
</configuration>
[nik@anvil apache-tomcat-7.0.39]$

without seeing any db xml output equivalent to the console export in a 
content.xml.

rgds,
Nik
> Hi German, please find my answers in-line.
>
> Il 06/05/2013 12:01, German Parente ha scritto:
>>
>> Hi all,
>>
>> my managers want me to implement the scenario I will describe. I will 
>> need some help to know how to address it.
>>
>> I have an application which basically consists in a REST web service. 
>> I have been asked to implement rbac feature to users connecting to 
>> the web service. The application is running in a virtual machine that 
>> is delivered to each customer asking for the product.
>>
>> Precise questions:
>>
>> 1) I will have to deploy syncope in the virtual machine for each 
>> customer using the product. Customer is not  supposed to use the 
>> console but an application must do the full initialization:
>>
>> - cleaning default stuff (users/roles, etc).
> You can avoid this step working onto the file 
> core/src/main/resources/content.xml.
> This file specifies the content that have to be loaded at first db 
> initialization.
> At startup time, Apache Syncope checks for syncope db tables: if no 
> content is found the content.xml file will be used to create the 
> default content.
>
> You can create your own content.xml file by configuring and exporting 
> your default content via console:
> 1. deploy syncope (or start in embedded mode)
> 2. make your configuration via console
> 3. export the configuration via console (main tab Configuration)
>> - creating resource and connectors
>> - configure them
>> - add users in the IDM from backend by reconciliation or 
>> synchronization.
>>
>> All initializing steps must be done by an application.
>>
>> Is there any example of how to do this ? A full configuration done 
>> from scratch where I could see how to achieve this ?
> As far as I remember it shouldn't exist any example of how to do this.
> You can take a look at integration tests [1]: looking into these 
> pieces of code you should be able to create your own configuration 
> application.
>>
>> Would it be better to use java api or rest interface ?
> REST API.
>>
>> 2) I have to address from my application the RBAC module getting user 
>> roles from syncope.
>>
>> Again, what would be the best approach ? Use java api or bare rest 
>> request calls ?
> REST calls are the right way to do this.
>>
>> Thanks a lot in advance,
>>
>> German
>
> [1] 
> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/
>


Re: Question about deployment / java api vs. rest services

Posted by German Parente <ge...@usharesoft.com>.
Hi Francesco,

Thanks for your answer.

I will take a look at that.

Regards,

German. 

On May 15, 2013, at 9:19, Francesco Chicchiriccò <il...@apache.org> wrote:

> On 14/05/2013 18:04, German Parente wrote:
>> Hi Fabio and all,
>> 
>>>> 2) I have to address from my application the RBAC module getting
>>>> user roles from syncope.
>>>> 
>>>> Again, what would be the best approach ? Use java api or bare rest
>>>> request calls ?
>>> REST calls are the right way to do this.
>> 
>> I am trying to use REST calls to get syncope users and roles
>> information from a web service.
>> 
>> To do that, I need to include syncope-common-1.1.1.jar, where I can
>> find objects like UserTO / RoleTO, etc.
>> 
>> The problem is that this jar is including also services sources which
>> are in conflict with my war file. I would need only "client" side of
>> the sources or at least, only the "to" objects.
>> 
>> Which would be the right way to access to users and roles information
>> ? Is there a sort of "only client" jar which I could include in my
>> application to get the required information ?
> 
> Hi German,
> I have prepared a simple Syncope client project on github [2], which
> turns useful for testing: you can check from there a working client setup.
> Please be aware that:
> 1. the SYNCOPE_1_1_X branch is meant to work with Apache Syncope 1.1.X
> 2. you might need to adjust dependency versions in the POM file
> 3. the class to look at is App.java: there you can choose whether use
> Spring-based or CXF-based initialization
> 
> HTH
> Regards.
> 
>>> [1]
>>> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/
> [2] https://github.com/ilgrosso/syncopeRestClient
> 
> -- 
> Francesco Chicchiriccò
> 
> ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
> http://people.apache.org/~ilgrosso/
> 
> 

Re: Question about deployment / java api vs. rest services

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 14/05/2013 18:04, German Parente wrote:
> Hi Fabio and all,
>
>>> 2) I have to address from my application the RBAC module getting
>>> user roles from syncope.
>>>
>>> Again, what would be the best approach ? Use java api or bare rest
>>> request calls ?
>> REST calls are the right way to do this.
>
> I am trying to use REST calls to get syncope users and roles
> information from a web service.
>
> To do that, I need to include syncope-common-1.1.1.jar, where I can
> find objects like UserTO / RoleTO, etc.
>
> The problem is that this jar is including also services sources which
> are in conflict with my war file. I would need only "client" side of
> the sources or at least, only the "to" objects.
>
> Which would be the right way to access to users and roles information
> ? Is there a sort of "only client" jar which I could include in my
> application to get the required information ?

Hi German,
I have prepared a simple Syncope client project on github [2], which
turns useful for testing: you can check from there a working client setup.
Please be aware that:
 1. the SYNCOPE_1_1_X branch is meant to work with Apache Syncope 1.1.X
 2. you might need to adjust dependency versions in the POM file
 3. the class to look at is App.java: there you can choose whether use
Spring-based or CXF-based initialization

HTH
Regards.

>> [1]
>> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/
[2] https://github.com/ilgrosso/syncopeRestClient

-- 
Francesco Chicchiriccò

ASF Member, Apache Syncope PMC chair, Apache Cocoon PMC Member
http://people.apache.org/~ilgrosso/


Re: Question about deployment / java api vs. rest services

Posted by German Parente <ge...@usharesoft.com>.
Hi Fabio and all,

>> 2) I have to address from my application the RBAC module getting user 
>> roles from syncope.
>>
>> Again, what would be the best approach ? Use java api or bare rest 
>> request calls ?
> REST calls are the right way to do this.

I am trying to use REST calls to get syncope users and roles information 
from a web service.

To do that, I need to include syncope-common-1.1.1.jar, where I can find 
objects like UserTO / RoleTO, etc.

The problem is that this jar is including also services sources which 
are in conflict with my war file. I would need only "client" side of the 
sources or at least, only the "to" objects.

Which would be the right way to access to users and roles information ? 
Is there a sort of "only client" jar which I could include in my 
application to get the required information ?

Thanks a lot,

German.



>>
>> Thanks a lot in advance,
>>
>> German
>
> [1] 
> http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/
>


Re: Question about deployment / java api vs. rest services

Posted by Fabio Martelli <fa...@gmail.com>.
Hi German, please find my answers in-line.

Il 06/05/2013 12:01, German Parente ha scritto:
>
> Hi all,
>
> my managers want me to implement the scenario I will describe. I will 
> need some help to know how to address it.
>
> I have an application which basically consists in a REST web service. 
> I have been asked to implement rbac feature to users connecting to the 
> web service. The application is running in a virtual machine that is 
> delivered to each customer asking for the product.
>
> Precise questions:
>
> 1) I will have to deploy syncope in the virtual machine for each 
> customer using the product. Customer is not  supposed to use the 
> console but an application must do the full initialization:
>
> - cleaning default stuff (users/roles, etc).
You can avoid this step working onto the file 
core/src/main/resources/content.xml.
This file specifies the content that have to be loaded at first db 
initialization.
At startup time, Apache Syncope checks for syncope db tables: if no 
content is found the content.xml file will be used to create the default 
content.

You can create your own content.xml file by configuring and exporting 
your default content via console:
1. deploy syncope (or start in embedded mode)
2. make your configuration via console
3. export the configuration via console (main tab Configuration)
> - creating resource and connectors
> - configure them
> - add users in the IDM from backend by reconciliation or synchronization.
>
> All initializing steps must be done by an application.
>
> Is there any example of how to do this ? A full configuration done 
> from scratch where I could see how to achieve this ?
As far as I remember it shouldn't exist any example of how to do this.
You can take a look at integration tests [1]: looking into these pieces 
of code you should be able to create your own configuration application.
>
> Would it be better to use java api or rest interface ?
REST API.
>
> 2) I have to address from my application the RBAC module getting user 
> roles from syncope.
>
> Again, what would be the best approach ? Use java api or bare rest 
> request calls ?
REST calls are the right way to do this.
>
> Thanks a lot in advance,
>
> German

[1] 
http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.1/core/src/test/java/org/apache/syncope/core/rest/

Question about deployment / java api vs. rest services

Posted by German Parente <ge...@usharesoft.com>.
Hi all,

my managers want me to implement the scenario I will describe. I will 
need some help to know how to address it.

I have an application which basically consists in a REST web service. I 
have been asked to implement rbac feature to users connecting to the web 
service. The application is running in a virtual machine that is 
delivered to each customer asking for the product.

Precise questions:

1) I will have to deploy syncope in the virtual machine for each 
customer using the product. Customer is not  supposed to use the console 
but an application must do the full initialization:

- cleaning default stuff (users/roles, etc).
- creating resource and connectors
- configure them
- add users in the IDM from backend by reconciliation or synchronization.

All initializing steps must be done by an application.

Is there any example of how to do this ? A full configuration done from 
scratch where I could see how to achieve this ?

Would it be better to use java api or rest interface ?


2) I have to address from my application the RBAC module getting user 
roles from syncope.

Again, what would be the best approach ? Use java api or bare rest 
request calls ?



Thanks a lot in advance,

German.