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");
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 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; }
/** * @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)); }