@AroundInvoke public Object invoke(final InvocationContext ic) throws Exception { if (SystemInstance.get().isDefaultProfile() || !SystemInstance.get().getOptions().get(OPENEJB_INTERNAL_BEANS_SECURITY_ENABLED, true)) { return ic.proceed(); } final SecurityService<?> ss = SystemInstance.get().getComponent(Assembler.class).getSecurityService(); for (final String role : ROLES) { if (ss.isCallerInRole(role)) { return ic.proceed(); } } throw new SecurityException("to invoke this EJB you need to get the right permission"); } }
@AroundInvoke public Object invoke(final InvocationContext ic) throws Exception { if (SystemInstance.get().isDefaultProfile() || !SystemInstance.get().getOptions().get(OPENEJB_INTERNAL_BEANS_SECURITY_ENABLED, true)) { return ic.proceed(); } final SecurityService<?> ss = SystemInstance.get().getComponent(Assembler.class).getSecurityService(); for (final String role : ROLES) { if (ss.isCallerInRole(role)) { return ic.proceed(); } } throw new SecurityException("to invoke this EJB you need to get the right permission"); } }
public static synchronized void init(final Properties properties) throws Exception { if (initialized) { return; } system.set(new SystemInstance(properties)); // WARNING: reverse order since we don't overwrite existing entries readSystemProperties(get().currentProfile()); readSystemProperties(); readUserSystemProperties(); // if the user read System.getProperties() instead of our properties, used in bval-tomee tck for instance System.getProperties().putAll(system.get().getProperties()); initialized = true; get().setProperty("openejb.profile.custom", Boolean.toString(!get().isDefaultProfile())); initDefaultComponents(); }
public static synchronized void init(final Properties properties) throws Exception { if (initialized) { return; } system = new SystemInstance(properties); // WARNING: reverse order since we don't overwrite existing entries readSystemProperties(get().currentProfile()); readSystemProperties(); readUserSystemProperties(); // if the user read System.getProperties() instead of our properties, used in bval-tomee tck for instance System.getProperties().putAll(system.getProperties()); initialized = true; get().setProperty("openejb.profile.custom", Boolean.toString(!get().isDefaultProfile())); }
public void start(final StandardServer server) { if (SystemInstance.get().isDefaultProfile()) { // add user tomee is no user are specified try { final NamingResourcesImpl resources = server.getGlobalNamingResources(); final ContextResource userDataBaseResource = resources.findResource("UserDatabase"); final UserDatabase db = (UserDatabase) server.getGlobalNamingContext().lookup(userDataBaseResource.getName()); if (!db.getUsers().hasNext() && db instanceof MemoryUserDatabase) { final MemoryUserDatabase mudb = (MemoryUserDatabase) db; final boolean oldRo = mudb.getReadonly(); try { ((MemoryUserDatabase) db).setReadonly(false); db.createRole("tomee-admin", "tomee admin role"); db.createUser("tomee", "tomee", "TomEE"); db.findUser("tomee").addRole(db.findRole("tomee-admin")); } finally { mudb.setReadonly(oldRo); } } } catch (final Throwable t) { // no-op } } }