{
if( cacheJndiName == null )
throw new LoginException("Required cacheJndiName option not set");
InitialContext iniCtx = new InitialContext();
CachePolicy cache = (CachePolicy) iniCtx.lookup(cacheJndiName);
SRPSessionKey key;
if( userPrincipal instanceof SRPPrincipal )
{
SRPPrincipal srpPrincpal = (SRPPrincipal) userPrincipal;
key = new SRPSessionKey(username, srpPrincpal.getSessionID());
}
else
{
key = new SRPSessionKey(username);
}
Object cacheCredential = cache.get(key);
if( cacheCredential == null )
{
throw new LoginException("No SRP session found for: "+key);