Search in sources :

Example 1 with ProcessInitiatorEntry

use of com.walmartlabs.concord.server.process.queue.ProcessInitiatorEntry in project concord by walmartlabs.

the class SessionKeyRealm method doGetAuthenticationInfo.

@Override
@WithTimer
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    SessionKey t = (SessionKey) token;
    PartialProcessKey processKey = PartialProcessKey.from(t.getInstanceId());
    try {
        ProcessInitiatorEntry p = processQueueManager.getInitiator(processKey);
        if (p == null) {
            log.warn("doGetAuthenticationInfo -> process not found: {}", t.getInstanceId());
            return null;
        }
        if (p.initiatorId() == null) {
            log.warn("doGetAuthenticationInfo -> initiator not found: {}", t.getInstanceId());
            return null;
        }
        if (isFinished(p)) {
            log.warn("doGetAuthenticationInfo -> process is finished: {}", t.getInstanceId());
            return null;
        }
        PrincipalCollection principals = getPrincipals(processKey);
        return new SimpleAccount(principals, t.getInstanceId(), getName());
    } catch (Exception e) {
        log.error("doGetAuthenticationInfo ['{}'] -> error", t.getInstanceId(), e);
        throw e;
    }
}
Also used : SimpleAccount(org.apache.shiro.authc.SimpleAccount) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessInitiatorEntry(com.walmartlabs.concord.server.process.queue.ProcessInitiatorEntry) PrincipalCollection(org.apache.shiro.subject.PrincipalCollection) SimplePrincipalCollection(org.apache.shiro.subject.SimplePrincipalCollection) AuthenticationException(org.apache.shiro.authc.AuthenticationException) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Aggregations

ProcessInitiatorEntry (com.walmartlabs.concord.server.process.queue.ProcessInitiatorEntry)1 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)1 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 SimpleAccount (org.apache.shiro.authc.SimpleAccount)1 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)1 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)1