/** * @param entry * @return old entry if entry existed and was removed */ synchronized public Entry remove(Entry entry) throws HTTPException { Entry found = null; if(entry == null) throw new HTTPException("HTTPAuthStore.remove: invalid entry: " + entry); for(Entry e : rows) { if(equivalent(e, entry)) { found = e; break; } } if(found != null) rows.remove(found); return (found); }
/** * @param entry * @return old provider if entry already existed and was replaced, else null. */ synchronized public CredentialsProvider insert(Entry entry) throws HTTPException { Entry found = null; if(entry == null) throw new HTTPException("HTTPAuthStore.insert: invalid entry: " + entry); for(Entry e : rows) { if(equivalent(e, entry)) { found = e; break; } } // If the entry already exists, then overwrite it and return old CredentialsProvider old = null; if(found != null) { old = entry.provider; found.provider = entry.provider; } else { Entry newentry = new Entry(ANY_PRINCIPAL, entry.scope, entry.provider); rows.add(newentry); } return old; }