java 如何在weblogic中创建安全角色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11903739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 06:52:03  来源:igfitidea点击:

How to create security role in weblogic

javaweblogic

提问by hudi

I followed this totorial to create security role in weblogic: http://blog.whitehorses.nl/2010/01/29/weblogic-web-application-container-security-part-1/

我按照这个 totorial 在 weblogic 中创建安全角色:http://blog.whitehorses.nl/2010/01/29/weblogic-web-application-container-security-part-1/

I create in weblogic server group RobMon and user monitor with pass. Then I create this xml:

我在 weblogic 服务器组 RobMon 中创建并使用 pass 进行用户监视器。然后我创建这个xml:

my web.xml:

我的 web.xml:

<security-constraint>

    <web-resource-collection>
        <web-resource-name>my-application</web-resource-name>
        <url-pattern>/admin</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>RobMon</role-name>
    </auth-constraint>
</security-constraint>

<security-role>
    <role-name>RobMon</role-name>
</security-role>

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login</form-login-page>
        <form-error-page>/login</form-error-page>
    </form-login-config>
</login-config>

weblogic.xml:

weblogic.xml:

<wls:security-role-assignment>
    <wls:role-name>RobMon</wls:role-name>
    <wls:principal-name>RobMon</wls:principal-name>
</wls:security-role-assignment>

and now I want to println role and principles:

现在我想打印角色和原则:

    Subject subject = Security.getCurrentSubject();
    Set<Principal> allPrincipals = subject.getPrincipals();
    for (Principal principal : allPrincipals) {
        if (principal instanceof WLSGroupImpl) {
            logger.error(principal.getName() + "??????????");
            roles.add(principal.getName());
        }
        if (principal instanceof WLSUserImpl) {
            logger.error(principal.getName() + "!!!!!!!!!!!");
            user = principal.getName();
        }
    }

but this prints me something else what I want

但这会打印出我想要的其他东西

 admin!!!!!!!!!!!
 Administrators??????????

it should println monitor and RobMon. What is wrong ?

它应该打印监视器和 RobMon。怎么了 ?

回答by Apostolos Emmanouilidis

In weblogic.xml you have assigned the role RobMon to the user RobMonwhich means that when the user RobMon is authenticated he will be assigned the RobMon role.

在 weblogic.xml 中,您已将角色 RobMon 分配给用户 RobMon,这意味着当用户 RobMon 通过身份验证时,他将被分配 RobMon 角色。

In the tutorial the principal group users is used instead of RobMon user which means that all the users of the group will be assigned the role after being authenticated.

本教程中使用主体组用户而不是 RobMon 用户,这意味着该组的所有用户都将在通过身份验证后分配角色。

Check that principal RobMon exists in your security realm. I think that the user RobMon does not exist in your security realm. You probably wanted to assign the role to the user monitor. So the configuration in weblogic.wml should be:

检查主体 RobMon 是否存在于您的安全领域中。我认为用户 RobMon 不存在于您的安全领域。您可能希望将角色分配给用户监视器。所以weblogic.wml中的配置应该是:

    <wls:security-role-assignment>
      <wls:role-name>RobMon</wls:role-name>
      <wls:principal-name>monitor</wls:principal-name>
    </wls:security-role-assignment>