Search in sources :

Example 11 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class BasicPasswordAuthenticationService method getRoleName.

private String getRoleName(Principal callerPrincipal) {
    String roleName = null;
    WebBundleDescriptor wbd = (WebBundleDescriptor) getComponentEnvManager().getCurrentJndiNameEnvironment();
    SecurityRoleMapperFactory securityRoleMapperFactory = getSecurityRoleMapperFactory();
    SecurityRoleMapper securityRoleMapper = securityRoleMapperFactory.getRoleMapper(wbd.getModuleID());
    Map<String, Subject> map = securityRoleMapper.getRoleToSubjectMapping();
    for (Map.Entry<String, Subject> entry : map.entrySet()) {
        roleName = entry.getKey();
        Subject subject = entry.getValue();
        Set principalSet = subject.getPrincipals();
        if (principalSet.contains(callerPrincipal)) {
            return roleName;
        }
    }
    return "";
}
Also used : SecurityRoleMapper(org.glassfish.deployment.common.SecurityRoleMapper) SecurityRoleMapperFactory(org.glassfish.deployment.common.SecurityRoleMapperFactory) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) Subject(javax.security.auth.Subject)

Example 12 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class SecurityRoleAssignmentNode method writeDescriptors.

/**
 * write all occurrences of the descriptor corresponding to the current
 * node from the parent descriptor to an JAXP DOM node and return it
 *
 * This API will be invoked by the parent node when the parent node
 * writes out a mix of statically and dynamically registered sub nodes.
 *
 * This method should be overriden by the sub classes if it
 * needs to be called by the parent node.
 *
 * @param parent node in the DOM tree
 * @param nodeName the name of the node
 * @param parentDesc parent descriptor of the descriptor to be written
 * @return the JAXP DOM node
 */
@Override
public Node writeDescriptors(Node parent, String nodeName, Descriptor parentDesc) {
    if (parentDesc instanceof WebBundleDescriptor) {
        WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) parentDesc;
        // security-role-assignment*
        SecurityRoleAssignment[] securityRoleAssignments = webBundleDescriptor.getSunDescriptor().getSecurityRoleAssignments();
        for (SecurityRoleAssignment securityRoleAssignment : securityRoleAssignments) {
            writeDescriptor(parent, nodeName, securityRoleAssignment);
        }
    }
    return parent;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) SecurityRoleAssignment(com.sun.enterprise.deployment.runtime.common.wls.SecurityRoleAssignment)

Example 13 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class DOLUtils method getComponentEnvId.

/**
 * Generate a unique id name for each J2EE component.
 * @param env
 * @return
 */
public static String getComponentEnvId(JndiNameEnvironment env) {
    String id = null;
    if (env instanceof EjbDescriptor) {
        // EJB component
        EjbDescriptor ejbEnv = (EjbDescriptor) env;
        // Make jndi name flat so it won't result in the creation of
        // a bunch of sub-contexts.
        String flattedJndiName = ejbEnv.getJndiName().replace('/', '.');
        EjbBundleDescriptor ejbBundle = ejbEnv.getEjbBundleDescriptor();
        Descriptor d = ejbBundle.getModuleDescriptor().getDescriptor();
        // as the web bundle, because they share the same JNDI namespace
        if (d instanceof WebBundleDescriptor) {
            // copy of code below
            WebBundleDescriptor webEnv = (WebBundleDescriptor) d;
            id = webEnv.getApplication().getName() + ID_SEPARATOR + webEnv.getContextRoot();
            if (deplLogger.isLoggable(Level.FINER)) {
                deplLogger.log(Level.FINER, CONVERT_EJB_TO_WEB_ID, id);
            }
        } else {
            id = ejbEnv.getApplication().getName() + ID_SEPARATOR + ejbBundle.getModuleDescriptor().getArchiveUri() + ID_SEPARATOR + ejbEnv.getName() + ID_SEPARATOR + flattedJndiName + ejbEnv.getUniqueId();
        }
    } else if (env instanceof WebBundleDescriptor) {
        WebBundleDescriptor webEnv = (WebBundleDescriptor) env;
        id = webEnv.getApplication().getName() + ID_SEPARATOR + webEnv.getContextRoot();
    } else if (env instanceof ApplicationClientDescriptor) {
        ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env;
        id = "client" + ID_SEPARATOR + appEnv.getName() + ID_SEPARATOR + appEnv.getMainClassName();
    } else if (env instanceof ManagedBeanDescriptor) {
        id = ((ManagedBeanDescriptor) env).getGlobalJndiName();
    } else if (env instanceof EjbBundleDescriptor) {
        EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env;
        id = "__ejbBundle__" + ID_SEPARATOR + ejbBundle.getApplication().getName() + ID_SEPARATOR + ejbBundle.getModuleName();
    }
    return id;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) ActiveDescriptor(org.glassfish.hk2.api.ActiveDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) Descriptor(org.glassfish.deployment.common.Descriptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 14 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class DOLUtils method getModuleName.

public static String getModuleName(JndiNameEnvironment env) {
    String moduleName = null;
    if (env instanceof EjbDescriptor) {
        // EJB component
        EjbDescriptor ejbEnv = (EjbDescriptor) env;
        EjbBundleDescriptor ejbBundle = ejbEnv.getEjbBundleDescriptor();
        moduleName = ejbBundle.getModuleDescriptor().getModuleName();
    } else if (env instanceof EjbBundleDescriptor) {
        EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env;
        moduleName = ejbBundle.getModuleDescriptor().getModuleName();
    } else if (env instanceof WebBundleDescriptor) {
        WebBundleDescriptor webEnv = (WebBundleDescriptor) env;
        moduleName = webEnv.getModuleName();
    } else if (env instanceof ApplicationClientDescriptor) {
        ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env;
        moduleName = appEnv.getModuleName();
    } else if (env instanceof ManagedBeanDescriptor) {
        ManagedBeanDescriptor mb = (ManagedBeanDescriptor) env;
        moduleName = mb.getBundle().getModuleName();
    } else {
        throw new IllegalArgumentException("IllegalJndiNameEnvironment : env");
    }
    return moduleName;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 15 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class DOLUtils method getApplicationFromEnv.

/**
 * @param env
 * @return
 */
public static Application getApplicationFromEnv(JndiNameEnvironment env) {
    Application app = null;
    if (env instanceof EjbDescriptor) {
        // EJB component
        EjbDescriptor ejbEnv = (EjbDescriptor) env;
        app = ejbEnv.getApplication();
    } else if (env instanceof EjbBundleDescriptor) {
        EjbBundleDescriptor ejbBundle = (EjbBundleDescriptor) env;
        app = ejbBundle.getApplication();
    } else if (env instanceof WebBundleDescriptor) {
        WebBundleDescriptor webEnv = (WebBundleDescriptor) env;
        app = webEnv.getApplication();
    } else if (env instanceof ApplicationClientDescriptor) {
        ApplicationClientDescriptor appEnv = (ApplicationClientDescriptor) env;
        app = appEnv.getApplication();
    } else if (env instanceof ManagedBeanDescriptor) {
        ManagedBeanDescriptor mb = (ManagedBeanDescriptor) env;
        app = mb.getBundle().getApplication();
    } else if (env instanceof Application) {
        app = ((Application) env);
    } else {
        throw new IllegalArgumentException("IllegalJndiNameEnvironment : env");
    }
    return app;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) Application(com.sun.enterprise.deployment.Application) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Aggregations

WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)47 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)14 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)10 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)7 Application (com.sun.enterprise.deployment.Application)6 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ArrayList (java.util.ArrayList)4 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)4 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)3 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)3 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)3 WebResourceCollection (com.sun.enterprise.deployment.web.WebResourceCollection)3 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 XMLNode (com.sun.enterprise.deployment.node.XMLNode)2 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)2 File (java.io.File)2