|
||||||||
|
This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira |
||||||||
- [jira] [Created] (TOMEE-404) allow to give a re... Romain Manni-Bucau (JIRA)
- [jira] [Closed] (TOMEE-404) allow to give ... Romain Manni-Bucau (JIRA)
- [jira] [Commented] (TOMEE-404) allow to gi... Enrico Olivelli (JIRA)
- [jira] [Commented] (TOMEE-404) allow to gi... Romain Manni-Bucau (JIRA)
- [jira] [Updated] (TOMEE-404) allow to give... Jean-Louis MONTEIRO (JIRA)

in META-INF/context.xml
<Context ...>
<Realm cdi="true" className="org.apache.tomee.catalina.realm.LazyRealm" realmClass="org.superbiz.AuthBean"/>
</Context>
package org.superbiz;
@RequestScoped
public class AuthBean {
public Principal authenticate(final String username, String password) {
if (("userA".equals(username)||"userB".equals(username)) && "test".equals(password)) {
return new Principal() {
@Override
public String getName() {
return username;
}
@Override
public String toString() {
return username;
}
};
}
return null;
}
public boolean hasRole(Principal principal, String role) {
if (principal == null) {
return false;
}
if(principal.getName().equals("userA") && (role.equals("admin")||role.equals("user"))) {
return true;
}
if(principal.getName().equals("userB") && (role.equals("user"))) {
return true;
}
return false;
}
}