Spring Security UserDetails and username -


in current implementation have user entity implements org.springframework.security.core.userdetails.userdetails interface.

    @entity     @table(name = "users")     public class user extends baseentity implements userdetails {          private static final long serialversionuid = 8884184875433252086l;          @id         @generatedvalue(strategy = generationtype.auto)         private integer id;          private string username;          private string password;     .... 

during oauth2 authorization manually create new user object, populate fields , store in database.

according userdetails contract - userdetails.getusername() method can't return null have no values retrieved social networks can used username.

what value in case should returned in user.getusername() method ?

is okay return ?

@override public string getusername() {     return string.valueof(id); } 

if need save entity before have valid value name think that's problem design. having said user.getusername() used display purposes, doubt matters actual value is, long can matched in authentication.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -