com.microsoft.tfs.core.httpclient.auth
Class BasicScheme

java.lang.Object
  extended by com.microsoft.tfs.core.httpclient.auth.AuthorizationHeaderScheme
      extended by com.microsoft.tfs.core.httpclient.auth.RFC2617Scheme
          extended by com.microsoft.tfs.core.httpclient.auth.BasicScheme
All Implemented Interfaces:
AuthScheme
Direct Known Subclasses:
PreemptiveBasicScheme

public class BasicScheme
extends RFC2617Scheme

Basic authentication scheme as defined in RFC 2617.


Field Summary
 
Fields inherited from class com.microsoft.tfs.core.httpclient.auth.AuthorizationHeaderScheme
HOST_CHALLENGE_HEADER, HOST_RESPONSE_HEADER, PROXY_CHALLENGE_HEADER, PROXY_RESPONSE_HEADER
 
Constructor Summary
BasicScheme()
          Default constructor for the basic authetication scheme.
BasicScheme(java.lang.String challenge)
          Deprecated. Use parameterless constructor and AuthScheme.processChallenge(String) method
 
Method Summary
 java.lang.String authenticate(AuthScope authscope, Credentials credentials, HttpMethod method)
          Produces basic authorization string for the given set of Credentials.
static java.lang.String authenticate(UsernamePasswordCredentials credentials)
          Deprecated. Use authenticate(UsernamePasswordCredentials, String) Returns a basic Authorization header value for the given UsernamePasswordCredentials.
static java.lang.String authenticate(UsernamePasswordCredentials credentials, java.lang.String charset)
          Returns a basic Authorization header value for the given UsernamePasswordCredentials and charset.
 java.lang.String getSchemeName()
          Returns textual designation of the basic authentication scheme.
 boolean isComplete()
          Tests if the Basic authentication process has been completed.
 boolean isConnectionBased()
          Returns false.
 void processChallenge(java.lang.String challenge)
          Processes the Basic challenge.
 boolean supportsCredentials(Credentials credentials)
          Determines whether this auth scheme supports credentials of the given type.
 
Methods inherited from class com.microsoft.tfs.core.httpclient.auth.RFC2617Scheme
getID, getParameter, getParameters, getRealm
 
Methods inherited from class com.microsoft.tfs.core.httpclient.auth.AuthorizationHeaderScheme
authenticateHost, authenticateProxy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.microsoft.tfs.core.httpclient.auth.AuthScheme
authenticateHost, authenticateProxy
 

Constructor Detail

BasicScheme

public BasicScheme()
Default constructor for the basic authetication scheme.

Since:
3.0

BasicScheme

@Deprecated
public BasicScheme(java.lang.String challenge)
            throws MalformedChallengeException
Deprecated. Use parameterless constructor and AuthScheme.processChallenge(String) method

Constructor for the basic authetication scheme.

Parameters:
challenge - authentication challenge
Throws:
MalformedChallengeException - is thrown if the authentication challenge is malformed
Method Detail

supportsCredentials

public boolean supportsCredentials(Credentials credentials)
Description copied from interface: AuthScheme
Determines whether this auth scheme supports credentials of the given type. For example, NegotiateScheme only supports DefaultNTCredentials.

Returns:
true if these credentials are supported, false otherwise

getSchemeName

public java.lang.String getSchemeName()
Returns textual designation of the basic authentication scheme.

Returns:
basic

processChallenge

public void processChallenge(java.lang.String challenge)
                      throws MalformedChallengeException
Processes the Basic challenge.

Specified by:
processChallenge in interface AuthScheme
Overrides:
processChallenge in class RFC2617Scheme
Parameters:
challenge - the challenge string
Throws:
MalformedChallengeException - is thrown if the authentication challenge is malformed
Since:
3.0

isComplete

public boolean isComplete()
Tests if the Basic authentication process has been completed.

Returns:
true if Basic authorization has been processed, false otherwise.
Since:
3.0

isConnectionBased

public boolean isConnectionBased()
Returns false. Basic authentication scheme is request based.

Returns:
false.
Since:
3.0

authenticate

public java.lang.String authenticate(AuthScope authscope,
                                     Credentials credentials,
                                     HttpMethod method)
                              throws AuthenticationException
Produces basic authorization string for the given set of Credentials.

Specified by:
authenticate in class AuthorizationHeaderScheme
Parameters:
credentials - The set of credentials to be used for athentication
method - The method being authenticated
Returns:
a basic authorization string
Throws:
InvalidCredentialsException - if authentication credentials are not valid or not applicable for this authentication scheme
AuthenticationException - if authorization string cannot be generated due to an authentication failure
Since:
3.0

authenticate

@Deprecated
public static java.lang.String authenticate(UsernamePasswordCredentials credentials)
Deprecated. Use authenticate(UsernamePasswordCredentials, String) Returns a basic Authorization header value for the given UsernamePasswordCredentials.

Parameters:
credentials - The credentials to encode.
Returns:
a basic authorization string

authenticate

public static java.lang.String authenticate(UsernamePasswordCredentials credentials,
                                            java.lang.String charset)
Returns a basic Authorization header value for the given UsernamePasswordCredentials and charset.

Parameters:
credentials - The credentials to encode.
charset - The charset to use for encoding the credentials
Returns:
a basic authorization string
Since:
3.0


© 2015 Microsoft. All rights reserved.