基于Jetty JDBCLoginService角色的访问不起作用

时间:2016-07-06 15:35:30

标签: java mysql jdbc jetty

这是以下帖子的后续内容:Jetty JDBCLoginService using null in mysql request您可以在其中找到领域配置。

我使用jetty JDBCLoginService在我的应用中进行授权, 当然,我在我的数据库中有价值。 我的web.xml的授权部分

<security-constraint>
  <web-resource-collection>
    <web-resource-name>
    Areas with authentication required
    </web-resource-name>
    <url-pattern> /protected/* </url-pattern>
  </web-resource-collection>
  <auth-constraint>
    <role-name>*</role-name>
  </auth-constraint>
  <user-data-constraint>
    <transport-guarantee> NONE </transport-guarantee>
  </user-data-constraint>
</security-constraint>
<login-config>
  <auth-method>FORM</auth-method>
  <realm-name>gateway_jndi</realm-name>
  <form-login-config>
    <form-login-page>/public/login.jsf</form-login-page>
    <form-error-page>/public/login.jsf</form-error-page>
  </form-login-config>
</login-config>

我的backbean的登录部分:

public void login() {
        ExternalContext    externalContext = FacesContext.getCurrentInstance().getExternalContext();
        HttpServletRequest request         = (HttpServletRequest) externalContext.getRequest();
        try {
            Faces.login(getUsername(), getPassword());
            FacesContext.getCurrentInstance().getExternalContext().redirect(request.getContextPath() + "/protected/statistiques.jsf");
            } 
        catch (ServletException ex) {
            FacesContext context = FacesContext.getCurrentInstance();
            context.addMessage(
                "formMsg", 
                new FacesMessage(
                        FacesMessage.SEVERITY_INFO, 
                        messagesBundle.getString("main.gateway.title.error"), 
                        messagesBundle.getString("main.gateway.common.controller.error.login")
                        )
            );
        } catch (IOException e) {
            e.printStackTrace();
        }
        setPassword(null);
    }

在使用它时,我总是在控制台中获得403 with!角色,如果我使用**我可以登录到应用程序。

我在我的支持bean中遗漏了一些东西,或者与码头相关的问题是什么?

1 个答案:

答案 0 :(得分:0)

好的,所以我在我的web.xml中诋毁角色,例如:

<security-role>
  <role-name>administrator</role-name>
</security-role>
似乎是:

<auth-constraint>
 <role-name>*</role-name>
</auth-constraint>

表示与应用程序相关的任何角色,而不是数据库中的任何角色。