Search in sources :

Example 1 with SimpleSecurityManager

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();
}
Also used : SimpleSecurityManager(org.jboss.as.security.service.SimpleSecurityManager) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain)

Example 2 with SimpleSecurityManager

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);
}
Also used : Set(java.util.Set) SecurityRolesMetaData(org.jboss.metadata.javaee.spec.SecurityRolesMetaData) ServerSecurityManager(org.jboss.as.core.security.ServerSecurityManager) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) SimpleSecurityManager(org.jboss.as.security.service.SimpleSecurityManager)

Aggregations

SimpleSecurityManager (org.jboss.as.security.service.SimpleSecurityManager)2 Set (java.util.Set)1 ServerSecurityManager (org.jboss.as.core.security.ServerSecurityManager)1 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)1 SecurityRolesMetaData (org.jboss.metadata.javaee.spec.SecurityRolesMetaData)1 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)1