當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthState.getCredentials方法代碼示例

本文整理匯總了Java中org.apache.http.auth.AuthState.getCredentials方法的典型用法代碼示例。如果您正苦於以下問題:Java AuthState.getCredentials方法的具體用法?Java AuthState.getCredentials怎麽用?Java AuthState.getCredentials使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.auth.AuthState的用法示例。


在下文中一共展示了AuthState.getCredentials方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAuthPrincipal

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private static Principal getAuthPrincipal(final AuthState authState) {
    AuthScheme scheme = authState.getAuthScheme();
    if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
        Credentials creds = authState.getCredentials();
        if (creds != null) {
            return creds.getUserPrincipal();
        }
    }
    return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:DefaultUserTokenHandler.java

示例2: getAuthPrincipal

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private static Principal getAuthPrincipal(final AuthState authState) {
    final AuthScheme scheme = authState.getAuthScheme();
    if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
        final Credentials creds = authState.getCredentials();
        if (creds != null) {
            return creds.getUserPrincipal();
        }
    }
    return null;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:11,代碼來源:DefaultUserTokenHandler.java

示例3: process

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
public void process(final HttpRequest request, final HttpContext context) 
        throws HttpException, IOException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }

    if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
        return;
    }
    
    // Obtain authentication state
    AuthState authState = (AuthState) context.getAttribute(
            ClientContext.PROXY_AUTH_STATE);
    if (authState == null) {
        return;
    }

    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null) {
        return;
    }
    
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        this.log.debug("User credentials not available");
        return;
    }
    if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
        try {
            request.addHeader(authScheme.authenticate(creds, request));
        } catch (AuthenticationException ex) {
            if (this.log.isErrorEnabled()) {
                this.log.error("Proxy authentication error: " + ex.getMessage());
            }
        }
    }
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:41,代碼來源:RequestProxyAuthentication.java

示例4: getAuthPrincipal

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private static Principal getAuthPrincipal(final AuthState authState) {
    AuthScheme scheme = authState.getAuthScheme();
    if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
        Credentials creds = authState.getCredentials();
        if (creds != null) {
            return creds.getUserPrincipal(); 
        }
    }
    return null;
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:11,代碼來源:DefaultUserTokenHandler.java

示例5: updateAuthState

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private void updateAuthState(
    final AuthState authState,
    final HttpHost host,
    final CredentialsProvider credsProvider) {

  if (!authState.isValid()) {
    return;
  }

  String hostname = host.getHostName();
  int port = host.getPort();
  if (port < 0) {
    Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
    port = scheme.getDefaultPort();
  }

  AuthScheme authScheme = authState.getAuthScheme();
  AuthScope authScope = new AuthScope(
      hostname,
      port,
      authScheme.getRealm(),
      authScheme.getSchemeName());

  if (this.log.isDebugEnabled()) {
    this.log.debug("Authentication scope: " + authScope);
  }
  Credentials creds = authState.getCredentials();
  if (creds == null) {
    creds = credsProvider.getCredentials(authScope);
    if (this.log.isDebugEnabled()) {
      if (creds != null) {
        this.log.debug("Found credentials");
      } else {
        this.log.debug("Credentials not found");
      }
    }
  } else {
    if (authScheme.isComplete()) {
      this.log.debug("Authentication failed");
      creds = null;
    }
  }
  authState.setAuthScope(authScope);
  authState.setCredentials(creds);
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:46,代碼來源:DefaultRequestDirector.java

示例6: process

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
public void process(final HttpRequest request, final HttpContext context) 
        throws HttpException, IOException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (context == null) {
        throw new IllegalArgumentException("HTTP context may not be null");
    }

    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase("CONNECT")) {
        return;
    }
    
    if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
        return;
    }
    
    // Obtain authentication state
    AuthState authState = (AuthState) context.getAttribute(
            ClientContext.TARGET_AUTH_STATE);
    if (authState == null) {
        return;
    }

    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null) {
        return;
    }
    
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        this.log.debug("User credentials not available");
        return;
    }

    if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
        try {
            request.addHeader(authScheme.authenticate(creds, request));
        } catch (AuthenticationException ex) {
            if (this.log.isErrorEnabled()) {
                this.log.error("Authentication error: " + ex.getMessage());
            }
        }
    }
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:47,代碼來源:RequestTargetAuthentication.java

示例7: updateAuthState

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private void updateAuthState(
        final AuthState authState, 
        final HttpHost host,
        final CredentialsProvider credsProvider) {
    
    if (!authState.isValid()) {
        return;
    }
    
    String hostname = host.getHostName();
    int port = host.getPort();
    if (port < 0) {
        Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
        port = scheme.getDefaultPort();
    }
    
    AuthScheme authScheme = authState.getAuthScheme();
    AuthScope authScope = new AuthScope(
            hostname,
            port,
            authScheme.getRealm(), 
            authScheme.getSchemeName());  
    
    if (this.log.isDebugEnabled()) {
        this.log.debug("Authentication scope: " + authScope);
    }
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        creds = credsProvider.getCredentials(authScope);
        if (this.log.isDebugEnabled()) {
            if (creds != null) {
                this.log.debug("Found credentials");
            } else {
                this.log.debug("Credentials not found");
            }
        }
    } else {
        if (authScheme.isComplete()) {
            this.log.debug("Authentication failed");
            creds = null;
        }
    }
    authState.setAuthScope(authScope);
    authState.setCredentials(creds);
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:46,代碼來源:DefaultRequestDirector.java

示例8: updateAuthState

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private void updateAuthState(
        final AuthState authState,
        final HttpHost host,
        final CredentialsProvider credsProvider) {

    if (!authState.isValid()) {
        return;
    }

    String hostname = host.getHostName();
    int port = host.getPort();
    if (port < 0) {
        Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
        port = scheme.getDefaultPort();
    }

    AuthScheme authScheme = authState.getAuthScheme();
    AuthScope authScope = new AuthScope(
            hostname,
            port,
            authScheme.getRealm(),
            authScheme.getSchemeName());

    if (DEBUG) {
    	Logger.debug("Authentication scope: {}", authScope);
    }
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        creds = credsProvider.getCredentials(authScope);
        if (DEBUG) {
            if (creds != null) {
            	Logger.debug("Found credentials");
            } else {
            	Logger.debug("Credentials not found");
            }
        }
    } else {
        if (authScheme.isComplete()) {
        	if (DEBUG) {
        		Logger.debug("Authentication failed");
        	}
            creds = null;
        }
    }
    authState.setAuthScope(authScope);
    authState.setCredentials(creds);
}
 
開發者ID:cattong,項目名稱:YiBo,代碼行數:48,代碼來源:LibRequestDirector.java

示例9: updateAuthState

import org.apache.http.auth.AuthState; //導入方法依賴的package包/類
private void updateAuthState(
        final AuthState authState,
        final HttpHost host,
        final CredentialsProvider credsProvider) {

    if (!authState.isValid()) {
        return;
    }

    String hostname = host.getHostName();
    int port = host.getPort();
    if (port < 0) {
        Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
        port = scheme.getDefaultPort();
    }

    AuthScheme authScheme = authState.getAuthScheme();
    AuthScope authScope = new AuthScope(
            hostname,
            port,
            authScheme.getRealm(),
            authScheme.getSchemeName());

    if (Constants.DEBUG) {
    	logger.debug("Authentication scope: {}", authScope);
    }
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        creds = credsProvider.getCredentials(authScope);
        if (Constants.DEBUG) {
            if (creds != null) {
            	logger.debug("Found credentials");
            } else {
            	logger.debug("Credentials not found");
            }
        }
    } else {
        if (authScheme.isComplete()) {
        	if (Constants.DEBUG) {
        		logger.debug("Authentication failed");
        	}
            creds = null;
        }
    }
    authState.setAuthScope(authScope);
    authState.setCredentials(creds);
}
 
開發者ID:yibome,項目名稱:yibo-library,代碼行數:48,代碼來源:YiBoRequestDirector.java


注:本文中的org.apache.http.auth.AuthState.getCredentials方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。