15.12. Extending the Identity component
If your application has special security requirements, you may need to extend your Identity component. The following example shows an Identity component extended with an additional
companyCode
field to handle credentials. (Usually this would be handled by a Credentials
component.) The install precedence of APPLICATION
ensures that this extended Identity is installed instead of the built-in Identity.
@Name("org.jboss.seam.security.identity") @Scope(SESSION) @Install(precedence = APPLICATION) @BypassInterceptors @Startup public class CustomIdentity extends Identity { private static final LogProvider log = Logging.getLogProvider(CustomIdentity.class); private String companyCode; public String getCompanyCode() { return companyCode; } public void setCompanyCode(String companyCode) { this.companyCode = companyCode; } @Override public String login() { log.info("###### CUSTOM LOGIN CALLED ######"); return super.login(); } }
Warning
An
Identity
component must be marked @Startup
so that it is available immediately after the SESSION
context begins. Failing to do this may render certain Seam functionality inoperable in your application.