use of org.apache.openejb.jee.MethodPermission$JAXB.writeMethodPermission in project tomee by apache.
the class AssemblyDescriptor$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final AssemblyDescriptor assemblyDescriptor, RuntimeContext context) throws Exception {
if (assemblyDescriptor == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (AssemblyDescriptor.class != assemblyDescriptor.getClass()) {
context.unexpectedSubclass(writer, assemblyDescriptor, AssemblyDescriptor.class);
return;
}
context.beforeMarshal(assemblyDescriptor, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = assemblyDescriptor.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(assemblyDescriptor, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: securityRole
final List<SecurityRole> securityRole = assemblyDescriptor.securityRole;
if (securityRole != null) {
for (final SecurityRole securityRoleItem : securityRole) {
if (securityRoleItem != null) {
writer.writeStartElement(prefix, "security-role", "http://java.sun.com/xml/ns/javaee");
writeSecurityRole(writer, securityRoleItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "securityRole");
}
}
}
// ELEMENT: methodPermission
final List<MethodPermission> methodPermission = assemblyDescriptor.methodPermission;
if (methodPermission != null) {
for (final MethodPermission methodPermissionItem : methodPermission) {
if (methodPermissionItem != null) {
writer.writeStartElement(prefix, "method-permission", "http://java.sun.com/xml/ns/javaee");
writeMethodPermission(writer, methodPermissionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "methodPermission");
}
}
}
// ELEMENT: containerTransaction
final List<ContainerTransaction> containerTransaction = assemblyDescriptor.containerTransaction;
if (containerTransaction != null) {
for (final ContainerTransaction containerTransactionItem : containerTransaction) {
if (containerTransactionItem != null) {
writer.writeStartElement(prefix, "container-transaction", "http://java.sun.com/xml/ns/javaee");
writeContainerTransaction(writer, containerTransactionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "containerTransaction");
}
}
}
// ELEMENT: containerConcurrency
final List<ContainerConcurrency> containerConcurrency = assemblyDescriptor.containerConcurrency;
if (containerConcurrency != null) {
for (final ContainerConcurrency containerConcurrencyItem : containerConcurrency) {
if (containerConcurrencyItem != null) {
writer.writeStartElement(prefix, "container-concurrency", "http://java.sun.com/xml/ns/javaee");
writeContainerConcurrency(writer, containerConcurrencyItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "containerConcurrency");
}
}
}
// ELEMENT: interceptorBinding
final List<InterceptorBinding> interceptorBinding = assemblyDescriptor.interceptorBinding;
if (interceptorBinding != null) {
for (final InterceptorBinding interceptorBindingItem : interceptorBinding) {
if (interceptorBindingItem != null) {
writer.writeStartElement(prefix, "interceptor-binding", "http://java.sun.com/xml/ns/javaee");
writeInterceptorBinding(writer, interceptorBindingItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "interceptorBinding");
}
}
}
// ELEMENT: messageDestination
final List<MessageDestination> messageDestination = assemblyDescriptor.messageDestination;
if (messageDestination != null) {
for (final MessageDestination messageDestinationItem : messageDestination) {
if (messageDestinationItem != null) {
writer.writeStartElement(prefix, "message-destination", "http://java.sun.com/xml/ns/javaee");
writeMessageDestination(writer, messageDestinationItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "messageDestination");
}
}
}
// ELEMENT: excludeList
final ExcludeList excludeList = assemblyDescriptor.excludeList;
if (excludeList != null) {
writer.writeStartElement(prefix, "exclude-list", "http://java.sun.com/xml/ns/javaee");
writeExcludeList(writer, excludeList, context);
writer.writeEndElement();
}
// ELEMENT: applicationException
final KeyedCollection<String, ApplicationException> applicationException = assemblyDescriptor.applicationException;
if (applicationException != null) {
for (final ApplicationException applicationExceptionItem : applicationException) {
if (applicationExceptionItem != null) {
writer.writeStartElement(prefix, "application-exception", "http://java.sun.com/xml/ns/javaee");
writeApplicationException(writer, applicationExceptionItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(assemblyDescriptor, "applicationException");
}
}
}
context.afterMarshal(assemblyDescriptor, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.MethodPermission$JAXB.writeMethodPermission in project tomee by apache.
the class StatefulSecurityPermissionsTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
final SecurityServiceInfo securityServiceInfo = config.configureService(SecurityServiceInfo.class);
securityServiceInfo.className = TestSecurityService.class.getName();
assembler.createSecurityService(securityServiceInfo);
final TestSecurityService securityService = (TestSecurityService) SystemInstance.get().getComponent(SecurityService.class);
securityService.login("foo", "Jazz", "Rock", "Reggae", "HipHop");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
final List<MethodPermission> permissions = ejbJar.getAssemblyDescriptor().getMethodPermission();
permissions.add(new MethodPermission("*", "Color", "*", "Foo"));
permissions.add(new MethodPermission("*", "Color", "create").setUnchecked());
permissions.add(new MethodPermission("*", "Color", "ejbCreate").setUnchecked());
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
final InitialContext context = new InitialContext();
{
final ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
assertEquals("Jazz", color.color());
try {
color.color((Object) null);
} catch (final EJBAccessException e) {
assertEquals("Excluded", actual.get());
}
assertEquals("Rock", color.color((String) null));
assertEquals("Unchecked", color.color((Boolean) null));
assertEquals("Reggae", color.color((Integer) null));
}
}
use of org.apache.openejb.jee.MethodPermission$JAXB.writeMethodPermission in project tomee by apache.
the class EjbJarInfoBuilder method initMethodPermissions.
private void initMethodPermissions(final EjbModule jar, final Map ejbds, final EjbJarInfo ejbJarInfo) {
final List<MethodPermission> methodPermissions = jar.getEjbJar().getAssemblyDescriptor().getMethodPermission();
for (final MethodPermission mp : methodPermissions) {
final MethodPermissionInfo info = new MethodPermissionInfo();
info.description = mp.getDescription();
info.roleNames.addAll(mp.getRoleName());
info.methods.addAll(getMethodInfos(mp.getMethod(), ejbds));
info.unchecked = mp.getUnchecked();
ejbJarInfo.methodPermissions.add(info);
}
}
Aggregations