您可以创建一个自定义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>')}"/>
我希望能对你有用!
与此类似的东西(https://performancemanager.successfactors.eu/doc/roboHelp/04-About_Your_Worksessions_and_Preferences/ph_set_proxy108.htm)是我正在寻找的 – Sam 2010-04-22 04:23:27