use of com.sun.enterprise.deployment.MethodPermissionDescriptor in project Payara by payara.
the class ExcludeListNode method getDescriptor.
@Override
public MethodPermissionDescriptor getDescriptor() {
if (descriptor == null) {
descriptor = new MethodPermissionDescriptor();
descriptor.addMethodPermission(MethodPermission.getExcludedMethodPermission());
}
return descriptor;
}
use of com.sun.enterprise.deployment.MethodPermissionDescriptor in project Payara by payara.
the class EjbBundleNode method addMethodPermissions.
private void addMethodPermissions(EjbDescriptor ejb, Map mpToMethods, Vector excludedMethods, MethodPermissionNode mpNode, Node assemblyNode) {
if (mpToMethods == null || mpToMethods.size() == 0) {
return;
}
for (Object o : mpToMethods.entrySet()) {
Map.Entry entry = (Map.Entry) o;
MethodPermission mp = (MethodPermission) entry.getKey();
if (mp.isExcluded()) {
// we need to be sure the method descriptors knows who owns them
Set methods = (Set) entry.getValue();
excludedMethods.addAll(methods);
} else {
MethodPermissionDescriptor mpd = new MethodPermissionDescriptor();
mpd.addMethodPermission(mp);
mpd.addMethods((Set) mpToMethods.get(mp));
mpNode.writeDescriptor(assemblyNode, EjbTagNames.METHOD_PERMISSION, mpd, ejb);
}
}
}
use of com.sun.enterprise.deployment.MethodPermissionDescriptor in project Payara by payara.
the class EjbBundleNode method addDescriptor.
@Override
public void addDescriptor(Object newDescriptor) {
if (newDescriptor instanceof EjbDescriptor) {
descriptor.addEjb((EjbDescriptor) newDescriptor);
} else if (newDescriptor instanceof RelationshipDescriptor) {
descriptor.addRelationship((RelationshipDescriptor) newDescriptor);
} else if (newDescriptor instanceof MethodPermissionDescriptor) {
MethodPermissionDescriptor nd = (MethodPermissionDescriptor) newDescriptor;
MethodDescriptor[] array = nd.getMethods();
for (int i = 0; i < array.length; i++) {
EjbDescriptor target = descriptor.getEjbByName(array[i].getEjbName());
MethodPermission[] mps = nd.getMethodPermissions();
for (int j = 0; j < mps.length; j++) {
DOLUtils.getDefaultLogger().fine("Adding mp " + mps[j] + " to " + array[i] + " for ejb " + array[i].getEjbName());
target.addPermissionedMethod(mps[j], array[i]);
}
}
} else
super.addDescriptor(newDescriptor);
}
use of com.sun.enterprise.deployment.MethodPermissionDescriptor in project Payara by payara.
the class EjbBundleNode method writeAssemblyDescriptor.
/**
* write assembly-descriptor related xml information to the DOM tree
*/
private void writeAssemblyDescriptor(Node parentNode, EjbBundleDescriptorImpl bundleDescriptor) {
Node assemblyNode = parentNode.getOwnerDocument().createElement(EjbTagNames.ASSEMBLY_DESCRIPTOR);
// security-role*
SecurityRoleNode roleNode = new SecurityRoleNode();
for (Iterator e = bundleDescriptor.getRoles().iterator(); e.hasNext(); ) {
roleNode.writeDescriptor(assemblyNode, TagNames.ROLE, (Role) e.next());
}
// method-permission*
Map excludedMethodsByEjb = new HashMap();
MethodPermissionNode mpNode = new MethodPermissionNode();
for (EjbDescriptor ejbDesc : bundleDescriptor.getEjbs()) {
if (ejbDesc instanceof EjbMessageBeanDescriptor)
continue;
Vector excludedMethods = new Vector();
addMethodPermissions(ejbDesc, ejbDesc.getPermissionedMethodsByPermission(), excludedMethods, mpNode, assemblyNode);
addMethodPermissions(ejbDesc, ejbDesc.getStyledPermissionedMethodsByPermission(), excludedMethods, mpNode, assemblyNode);
if (excludedMethods.size() > 0) {
excludedMethodsByEjb.put(ejbDesc, excludedMethods);
}
}
// container-transaction*
ContainerTransactionNode ctNode = new ContainerTransactionNode();
for (EjbDescriptor ejbDesc : bundleDescriptor.getEjbs()) {
ctNode.writeDescriptor(assemblyNode, EjbTagNames.CONTAINER_TRANSACTION, ejbDesc);
}
// interceptor-binding*
InterceptorBindingNode ibNode = new InterceptorBindingNode();
for (EjbDescriptor ejbDesc : bundleDescriptor.getEjbs()) {
if (!ejbDesc.getInterceptorClasses().isEmpty()) {
ibNode.writeBindings(assemblyNode, ejbDesc);
}
}
// message-destination*
writeMessageDestinations(assemblyNode, bundleDescriptor.getMessageDestinations().iterator());
// exclude-list*
if (excludedMethodsByEjb.size() > 0) {
Node excludeListNode = this.appendChild(assemblyNode, EjbTagNames.EXCLUDE_LIST);
for (Object o : excludedMethodsByEjb.entrySet()) {
Map.Entry entry = (Map.Entry) o;
EjbDescriptor ejbDesc = (EjbDescriptor) entry.getKey();
Vector excludedMethods = (Vector) entry.getValue();
MethodPermissionDescriptor mpd = new MethodPermissionDescriptor();
mpd.addMethodPermission(MethodPermission.getExcludedMethodPermission());
mpd.addMethods(excludedMethods);
mpNode.writeDescriptorInNode(excludeListNode, mpd, ejbDesc);
}
}
for (EjbApplicationExceptionInfo next : bundleDescriptor.getApplicationExceptions().values()) {
EjbApplicationExceptionNode node = new EjbApplicationExceptionNode();
node.writeDescriptor(assemblyNode, EjbTagNames.APPLICATION_EXCEPTION, next);
}
if (assemblyNode.hasChildNodes()) {
parentNode.appendChild(assemblyNode);
}
}
Aggregations