private static void doClearSubject() { if (subjectThreadState != null) { subjectThreadState.clear(); subjectThreadState = null; } }
/** * Binds the passed-in subject to the executing thread. Usage: * * <pre> * ThreadState state = null; * try { * state = securityService.bindSubject(subject); * // do the rest of the work as this subject * } finally { * if (state != null) * state.clear(); * } * </pre> */ @Override public ThreadState bindSubject(final Subject subject) { if (subject == null) { throw new AuthenticationRequiredException("Failed to find the authenticated user."); } ThreadState threadState = new SubjectThreadState(subject); threadState.bind(); return threadState; }
@Override public Object run() { ThreadState threadState = new SubjectThreadState(subject); threadState.bind(); try { SourceLookup sourceLookup = getSourceLookup(); String format = (String) checkNotNull(sourceLookup.get(FORMAT)); String repositoryName = (String) checkNotNull(sourceLookup.get(REPOSITORY_NAME)); VariableResolverAdapter variableResolverAdapter = variableResolverAdapterManager.get(format); @SuppressWarnings("unchecked") List<Map<String, Object>> assets = (List<Map<String, Object>>) sourceLookup .getOrDefault("assets", Collections.emptyList()); if (assets != null) { for (Map<String, Object> asset : assets) { VariableSource variableSource = variableResolverAdapter.fromSourceLookup(sourceLookup, asset); Set<String> repoNames = new HashSet<>(); repoNames.add(repositoryName); repoNames.addAll(repositoryManager.findContainingGroups(repositoryName)); return contentPermissionChecker.isPermitted(repoNames, format, BROWSE, variableSource); } } return false; } finally { threadState.clear(); } }
/** * Allows subclasses to set the currently executing {@link Subject} instance. * * @param subject the Subject instance */ protected void setSubject(Subject subject) { clearSubject(); subjectThreadState = createThreadState(subject); subjectThreadState.bind(); }
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
/** * Allows subclasses to set the currently executing {@link Subject} instance. * * @param subject the Subject instance */ protected void setSubject( Subject subject ) { doClearSubject(); subjectThreadState = new SubjectThreadState( subject ); subjectThreadState.bind(); }
private static void doClearSubject() { if ( subjectThreadState != null ) { subjectThreadState.clear(); subjectThreadState = null; } }
protected Subject newSubject(SecurityManager securityManager) { Subject subject = new Subject.Builder(securityManager).buildSubject(); threadState = new SubjectThreadState(subject); threadState.bind(); return subject; } }
state.clear();
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
/** * Sets up a security manager and subject on the current thread. * * @param subject The subject to attach to the current thread. */ public static void setSubject(Subject subject) { clearSubject(); subjectThreadState = createThreadState(subject); subjectThreadState.bind(); }
clearRequestMessage(); if (threadState != null) { threadState.clear();
/** * Allows subclasses to set the currently executing {@link Subject} instance. * * @param subject the Subject instance */ protected void setSubject(Subject subject) { clearSubject(); subjectThreadState = createThreadState(subject); subjectThreadState.bind(); }
/** Removes the subject from the current thread. */ public static void clearSubject() { if (subjectThreadState != null) { subjectThreadState.clear(); subjectThreadState = null; } }
/** * {@link ThreadState#bind Bind}s the Subject thread state, executes the target {@code Runnable} and then guarantees * the previous thread state's {@link ThreadState#restore restoration}: * <pre> * try { * threadState.{@link ThreadState#bind bind()}; * {@link #doRun doRun}(targetRunnable); * } finally { * threadState.{@link ThreadState#restore restore()} * } * </pre> */ public void run() { try { threadState.bind(); doRun(this.runnable); } finally { threadState.restore(); } }
/** * Allows subclasses to set the currently executing {@link Subject} instance. * * @param subject * the Subject instance */ protected void setSubject(Subject subject) { clearSubject(); subjectThreadState = createThreadState(subject); subjectThreadState.bind(); }
/** * Method description * */ private static void doClearSubject() { if (subjectThreadState != null) { subjectThreadState.clear(); subjectThreadState = null; } }