Search in sources :

Example 6 with IdpSession

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;
}
Also used : IdpSession(com.haulmont.cuba.security.global.IdpSession)

Example 7 with IdpSession

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;
}
Also used : IdpSession(com.haulmont.cuba.security.global.IdpSession)

Example 8 with 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;
}
Also used : IdpSession(com.haulmont.cuba.security.global.IdpSession)

Example 9 with IdpSession

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);
}
Also used : IdpSession(com.haulmont.cuba.security.global.IdpSession)

Example 10 with IdpSession

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;
}
Also used : IdpSession(com.haulmont.cuba.security.global.IdpSession)

Aggregations

IdpSession (com.haulmont.cuba.security.global.IdpSession)18 Gson (com.google.gson.Gson)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 VaadinRequest (com.vaadin.server.VaadinRequest)2 IOException (java.io.IOException)2 Principal (java.security.Principal)2 Nullable (javax.annotation.Nullable)2 HttpResponse (org.apache.http.HttpResponse)2 HttpClient (org.apache.http.client.HttpClient)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 HttpPost (org.apache.http.client.methods.HttpPost)2 HttpClientConnectionManager (org.apache.http.conn.HttpClientConnectionManager)2 BasicResponseHandler (org.apache.http.impl.client.BasicResponseHandler)2 BasicHttpClientConnectionManager (org.apache.http.impl.conn.BasicHttpClientConnectionManager)2 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)2 Test (org.junit.Test)2 AuthenticationDetails (com.haulmont.cuba.security.auth.AuthenticationDetails)1 LoginPasswordCredentials (com.haulmont.cuba.security.auth.LoginPasswordCredentials)1 User (com.haulmont.cuba.security.entity.User)1