use of com.haulmont.cuba.security.global.IdpSession in project cuba by cuba-platform.
the class IdpServiceBean method removeSessionAttribute.
@Override
public IdpSession removeSessionAttribute(String sessionId, String name) {
IdpSession session = sessionStore.getSession(sessionId);
if (session != null) {
Map<String, Object> attributes = session.getAttributes();
if (attributes != null) {
attributes.remove(name);
}
sessionStore.propagate(session.getId());
}
return session;
}
use of com.haulmont.cuba.security.global.IdpSession in project cuba by cuba-platform.
the class IdpSessionStoreBean method activateSessionTicket.
@Override
public IdpSession activateSessionTicket(String serviceProviderTicket) {
IdpSession idpSession;
IdpSessionTicketRecord ticketRecord;
lock.writeLock().lock();
try {
ticketRecord = sessionTickets.remove(serviceProviderTicket);
if (ticketRecord == null) {
return null;
}
String sessionId = ticketRecord.getSessionId();
IdpSessionRecord sessionInfo = sessions.get(sessionId);
idpSession = sessionInfo != null ? sessionInfo.getSession() : null;
} finally {
lock.writeLock().unlock();
}
if (idpSession != null) {
ticketRecord.setActive(false);
clusterManager.sendSync(ticketRecord);
}
return idpSession;
}
use of com.haulmont.cuba.security.global.IdpSession in project cuba by cuba-platform.
the class IdpSessionStoreBean method getSession.
@Override
public IdpSession getSession(String sessionId) {
IdpSession session;
IdpSessionRecord sessionRecord;
lock.readLock().lock();
try {
sessionRecord = sessions.get(sessionId);
session = sessionRecord != null ? sessionRecord.getSession() : null;
} finally {
lock.readLock().unlock();
}
if (sessionRecord != null) {
long now = timeSource.currentTimeMillis();
sessionRecord.setLastUsedTs(now);
if (now > sessionRecord.getLastSentTs() + sendTimeoutSec * 1000) {
sessionRecord.setLastSentTs(now);
clusterManager.send(sessionRecord);
}
}
return session;
}
use of com.haulmont.cuba.security.global.IdpSession in project cuba by cuba-platform.
the class IdpSessionStoreBean method toSessionInfo.
protected IdpSessionInfo toSessionInfo(IdpSessionRecord record) {
if (record == null) {
return null;
}
Date sinceTs = timeSource.currentTimestamp();
sinceTs.setTime(record.getSince());
Date lastUsedTs = timeSource.currentTimestamp();
lastUsedTs.setTime(record.getLastUsedTs());
IdpSession session = record.getSession();
return new IdpSessionInfo(session.getId(), session.getLogin(), session.getEmail(), session.getLocale(), sinceTs, lastUsedTs);
}
use of com.haulmont.cuba.security.global.IdpSession in project cuba by cuba-platform.
the class IdpSessionStoreBean method createServiceProviderTicket.
@Override
public String createServiceProviderTicket(String sessionId) {
lock.readLock().lock();
IdpSession session;
try {
IdpSessionRecord sessionInfo = sessions.get(sessionId);
session = sessionInfo != null ? sessionInfo.getSession() : null;
} finally {
lock.readLock().unlock();
}
if (session == null) {
return null;
}
String serviceProviderTicket = uuidSource.createUuid().toString().replace("-", "");
IdpSessionTicketRecord ticketRecord;
lock.writeLock().lock();
try {
ticketRecord = new IdpSessionTicketRecord(serviceProviderTicket, sessionId, timeSource.currentTimeMillis());
sessionTickets.put(serviceProviderTicket, ticketRecord);
} finally {
lock.writeLock().unlock();
}
clusterManager.sendSync(ticketRecord);
return serviceProviderTicket;
}
Aggregations