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 "";
}
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;
}
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;
}
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;
}
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;
}
Aggregations