try { AuthScope scope = new AuthScope(ANY_HOST, ANY_PORT, ANY_REALM, HTTPAuthPolicy.SSL); insert(new Entry(ANY_PRINCIPAL, scope, creds)); } catch (HTTPException he) { log.error("HTTPAuthStore: could not insert default SSL data");
public void print(PrintWriter p) throws IOException { List<Entry> elist = getAllRows(); for(int i = 0; i < elist.size(); i++) { Entry e = elist.get(i); p.printf("[%02d] %s%n", i, e.toString()); } }
/** * @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; }
static synchronized protected void defineCredentialsProvider(String principal, AuthScope scope, CredentialsProvider provider, HTTPAuthStore store) { // Add/remove entry to AuthStore try { if(provider == null) {//remove store.remove(new HTTPAuthStore.Entry(principal, scope, provider)); } else { // add store.insert(new HTTPAuthStore.Entry(principal, scope, provider)); } } catch (HTTPException he) { log.error("HTTPSession.setCredentialsProvider failed"); } }
/** * @param scope * @param provider * @return old provider if entry already existed and was replaced, else null. */ synchronized public CredentialsProvider insert(String principal, AuthScope scope, CredentialsProvider provider) throws HTTPException { return insert(new Entry(principal, scope, provider)); }
public boolean equals(Object o) { if(!(o instanceof Entry)) return false; return (compareTo((Entry)o) == 0); }