public boolean isUserArchitect() { try { return ejbContext.isCallerInRole("architect"); } catch (Exception e) { e.printStackTrace(); } return false; }
@Override public boolean hasRole(String role) { return context.isCallerInRole(role); }
public boolean isUserInRole(String role) { EJBContext ejbContext = getAttachment(EJBContext.class); boolean isUserInRole = ejbContext.isCallerInRole(role); return isUserInRole; } }
public static final boolean inRole(String role) { EJBContext context = ThreadLocalServiceSecurityManager.get(); if (context == null) { return false; } return context.isCallerInRole(role); }
private static void assertClientSecurityContext(TransactionPhase phase) { assertTrue(ejbContext.isCallerInRole("student")); assertTrue(!ejbContext.isCallerInRole("printer")); toner.spill(); try { printer.tryAccess(); fail("Transactional observer method was NOT called within the same client security context."); } catch (javax.ejb.EJBAccessException expected) { // OK } ActionSequence.addAction(phase.toString()); } }
boolean isInRole = false; try { isInRole = ejbcontext.isCallerInRole(entry); } catch (Exception ex) { if(_logger.isLoggable(Level.FINE)) {
public static boolean isCallerInRole(String role) { Subject subject = getSubject(); if (hasPermission(subject, new WebRoleRefPermission("", role))) { return true; } EJBContext ejbContext = getEJBContext(); if (ejbContext != null) { // We're called from an EJB // To ask for the permission, get the EJB name first. // Unlike the Servlet container there's no automatic mapping // to a global ("") name. String ejbName = getCurrentEJBName(ejbContext); if (ejbName != null) { return hasPermission(subject, new EJBRoleRefPermission(ejbName, role)); } // EJB name not supported for current container, fallback to going fully through // ejbContext return ejbContext.isCallerInRole(role); } return false; }
public static boolean isCallerInRole(String role) { Subject subject = getSubject(); if (hasPermission(subject, new WebRoleRefPermission("", role))) { return true; } EJBContext ejbContext = getEJBContext(); if (ejbContext != null) { // We're called from an EJB // To ask for the permission, get the EJB name first. // Unlike the Servlet container there's no automatic mapping // to a global ("") name. String ejbName = getCurrentEJBName(ejbContext); if (ejbName != null) { return hasPermission(subject, new EJBRoleRefPermission(ejbName, role)); } // EJB name not supported for current container, fallback to going fully through // ejbContext return ejbContext.isCallerInRole(role); } return false; }