Can you use your Stormpath group object(i.e. ADMIN) as a class in your Spring Boot application? I mean, I want to keep some state of this object and I do not want to keep a correspondent POJO, which would have the ADMIN's email and password, plus another data like a gender/birthday, but simply have the whole state and behaviour in a instance of the stormpath group ADMIN.
Can this be achieved?
When you say use your Stormpath group object 'as a class', I assume you mean 'as a Spring bean'? If so, then most definitely!
For example:
Then, elsewhere in your Spring config you can use
adminGroup()to reference the group (in the save Java configuration class file). Or, if you want to reference the Group as a bean in other Java configuration classes or @Component beans, just autowire it:However, if you define more than one
Groupbean in your Spring Java config (maybe other groups? likeusersoremployees?), then you'll need a@Qualifierwhen autowiring to ensure that the correctGroupinstance is injected:All Stormpath resource instances (
Account,Group,Application, etc) are thread-safe, making them safe to be used as singletons if desired.