}
private void addSecurityData(EnterpriseBean enterpriseBean, ComponentPermissions componentPermissions) throws DeploymentException {
SecurityConfiguration securityConfiguration = (SecurityConfiguration) earContext.getSecurityConfiguration();
if (securityConfiguration != null) {
GBeanData gbean = getEjbGBean(enterpriseBean.getEjbName());
if (enterpriseBean instanceof RemoteBean) {
RemoteBean remoteBean = (RemoteBean) enterpriseBean;
SecurityBuilder securityBuilder = new SecurityBuilder();
PermissionCollection permissions = new Permissions();
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.HOME.getJaccInterfaceName(),
remoteBean.getHome(),
ejbModule.getClassLoader());
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.REMOTE.getJaccInterfaceName(),
remoteBean.getRemote(),
ejbModule.getClassLoader());
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.LOCAL.getJaccInterfaceName(),
remoteBean.getLocal(),
ejbModule.getClassLoader());
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.LOCAL_HOME.getJaccInterfaceName(),
remoteBean.getLocalHome(),
ejbModule.getClassLoader());
if (remoteBean instanceof SessionBean) {
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.SERVICE_ENDPOINT.getJaccInterfaceName(),
((SessionBean) remoteBean).getServiceEndpoint(),
ejbModule.getClassLoader());
}
if (remoteBean.getBusinessRemote() != null && !remoteBean.getBusinessRemote().isEmpty()) {
for (String businessRemote : remoteBean.getBusinessRemote()) {
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.REMOTE.getJaccInterfaceName(),
businessRemote,
ejbModule.getClassLoader());
}
securityBuilder.addToPermissions(componentPermissions.getUncheckedPermissions(),
remoteBean.getEjbName(),
EjbInterface.HOME.getJaccInterfaceName(),
DeploymentInfo.BusinessRemoteHome.class.getName(),
ejbModule.getClassLoader());
}
if (remoteBean.getBusinessLocal() != null && !remoteBean.getBusinessLocal().isEmpty()) {
for (String businessLocal : remoteBean.getBusinessLocal()) {
securityBuilder.addToPermissions(permissions,
remoteBean.getEjbName(),
EjbInterface.LOCAL.getJaccInterfaceName(),
businessLocal,
ejbModule.getClassLoader());
}
securityBuilder.addToPermissions(componentPermissions.getUncheckedPermissions(),
remoteBean.getEjbName(),
EjbInterface.LOCAL_HOME.getJaccInterfaceName(),
DeploymentInfo.BusinessLocalHome.class.getName(),
ejbModule.getClassLoader());
}
String defaultRole = securityConfiguration.getDefaultRole();
securityBuilder.addComponentPermissions(defaultRole,
permissions,
ejbModule.getEjbJar().getAssemblyDescriptor(),
enterpriseBean.getEjbName(),
remoteBean.getSecurityRoleRef(),
componentPermissions);
}
// RunAs subject
SecurityIdentity securityIdentity = enterpriseBean.getSecurityIdentity();
if (securityIdentity != null && securityIdentity.getRunAs() != null) {
String runAsName = securityIdentity.getRunAs();
if (runAsName != null) {
gbean.setAttribute("runAsRole", runAsName);
}
}
gbean.setAttribute("securityEnabled", true);
gbean.setReferencePattern("RunAsSource", earContext.getJaccManagerName());
}
}