AuthPolicy.AUTH_SCHEME_PRIORITY); if (authPrefs == null || authPrefs.isEmpty()) { authPrefs = AuthPolicy.getDefaultAuthPrefs(); authscheme = AuthPolicy.getAuthScheme(id); } catch (IllegalStateException e) { throw new AuthChallengeException(e.getMessage());
/** * Preemptively assigns Basic authentication scheme. */ public void setPreemptive() { if (!this.preemptive) { if (this.authScheme != null) { throw new IllegalStateException("Authentication state already initialized"); } this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME); this.preemptive = true; } }
/** * Register a new authentication scheme. * * @param name * @param scheme */ public static void registerScheme(String name, Class<? extends AuthScheme> scheme) { AuthPolicy.registerAuthScheme(name, scheme); }
/** * Configure the client to use the default authentication scheme settings */ public AbderaClient setAuthenticationSchemeDefaults() { List authPrefs = AuthPolicy.getDefaultAuthPrefs(); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); return this; }
/** * Unregister a specific authentication scheme * * @param name The name of the authentication scheme (e.g. "basic", "digest", etc) */ public static void unregisterScheme(String name) { AuthPolicy.unregisterAuthScheme(name); }
/** * Preemptively assigns Basic authentication scheme. */ public void setPreemptive() { if (!this.preemptive) { if (this.authScheme != null) { throw new IllegalStateException("Authentication state already initialized"); } this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME); this.preemptive = true; } }
protected void setupAuthentication( final HttpClient client, final String user, final String password ) { UsernamePasswordCredentials creds = new UsernamePasswordCredentials( user, password ); List<String> policies = new ArrayList<String>(); policies.add( NxBasicScheme.POLICY_NAME ); AuthPolicy.registerAuthScheme( NxBasicScheme.POLICY_NAME, NxBasicScheme.class ); client.getParams().setParameter( AuthPolicy.AUTH_SCHEME_PRIORITY, policies ); client.getState().setCredentials( AuthScope.ANY, creds ); }
AuthPolicy.AUTH_SCHEME_PRIORITY); if (authPrefs == null || authPrefs.isEmpty()) { authPrefs = AuthPolicy.getDefaultAuthPrefs(); authscheme = AuthPolicy.getAuthScheme(id); } catch (IllegalStateException e) { throw new AuthChallengeException(e.getMessage());
/** * Preemptively assigns Basic authentication scheme. */ public void setPreemptive() { if (!this.preemptive) { if (this.authScheme != null) { throw new IllegalStateException("Authentication state already initialized"); } this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME); this.preemptive = true; } }
/** * Enable NTLM authentication on http client * * @param httpClient HttpClient instance */ public static void addNTLM(HttpClient httpClient) { // disable preemptive authentication httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, false); // register the jcifs based NTLMv2 implementation AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, NTLMv2Scheme.class); ArrayList<String> authPrefs = new ArrayList<String>(); authPrefs.add(AuthPolicy.NTLM); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // make sure NTLM is always active needNTLM = true; // separate domain from username in credentials AuthScope authScope = new AuthScope(null, -1); NTCredentials credentials = (NTCredentials) httpClient.getState().getCredentials(authScope); if (credentials != null && credentials.getDomain() == null) { setCredentials(httpClient, credentials.getUserName(), credentials.getPassword()); } }
AuthPolicy.AUTH_SCHEME_PRIORITY); if (authPrefs == null || authPrefs.isEmpty()) { authPrefs = AuthPolicy.getDefaultAuthPrefs(); authscheme = AuthPolicy.getAuthScheme(id); } catch (IllegalStateException e) { throw new AuthChallengeException(e.getMessage());
/** * Preemptively assigns Basic authentication scheme. */ public void setPreemptive() { if (!this.preemptive) { if (this.authScheme != null) { throw new IllegalStateException("Authentication state already initialized"); } this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME); this.preemptive = true; } }
@Override public void applyTo(OwnCloudClient client) { AuthPolicy.registerAuthScheme(BearerAuthScheme.AUTH_POLICY, BearerAuthScheme.class); List<String> authPrefs = new ArrayList<String>(1); authPrefs.add(BearerAuthScheme.AUTH_POLICY); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); client.getParams().setAuthenticationPreemptive(true); client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET); client.getState().setCredentials( AuthScope.ANY, new BearerCredentials(mAccessToken) ); }
AuthPolicy.AUTH_SCHEME_PRIORITY); if (authPrefs == null || authPrefs.isEmpty()) { authPrefs = AuthPolicy.getDefaultAuthPrefs(); authscheme = AuthPolicy.getAuthScheme(id); } catch (IllegalStateException e) { throw new AuthChallengeException(e.getMessage());
/** * Preemptively assigns Basic authentication scheme. */ public void setPreemptive() { if (!this.preemptive) { if (this.authScheme != null) { throw new IllegalStateException("Authentication state already initialized"); } this.authScheme = AuthPolicy.getAuthScheme(PREEMPTIVE_AUTH_SCHEME); this.preemptive = true; } }
AuthPolicy.registerAuthScheme("Negotiate", SpNegoScheme.class); ArrayList<String> authPrefs = new ArrayList<String>(); authPrefs.add("Negotiate");
AuthPolicy.AUTH_SCHEME_PRIORITY); if (authPrefs == null || authPrefs.isEmpty()) { authPrefs = AuthPolicy.getDefaultAuthPrefs(); authscheme = AuthPolicy.getAuthScheme(id); } catch (IllegalStateException e) { throw new AuthChallengeException(e.getMessage());