use of org.glassfish.security.common.Role in project Payara by payara.
the class AppSecurityRole method check.
/**
* The Application role-name element contains the name of a security role.
*
* @param descriptor the Application deployment descriptor
*
* @return <code>Result</code> the results for this assertion
*/
public Result check(Application descriptor) {
Result result = getInitializedResult();
if (!descriptor.getRoles().isEmpty()) {
boolean oneFailed = false;
boolean foundIt = false;
// get the security role name's in this app
Set sc = descriptor.getRoles();
Iterator itr = sc.iterator();
while (itr.hasNext()) {
foundIt = false;
Role role = (Role) itr.next();
String roleName = role.getName();
if (roleName.length() > 0) {
foundIt = true;
} else {
foundIt = false;
}
if (foundIt) {
result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "The security role name [ {0} ] found within application [ {1} ]", new Object[] { roleName, descriptor.getName() }));
} else {
if (!oneFailed) {
oneFailed = true;
}
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: The security role name [ {0} ] not found within application [ {1} ]", new Object[] { roleName, descriptor.getName() }));
}
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
} else {
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "There are no role-name elements within the application [ {0} ]", new Object[] { descriptor.getName() }));
}
return result;
}
use of org.glassfish.security.common.Role in project Payara by payara.
the class MapValue method removePolicyStatements.
/**
* Remove All Policy Statements from Configuration config must be in open state when this method is called
*
* @param pc
* @param wbd
* @throws javax.security.jacc.PolicyContextException
*/
public static void removePolicyStatements(PolicyConfiguration pc, WebBundleDescriptor wbd) throws javax.security.jacc.PolicyContextException {
pc.removeUncheckedPolicy();
pc.removeExcludedPolicy();
// iteration done for old providers
Set<Role> roleSet = wbd.getRoles();
for (Role r : roleSet) {
pc.removeRole(r.getName());
}
// 1st call will remove "*" role if present. 2nd will remove all roles (if supported).
pc.removeRole("*");
pc.removeRole("*");
}
use of org.glassfish.security.common.Role in project Payara by payara.
the class DeclareRolesHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
DeclareRoles rolesRefAn = (DeclareRoles) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDescriptor = ejbContext.getDescriptor();
for (String roleName : rolesRefAn.value()) {
if (ejbDescriptor.getRoleReferenceByName(roleName) == null) {
RoleReference roleRef = new RoleReference(roleName, "");
roleRef.setRolename(roleName);
roleRef.setSecurityRoleLink(new SecurityRoleDescriptor(roleName, ""));
ejbDescriptor.addRoleReference(roleRef);
}
Role role = new Role(roleName);
ejbDescriptor.getEjbBundleDescriptor().addRole(role);
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.security.common.Role in project Payara by payara.
the class RunAsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
RunAs runAsAn = (RunAs) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
// override by xml
if (ejbDesc.getUsesCallerIdentity() != null) {
continue;
}
String roleName = runAsAn.value();
Role role = new Role(roleName);
// add Role if not exists
ejbDesc.getEjbBundleDescriptor().addRole(role);
RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
runAsDesc.setRoleName(roleName);
ejbDesc.setUsesCallerIdentity(false);
if (ejbDesc.getRunAsIdentity() == null) {
ejbDesc.setRunAsIdentity(runAsDesc);
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.security.common.Role in project Payara by payara.
the class WebBundleDescriptorImpl method getSecurityRoles.
/**
* Returns an Enumeration of my SecurityRole objects.
* @return
*/
@Override
public Enumeration<SecurityRoleDescriptor> getSecurityRoles() {
Vector<SecurityRoleDescriptor> securityRoles = new Vector<SecurityRoleDescriptor>();
for (Role r : super.getRoles()) {
SecurityRoleDescriptor srd = new SecurityRoleDescriptor(r);
securityRoles.add(srd);
}
return securityRoles.elements();
}
Aggregations