Вы можете создать собственный метод registerAdminAsUser ().
@Name("authenticationProxy")
public class AuthenticationProxy {
private @In org.jboss.seam.security.Identity identity;
/**
* Starting with Seam 2.1+, you should use Credentials instead of Identity
* To collect your username and password
*
* Your JSF Form should looks like
*
* <h:inputText value="#{credentials.username}"/>
* <h:inputSecret value="#{credentials.password}"/>
*/
private @In org.jboss.seam.security.Credentials credentials;
public String registerAdminAsUser2() {
identity.getCredentials().setUsername("user2");
/**
* Here you should provide any role which should be assigned to User2
*/
identity.addRole("<A_ROLE>");
identity.addRole("<OTHER_ROLE>");
identity.addRole("<ANOTHER_ROLE>");
/**
* Do not call login method because it will call authenticate one
* You do not have User2 password
*/
// identity.login();
return "loggedIn";
}
/**
* Be aware you may need a unregisterAdminAsUser2
*/
}
И чтобы включить свой прокси, создайте команду Кнопка
<h:commandButton value="register Admin as User2" value="#{authenticationProxy.registerAdminAsUser2}" rendered="#{credentials.username == 'admin'}"/>
Чтобы использовать какой-либо компонент JSF, сделайте следующее
<h:commandLink rendered="#{s:hasRole('<ANY_ROLE_ASSIGNED_TO_USER2_GOES_HERE>')}"/>
Я надеюсь, что это может быть полезно для вас!