简体   繁体   English

如何在Weblogic中创建安全角色

[英]How to create security role in weblogic

I followed this totorial to create security role in weblogic: http://blog.whitehorses.nl/2010/01/29/weblogic-web-application-container-security-part-1/ 我按照以下指南在网络逻辑中创建安全角色: 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. 我在weblogic服务器组RobMon中创建并通过传递用户监视器。 Then I create this xml: 然后创建此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. 它应该打印监视器和RobMon。 What is wrong ? 怎么了 ?

In weblogic.xml you have assigned the role RobMon to the user RobMon which 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. 检查主体RobMon是否存在于您的安全领域中。 I think that the user RobMon does not exist in your security realm. 我认为用户RobMon在您的安全领域中不存在。 You probably wanted to assign the role to the user monitor. 您可能想将角色分配给用户监视器。 So the configuration in weblogic.wml should be: 因此,weblogic.wml中的配置应为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM