I followed this totorial to create security role in 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:
my 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:
<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 ?