if (!component.isDenyAllApplicableToClass(viewClassName, ejbClassName)) {
denyOnAllViews = false;
} else {
EJBViewDescription ejbView = EJBViewDescription.class.cast(view);
MethodInterfaceType type = getMethodInterfaceType(ejbView.getMethodIntf());
EJBMethodPermission p = new EJBMethodPermission(ejbName, null, type.name(), null);
permissions.add(p);
}
if (!component.isPermitAllApplicableToClass(viewClassName, ejbClassName)) {
permitOnAllViews = false;
} else {
EJBViewDescription ejbView = EJBViewDescription.class.cast(view);
MethodInterfaceType type = getMethodInterfaceType(ejbView.getMethodIntf());
EJBMethodPermission p = new EJBMethodPermission(ejbName, null, type.name(), null);
uncheckedPermissions.add(p);
}
Set<String> roles = component.getRolesAllowedForClass(viewClassName, ejbClassName);
for (String role : roles) {
policyConfiguration.addToRole(role, new EJBMethodPermission(ejbName, null, null, null));
}
// check method level
Collection<EJBMethodIdentifier> methods = component.getDenyAllMethodsForView(viewClassName);
for (EJBMethodIdentifier method : methods) {
MethodIdentifier identifier = method.getMethodIdentifier();
EJBViewDescription ejbView = EJBViewDescription.class.cast(view);
MethodInterfaceType type = getMethodInterfaceType(ejbView.getMethodIntf());
EJBMethodPermission p = new EJBMethodPermission(ejbName, identifier.getName(), type.name(),
identifier.getParameterTypes());
policyConfiguration.addToExcludedPolicy(p);
}
methods = component.getPermitAllMethodsForView(viewClassName);
for (EJBMethodIdentifier method : methods) {
MethodIdentifier identifier = method.getMethodIdentifier();
EJBViewDescription ejbView = EJBViewDescription.class.cast(view);
MethodInterfaceType type = getMethodInterfaceType(ejbView.getMethodIntf());
EJBMethodPermission p = new EJBMethodPermission(ejbName, identifier.getName(), type.name(),
identifier.getParameterTypes());
policyConfiguration.addToUncheckedPolicy(p);
}
Map<EJBMethodIdentifier, Set<String>> rolesMap = component.getRolesAllowed(viewClassName);
for (Entry<EJBMethodIdentifier, Set<String>> entry : rolesMap.entrySet()) {
MethodIdentifier identifier = entry.getKey().getMethodIdentifier();
EJBViewDescription ejbView = EJBViewDescription.class.cast(view);
MethodInterfaceType type = getMethodInterfaceType(ejbView.getMethodIntf());
for (String role : entry.getValue()) {
EJBMethodPermission p = new EJBMethodPermission(ejbName, identifier.getName(), type.name(),
identifier.getParameterTypes());
policyConfiguration.addToRole(role, p);
}
}
}
// if deny is on all views, we add permission with null as the interface
if (denyOnAllViews) {
permissions = new ArrayList<EJBMethodPermission>();
permissions.add(new EJBMethodPermission(ejbName, null, null, null));
}
// add exclude-list permissions
for (EJBMethodPermission ejbMethodPermission : permissions) {
policyConfiguration.addToExcludedPolicy(ejbMethodPermission);
}
// if permit is on all views, we add permission with null as the interface
if (permitOnAllViews) {
uncheckedPermissions = new ArrayList<EJBMethodPermission>();
uncheckedPermissions.add(new EJBMethodPermission(ejbName, null, null, null));
}
// add method-permission permissions
for (EJBMethodPermission ejbMethodPermission : uncheckedPermissions) {
policyConfiguration.addToUncheckedPolicy(ejbMethodPermission);
}
// Process the security-role-ref
Map<String, Collection<String>> securityRoles = component.getSecurityRoleLinks();
for (Entry<String, Collection<String>> entry : securityRoles.entrySet()) {
String roleName = entry.getKey();
for (String roleLink : entry.getValue()) {
EJBRoleRefPermission p = new EJBRoleRefPermission(ejbName, roleName);
policyConfiguration.addToRole(roleLink, p);
}
}
/*
* Special handling of stateful session bean getEJBObject due how the stateful session handles acquire the
* proxy by sending an invocation to the ejb container.
*/
if (component instanceof SessionBeanComponentDescription) {
SessionBeanComponentDescription session = SessionBeanComponentDescription.class.cast(component);
if (session.isStateful()) {
EJBMethodPermission p = new EJBMethodPermission(ejbName, "getEJBObject", "Home", null);
policyConfiguration.addToUncheckedPolicy(p);
}
}
}
}