use of org.jboss.as.security.service.SimpleSecurityManager in project wildfly by wildfly.
the class WeldSecurityServices method getPrincipal.
@Override
public Principal getPrincipal() {
SecurityDomain elytronDomain = SecurityDomain.getCurrent();
if (elytronDomain != null) {
return elytronDomain.getCurrentSecurityIdentity().getPrincipal();
}
final SimpleSecurityManager securityManager = securityManagerValue.getOptionalValue();
if (securityManager == null)
throw WeldLogger.ROOT_LOGGER.securityNotEnabled();
return securityManager.getCallerPrincipal();
}
use of org.jboss.as.security.service.SimpleSecurityManager in project wildfly by wildfly.
the class SecurityContextInterceptorFactory method create.
@Override
protected Interceptor create(final Component component, final InterceptorFactoryContext context) {
if (component instanceof EJBComponent == false) {
throw EjbLogger.ROOT_LOGGER.unexpectedComponent(component, EJBComponent.class);
}
final EJBComponent ejbComponent = (EJBComponent) component;
final ServerSecurityManager securityManager;
if (propagateSecurity) {
securityManager = ejbComponent.getSecurityManager();
} else {
securityManager = new SimpleSecurityManager((SimpleSecurityManager) ejbComponent.getSecurityManager());
}
final EJBSecurityMetaData securityMetaData = ejbComponent.getSecurityMetaData();
String securityDomain = securityMetaData.getSecurityDomain();
if (securityDomain == null) {
securityDomain = DEFAULT_DOMAIN;
}
if (ROOT_LOGGER.isTraceEnabled()) {
ROOT_LOGGER.trace("Using security domain: " + securityDomain + " for EJB " + ejbComponent.getComponentName());
}
final String runAs = securityMetaData.getRunAs();
// TODO - We should do something with DeclaredRoles although it never has much meaning in JBoss AS
final String runAsPrincipal = securityMetaData.getRunAsPrincipal();
final SecurityRolesMetaData securityRoles = securityMetaData.getSecurityRoles();
Set<String> extraRoles = null;
Map<String, Set<String>> principalVsRolesMap = null;
if (securityRoles != null) {
principalVsRolesMap = securityRoles.getPrincipalVersusRolesMap();
if (runAsPrincipal != null)
extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(runAsPrincipal);
}
SecurityContextInterceptorHolder holder = new SecurityContextInterceptorHolder();
holder.setSecurityManager(securityManager).setSecurityDomain(securityDomain).setRunAs(runAs).setRunAsPrincipal(runAsPrincipal).setPolicyContextID(this.policyContextID).setExtraRoles(extraRoles).setPrincipalVsRolesMap(principalVsRolesMap).setSkipAuthentication(securityRequired == false);
return new SecurityContextInterceptor(holder);
}
Aggregations