public RunAsMetaData create(Class element) { RunAs runAs = finder.getAnnotation(element, RunAs.class); if(runAs == null) return null; RunAsMetaData metaData = new RunAsMetaData(); metaData.setRoleName(runAs.value()); Descriptions descriptions = ProcessorUtils.getDescription("RunAs("+runAs.value()+") on class: "+element.getName()); metaData.setDescriptions(descriptions); return metaData; }
@Stateless @RunAs("student") @PermitAll public class Student { @EJB private Alarm alarm; public void sleep() { alarm.createTimer(); } }
public RunAsMetaData create(Class<?> element) { RunAs runAs = finder.getAnnotation(element, RunAs.class); if(runAs == null) return null; RunAsMetaData metaData = new RunAsMetaData(); metaData.setRoleName(runAs.value()); Descriptions descriptions = ProcessorUtils.getDescription("RunAs("+runAs.value()+") on class: "+element.getName()); metaData.setDescriptions(descriptions); return metaData; }
@Stateful @RunAs("student") @PermitAll public class Student { public static String STUDENT_MESSAGE = "student message"; @Inject Event<Text> printer; public Text print() throws ExecutionException, InterruptedException { BlockingQueue<Text> sync = new LinkedBlockingQueue<>(); printer.fireAsync(new Text(STUDENT_MESSAGE)).thenAccept(sync::offer); return sync.poll(2l, TimeUnit.SECONDS); } }
"[cls] " + (cls != null ? cls.getName() : null) + "): Entry"); String annotationRunAs = annotation.value(); if (!annotationRunAs.equals("")) { List<org.apache.openejb.jee.Servlet> servlets = webApp.getServlet();
@Stateless @Interceptors(AlarmSecurityInterceptor.class) @RunAs("alarm") @RolesAllowed("student") public class Alarm { public static AtomicLong timeoutAt = null; @Resource private SessionContext ctx; public void createTimer() { ctx.getTimerService().createTimer(1l, null); } @Timeout public void timeout(Timer timer) { timeoutAt = new AtomicLong(System.currentTimeMillis()); assertTrue(!this.ctx.isCallerInRole("student")); assertTrue(!this.ctx.isCallerInRole("alarm")); } }
public void processRunAsAnnotations () throws Exception { for (Class clazz:_finder.getClassesForAnnotation(RunAs.class)) { if (!javax.servlet.Servlet.class.isAssignableFrom(clazz) && !(_pojoInstances.containsKey(clazz))) { Log.debug("Ignoring runAs notation on on-servlet class "+clazz.getName()); continue; } RunAs runAs = (RunAs)clazz.getAnnotation(RunAs.class); if (runAs != null) { String role = runAs.value(); if (role != null) { org.mortbay.jetty.plus.annotation.RunAs ra = new org.mortbay.jetty.plus.annotation.RunAs(); ra.setTargetClass(clazz); ra.setRoleName(role); _runAs.add(ra); } } } }
@Stateless @Interceptors(PrinterSecurityInterceptor.class) @RunAs("printer") @RolesAllowed("student") public class Printer { @EJB private Toner toner; public void print() { toner.spill(); } }
public void evaluate() throws Throwable { info.setRunAs(annotation.value()); final ThreadContext context = new ThreadContext(info, null); final ThreadContext old = ThreadContext.enter(context); try { next.evaluate(); } finally { ThreadContext.exit(old); } } }
@Stateless @RunAs("printer") @RolesAllowed("student") @TransactionManagement(TransactionManagementType.BEAN)
return new RunAsIdentity(runAs.value(), runAsPrincipal, extraRoles);
@Stateful @RunAs("student") @PermitAll public class Student { @EJB private Printer printer; public void printArticle() { printer.print(); } }
if (roleName == null && clazz.isAnnotationPresent(RunAs.class)) { RunAs runAs = (RunAs)clazz.getAnnotation(RunAs.class); roleName = runAs.value();
@Stateless @RunAs("printer") @RolesAllowed("student") @TransactionManagement(TransactionManagementType.BEAN)
wrapper.setRunAs(annotation.value());
@Stateless @RunAs("printer") @RolesAllowed("student") @TransactionManagement(TransactionManagementType.BEAN)
wrapper.setRunAs(annotation.value());
@Stateful @RunAs("student") @PermitAll public class Student { @EJB private Printer printer; public void printSuccess() throws Exception { printer.printSuccess(); } public void printFailure() throws Exception { printer.printFailure(); } }
wrapper.setRunAs(annotation.value());
@Stateful @RunAs("student") @PermitAll public class Student { @EJB private Printer printer; public void printSuccess() throws Exception { printer.printSuccess(); } public void printFailure() throws Exception { printer.printFailure(); } }