2017-03-22 98 views
0

我在websphere安全性方面很新颖。在我的应用程序中,我有一个ejb,它具有以用户身份运行的安全设置。当我ping ejb时,它执行runas configs中指定的用户方法。 是否可以对servlet做同样的事情?我的意思是当用户发送来自ui的请求并且websphere从runas configs执行dopost/doget作为用户时?websphere以用户身份运行servlet

+0

请参阅[这里](https://www.ibm.com/support/knowledgecenter/SSAW57_liberty/com.ibm.websphere.wlp.doc/ae/twlp_sec_runas.html) –

回答

1

如果您使用的是Servlet 3.1(Java EE 7),那么您可以在servlet类上使用@RunAs注释。

例如,该组的Servlet注解将允许管理人员和员工的角色来访问servlet和运行为员工角色:

@RunAs("Employee") 
@WebServlet("/myServlet") 
@ServletSecurity(
    httpMethodConstraints = { 
    @HttpMethodConstraint(value = "GET", rolesAllowed = "Manager"), 
    @HttpMethodConstraint(value = "GET", rolesAllowed = "Employee") 
    } 
) 
public class MyServlet extends HttpServlet { 
    // ... 
} 

有关运行方式配置完全自由的文档,在这里看到:Configuring RunAs authentication in Liberty

+1

非常感谢它! –