Package org.codice.ddf.security
Interface Security
public interface Security
-
Method Summary
Modifier and TypeMethodDescriptiongetGuestSubject(String ipAddress) Gets the guestSubjectassociated with the specified IP.getSubject(String username, String password, String ip) Gets theSubjectassociated with this system.booleanDetermines if the current JavaSubjecthas the admin role.<T> TrunAsAdmin(PrivilegedAction<T> action) <T> TrunAsAdminWithException(PrivilegedExceptionAction<T> action) <T> TrunWithSubjectOrElevate(Callable<T> codeToRun)
-
Method Details
-
getSubject
-
javaSubjectHasAdminRole
boolean javaSubjectHasAdminRole()Determines if the current JavaSubjecthas the admin role.- Returns:
trueif the JavaSubjectexists and has the admin role,falseotherwise- Throws:
SecurityException- if a security manager exists and theAuthPermission("getSubject")permission is not authorized
-
runWithSubjectOrElevate
<T> T runWithSubjectOrElevate(Callable<T> codeToRun) throws SecurityServiceException, InvocationTargetException Runs theCallablein the current thread as the current security framework'sSubject. If the security framework'sSubjectis not currently set and the Java Subject contains the admin role, elevates and runs theCallableas the systemSubject.- Type Parameters:
T- type of the returned value- Parameters:
codeToRun- code to run- Returns:
- value returned by the
Callable - Throws:
SecurityServiceException- if the current subject didn' have enough permissions to run the codeSecurityException- if a security manager exists and theAuthPermission("getSystemSubject")orAuthPermission("getSubject")permissions are not authorizedInvocationTargetException- wraps any exception thrown byCallable.call().Callableexception can be retrieved using theInvocationTargetException.getCause().
-
getSystemSubject
Gets theSubjectassociated with this system. Uses a cached subject since the subject will not change between calls.- Returns:
- system's
Subjectornullif unable to get the system'sSubject - Throws:
SecurityException- if a security manager exists and theAuthPermission("getSystemSubject")orAuthPermission("getSubject")permissions are not authorized
-
getGuestSubject
Gets the guestSubjectassociated with the specified IP. Uses a cached subject when possible since the subject will not change between calls.- Returns:
- system's
Subject
-
runAsAdmin
-
runAsAdminWithException
- Throws:
PrivilegedActionException
-
getSystemKeyStore
KeyStore getSystemKeyStore()
-