You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by Korhonen Tommi <to...@thl.fi> on 2015/10/12 10:57:40 UTC

Generating username

Hello all,

Firstly, thanks for great software! Although some more documentation is still needed, I find syncope very intuitive to work with.

Is it possible to generate username during synchronization? I'd like to create a username based on user's firstname and lastname. The algorithm is a bit more complicated that e.g. concatenating first and last name and it includes testing if generated candidate for username already exists.  How can I get started with this?

Best Regards,
Tommi

Re: Generating username

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 12/10/2015 11:31, Francesco Chicchiriccò wrote:
> On 12/10/2015 10:57, Korhonen Tommi wrote:
>>
>> Hello all,
>>
>> Firstly, thanks for great software! Although some more documentation 
>> is still needed, I find syncope very intuitive to work with.
>>
>
> Thanks Tommi!
>
> We are aware that our documentation is really needing some special 
> effort, and we have started building new docs from scratch that will 
> be released alongside with 2.0.0
>
> You can find the current draft of next "getting started guide" here:
>
> http://ilgrosso.github.io/syncope2/getting-started.html
> http://ilgrosso.github.io/syncope2/getting-started.pdf
>
>> Is it possible to generate username during synchronization? I’d like 
>> to create a username based on user’s firstname and lastname. The 
>> algorithm is a bit more complicated that e.g. concatenating first and 
>> last name and it includes testing if generated candidate for username 
>> already exists.  How can I get started with this?
>>
>
> If you had simpler need, e.g. "concatenating first and last name" 
> (without further check) you could setup an user template for the given 
> sync task [1].
>
> Since you need to perform further checks, the most viable option is to 
> create a SyncActions [2] implementation where - most likely in the 
> beforeProvision() method - you can place such logic.
>
> Assuming that you are working with 1.2.5, you'll need to:
>
>  1. extend DefaultSyncActions [3]
>  2. override beforeProvision() and implement your logic there
>   2.1 you might need to autowire UserDAO (for checking the existing 
> username)
>   2.2 your purpose is to set ((UserTO) subject).setUsername()

Forgot to add: see [4] for a working sample.

> HTH
> Regards.
>
> [1] 
> https://cwiki.apache.org/confluence/display/SYNCOPE/Tasks#Tasks-SpecifyUserTemplate
> [2] https://cwiki.apache.org/confluence/display/SYNCOPE/SyncActionsClass
> [3] 
> https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/sync/DefaultSyncActions.java
> [4] 
> https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPPasswordSyncActions.java#L57-L68 


-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: Generating username

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 12/10/2015 10:57, Korhonen Tommi wrote:
>
> Hello all,
>
> Firstly, thanks for great software! Although some more documentation 
> is still needed, I find syncope very intuitive to work with.
>

Thanks Tommi!

We are aware that our documentation is really needing some special 
effort, and we have started building new docs from scratch that will be 
released alongside with 2.0.0

You can find the current draft of next "getting started guide" here:

http://ilgrosso.github.io/syncope2/getting-started.html
http://ilgrosso.github.io/syncope2/getting-started.pdf

> Is it possible to generate username during synchronization? I’d like 
> to create a username based on user’s firstname and lastname. The 
> algorithm is a bit more complicated that e.g. concatenating first and 
> last name and it includes testing if generated candidate for username 
> already exists.  How can I get started with this?
>

If you had simpler need, e.g. "concatenating first and last name" 
(without further check) you could setup an user template for the given 
sync task [1].

Since you need to perform further checks, the most viable option is to 
create a SyncActions [2] implementation where - most likely in the 
beforeProvision() method - you can place such logic.

Assuming that you are working with 1.2.5, you'll need to:

  1. extend DefaultSyncActions [3]
  2. override beforeProvision() and implement your logic there
   2.1 you might need to autowire UserDAO (for checking the existing 
username)
   2.2 your purpose is to set ((UserTO) subject).setUsername()

HTH
Regards.

[1] 
https://cwiki.apache.org/confluence/display/SYNCOPE/Tasks#Tasks-SpecifyUserTemplate
[2] https://cwiki.apache.org/confluence/display/SYNCOPE/SyncActionsClass
[3] 
https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/sync/DefaultSyncActions.java
[4] 
https://github.com/apache/syncope/blob/1_2_X/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPPasswordSyncActions.java#L57-L68

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/