use of org.codice.ddf.security.handler.api.GuestAuthenticationToken in project alliance by codice.
the class NsiliEndpoint method getGuestSubject.
public static synchronized Subject getGuestSubject() throws SecurityServiceException {
if (guestSubject == null || Security.getInstance().tokenAboutToExpire(guestSubject)) {
String ip = DEFAULT_IP_ADDRESS;
try {
ip = InetAddress.getLocalHost().getHostAddress();
LOGGER.debug("Guest token ip: {}", ip);
} catch (UnknownHostException e) {
LOGGER.info("Could not get IP address for localhost", e);
}
String guestTokenId = ip;
GuestAuthenticationToken guestToken = new GuestAuthenticationToken(BaseAuthenticationToken.ALL_REALM, guestTokenId);
guestSubject = securityManager.getSubject(guestToken);
}
return guestSubject;
}
use of org.codice.ddf.security.handler.api.GuestAuthenticationToken in project ddf by codice.
the class Security method getGuestSubject.
/**
* Gets the guest {@link Subject} associated with the specified IP. Uses a cached subject when possible since the subject
* will not change between calls.
*
* @return system's {@link Subject}
*/
public Subject getGuestSubject(String ipAddress) {
Subject subject = null;
GuestAuthenticationToken token = new GuestAuthenticationToken(BaseAuthenticationToken.DEFAULT_REALM, ipAddress);
LOGGER.debug("Getting new Guest user token for {}", ipAddress);
try {
SecurityManager securityManager = getSecurityManager();
if (securityManager != null) {
subject = securityManager.getSubject(token);
}
} catch (SecurityServiceException sse) {
LOGGER.info("Unable to request subject for guest user.", sse);
}
return subject;
}
Aggregations