use of com.walmartlabs.concord.server.security.apikey.ApiKey in project concord by walmartlabs.
the class ConcordRememberMeManager method rememberIdentity.
@Override
protected void rememberIdentity(Subject subject, PrincipalCollection src) {
SimplePrincipalCollection dst = new SimplePrincipalCollection();
// keep only the specific types of principals to keep the cookie small
for (String realmName : src.getRealmNames()) {
Collection<?> principals = src.fromRealm(realmName);
for (Object p : principals) {
if (p instanceof UsernamePasswordToken || p instanceof ApiKey) {
dst.add(p, realmName);
}
}
}
super.rememberIdentity(subject, dst);
}
use of com.walmartlabs.concord.server.security.apikey.ApiKey in project concord by walmartlabs.
the class ConcordAuthenticationHandler method createFromAuthHeader.
private AuthenticationToken createFromAuthHeader(HttpServletRequest req) {
// check the 'remember me' status
boolean rememberMe = Boolean.parseBoolean(req.getHeader(REMEMBER_ME_HEADER));
String h = req.getHeader(HttpHeaders.AUTHORIZATION);
if (h.startsWith(BASIC_AUTH_PREFIX)) {
// enable sessions
req.setAttribute(DefaultSubjectContext.SESSION_CREATION_ENABLED, Boolean.TRUE);
return parseBasicAuth(h, rememberMe);
} else {
boolean enableSessions = Boolean.parseBoolean(req.getHeader(ENABLE_HTTP_SESSION));
req.setAttribute(DefaultSubjectContext.SESSION_CREATION_ENABLED, enableSessions);
if (h.startsWith(BEARER_AUTH_PREFIX)) {
h = h.substring(BEARER_AUTH_PREFIX.length());
}
validateApiKey(h);
ApiKeyEntry apiKey = apiKeyDao.find(h);
if (apiKey == null) {
return new UsernamePasswordToken();
}
return new ApiKey(apiKey.getId(), apiKey.getUserId(), h, rememberMe);
}
}
Aggregations