/** * Creates a new {@code SubjectRunnable} that, when executed, will execute the target {@code delegate}, but * guarantees that it will run associated with the specified {@code Subject}. * * @param subject the Subject to associate with the delegate's execution. * @param delegate the runnable to run. */ public SubjectRunnable(Subject subject, Runnable delegate) { this(new SubjectThreadState(subject), delegate); }
/** * Creates a new {@code SubjectContext} instance to be used to populate with subject contextual data that * will then be sent to the {@code SecurityManager} to create a new {@code Subject} instance. * * @return a new {@code SubjectContext} instance */ protected SubjectContext newSubjectContextInstance() { return new DefaultSubjectContext(); }
/** * @see Subject#getPrincipal() */ public Object getPrincipal() { return getPrimaryPrincipal(getPrincipals()); }
protected boolean hasPrincipals() { return !isEmpty(getPrincipals()); }
public boolean isSessionCreationEnabled() { Boolean val = getTypedValue(SESSION_CREATION_ENABLED, Boolean.class); return val == null || val; }
public <V> Callable<V> associateWith(Callable<V> callable) { return new SubjectCallable<V>(this, callable); }
public void setSessionCreationEnabled(boolean enabled) { nullSafePut(SESSION_CREATION_ENABLED, enabled); }
public PrincipalCollection releaseRunAs() { return popIdentity(); }
public void setAuthenticated(boolean authc) { put(AUTHENTICATED, authc); }
public SubjectCallable(Subject subject, Callable<V> delegate) { this(new SubjectThreadState(subject), delegate); }
protected SubjectContext createSubjectContext() { return new DefaultSubjectContext(); }
public SecurityManager getSecurityManager() { return getTypedValue(SECURITY_MANAGER, SecurityManager.class); }
public void setAuthenticationInfo(AuthenticationInfo info) { nullSafePut(AUTHENTICATION_INFO, info); }
public boolean isAuthenticated() { Boolean authc = getTypedValue(AUTHENTICATED, Boolean.class); return authc != null && authc; }
public void setSession(Session session) { nullSafePut(SESSION, session); }
public AuthenticationInfo getAuthenticationInfo() { return getTypedValue(AUTHENTICATION_INFO, AuthenticationInfo.class); }
public void setAuthenticationToken(AuthenticationToken token) { nullSafePut(AUTHENTICATION_TOKEN, token); }
public AuthenticationToken getAuthenticationToken() { return getTypedValue(AUTHENTICATION_TOKEN, AuthenticationToken.class); }
public String getHost() { return getTypedValue(HOST, String.class); }