You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Cemo <ce...@gmail.com> on 2012/11/25 16:22:59 UTC
Custom Subjects
Hi,
I am trying to learn Shiro. I want to port a legacy application to Shiro.
Legacy application has a User Entity. In order to port application to Shiro
what I have in my mind is extending WebDelegatingSubject as this:
public class User extends WebDelegatingSubject {
> private Integer id;
>
> @NotNull
> @Length(min = 4, max = 16)
> @IsLegalUsername
> @IsUsernameExists
> private String username;
>
> private String email;
>
> private String password;
>
> private Date birthday;
>
> // getter setter .....
}
What are the steps the provide a custom Subject? Or I should do something
else?
Thanks
Re: Custom Subjects
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
You can just define a single principal to be whatever object you want.
It can contain whatever user properties you may desire.
On Nov 25, 2012, at 5:27 PM, Cemo wrote:
> It seems that I should use multiple principals. UserId for primary principal and User Entity for secondary.
>
> Thanks
>
> On 26 November 2012 00:07, Cemo <ce...@gmail.com> wrote:
> Ok, I have read entire documentation and also instead of using ini file I have implemented necessary programmatic configuration implementation entirely via getters and setters.
>
> But It still is not clear for me why I should not extend WebDelegatingSubject and instead I should use custom Realm. AuthenticationInfo data fetched from Realm is not stored at WebDelegatingSubject as far as I know. Even if my realm provides AuthenticationInfo data with necessary fields I can not access them from my Subject.
>
> It seems that I am missing something.
>
> Any help?
>
Re: Custom Subjects
Posted by Cemo <ce...@gmail.com>.
It seems that I should use multiple principals. UserId for primary
principal and User Entity for secondary.
Thanks
On 26 November 2012 00:07, Cemo <ce...@gmail.com> wrote:
> Ok, I have read entire documentation and also instead of using ini file I
> have implemented necessary programmatic configuration implementation
> entirely via getters and setters.
>
> But It still is not clear for me why I should not extend
> WebDelegatingSubject and instead I should use custom Realm.
> AuthenticationInfo data fetched from Realm is not stored at
> WebDelegatingSubject as far as I know. Even if my realm provides
> AuthenticationInfo data with necessary fields I can not access them from my
> Subject.
>
> It seems that I am missing something.
>
> Any help?
>
Re: Custom Subjects
Posted by Cemo <ce...@gmail.com>.
Ok, I have read entire documentation and also instead of using ini file I
have implemented necessary programmatic configuration implementation
entirely via getters and setters.
But It still is not clear for me why I should not extend
WebDelegatingSubject and instead I should use custom Realm.
AuthenticationInfo data fetched from Realm is not stored at
WebDelegatingSubject as far as I know. Even if my realm provides
AuthenticationInfo data with necessary fields I can not access them from my
Subject.
It seems that I am missing something.
Any help?
On 25 November 2012 17:35, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> This is all in documentation:
> http://shiro.apache.org/realm.html
Re: Custom Subjects
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
This is all in documentation:
http://shiro.apache.org/realm.html
On Nov 25, 2012, at 10:31 AM, Cemo wrote:
> Could you explain that where I will store necessary information such as birthday, email etc? And please note that there is a validation process for User which is utilizing annotations on fields.
>
> On 25 November 2012 17:25, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> I think you should provide a custom Realm, not a Subject.
>
Re: Custom Subjects
Posted by Cemo <ce...@gmail.com>.
Could you explain that where I will store necessary information such as
birthday, email etc? And please note that there is a validation process for
User which is utilizing annotations on fields.
On 25 November 2012 17:25, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> I think you should provide a custom Realm, not a Subject.
Re: Custom Subjects
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I think you should provide a custom Realm, not a Subject.
On Nov 25, 2012, at 10:22 AM, Cemo wrote:
> Hi,
>
> I am trying to learn Shiro. I want to port a legacy application to Shiro. Legacy application has a User Entity. In order to port application to Shiro what I have in my mind is extending WebDelegatingSubject as this:
>
>
> public class User extends WebDelegatingSubject {
> private Integer id;
>
> @NotNull
> @Length(min = 4, max = 16)
> @IsLegalUsername
> @IsUsernameExists
> private String username;
>
> private String email;
>
> private String password;
>
> private Date birthday;
>
> // getter setter .....
> }
>
>
> What are the steps the provide a custom Subject? Or I should do something else?
>
> Thanks