value = UUID.fromString( nonce );
} catch( Exception e ) {
log.info( "couldnt parse nonce" );
return NonceValidity.INVALID;
}
Nonce n = (Nonce)memcache.get(value);
if( n == null ) {
log.info( "not found in cache" );
return NonceValidity.INVALID;
} else {
if( isExpired( n.getIssued() ) ) {
log.info( "nonce has expired; that is unusual as it should have been evicted from the cache already." );
return NonceValidity.EXPIRED;
} else {
if( nc == null ) {
log.info( "nonce ok" );
return NonceValidity.OK;
} else {
if( enableNonceCountChecking && nc <= n.getNonceCount() ) {
log.warning( "nonce-count was not greater then previous, possible replay attack. new: " + nc + " old:" + n.getNonceCount() );
return NonceValidity.INVALID;
} else {
log.info( "nonce and nonce-count ok" );
Nonce newNonce = n.increaseNonceCount( nc );
memcache.put( newNonce.getValue(), newNonce, Expiration.byDeltaSeconds(nonceValiditySeconds));
return NonceValidity.OK;
}
}
}
}