public boolean isDisabled(String id) { if (size() == 0) { // The security system is not active, so nothing can have // been "disabled" return false; } else { Set<String> s = current().getDisabledSubsystems(); if (s == null || id == null || !s.contains(id)) { return false; } return true; } } }
public Principal principal() { if (principalHolder.size() == 0) { return null; } else { EventContext ec = principalHolder.getCurrentEventContext(); String session = ec.getCurrentSessionUuid(); return new Principal(session); } }
/** * Executes a {@link SqlWork} in transaction. * * @param work * Non-null. * @return See above. */ public Object executeSql(final SqlWork work) { if (principalHolder.size() > 0) { throw new IllegalStateException( "Currently logged in. \n" + "JDBC will then take part in transaction directly. \n" + "Please have the proper JDBC or data source injected."); } ProxyFactory factory = new ProxyFactory(); factory.setTarget(work); factory.setInterfaces(new Class[] { SqlWork.class }); factory.addAdvice(advices.get(2)); // TX FIXME SqlWork wrapper = (SqlWork) factory.getProxy(); return wrapper.doWork(this.sqlAction); }
private Principal clearAndCheckPrincipal() { // clear even if this fails. (make SecuritySystem unusable) invalidateEventContext(); if (cd.size() == 0) { throw new SecurityViolation( "Principal is null. Not logged in to SecuritySystem."); } final Principal p = cd.getLast(); if (p.getName() == null) { throw new InternalException( "Principal.name is null. Security system failure."); } return p; }
/** * Called in the main server (Blitz-0) in order to create a PIXELDATA * {@link EventLog} which will get processed by PixelData-0. */ public void onApplicationEvent(final MissingPyramidMessage mpm) { if (readOnly.isReadOnlyDb()) { log.debug("Ignored: " + mpm); return; } log.info("Received: " + mpm); // #5232. If this is called without an active event, then throw // an exception since a call to Executor should wrap whatever the // invoker is doing. final CurrentDetails cd = executor.getContext().getBean(CurrentDetails.class); if (cd.size() <= 0) { throw new InternalException("Not logged in."); } final EventContext ec = cd.getCurrentEventContext(); if (null == ec.getCurrentUserId()) { throw new InternalException("No user! Must be wrapped by call to Executor?"); } Future<EventLog> future = this.executor.submit(cd.getContext(), new Callable<EventLog>(){ public EventLog call() throws Exception { return makeEvent(ec, mpm); }}); this.executor.get(future); }