com.microsoft.tfs.core.credentials.internal
Class KeychainCredentialsManager

java.lang.Object
  extended by com.microsoft.tfs.core.credentials.internal.KeychainCredentialsManager
All Implemented Interfaces:
CredentialsManager

public class KeychainCredentialsManager
extends java.lang.Object
implements CredentialsManager

An CredentialsManager that can read and write passwords securely in Mac OS Keychain. Since the keychain interface requires a username, we need to store some information in the persistence store credentials provider.

Thread-safety:
thread-safe

Constructor Summary
KeychainCredentialsManager()
           
 
Method Summary
 boolean canWrite()
          Tests whether this credentials provider is writable.
 CachedCredentials[] getCredentials()
          Returns all the credentials that are currently configured for any server.
 CachedCredentials getCredentials(java.net.URI serverURI)
          Provides the credentials for the given URI.
 java.lang.String getUIMechanismName()
          Gets the localized name of the storage mechanism this provider uses.
 boolean isSecure()
          Queries whether the credentials are stored in a secure mechanism as determined by the operating system, for example, Apple Keychain, GNOME Keyring, Windows CredMan, Eclipse's credential store, or encrypted using a system mechanism such as Windows DPAPI.
 boolean removeCredentials(CachedCredentials cachedCredentials)
          Removes the credentials for the given URI.
 boolean removeCredentials(java.net.URI uri)
          Removes the credentials for the given URI.
 boolean setCredentials(CachedCredentials cachedCredentials)
          Sets the credentials for the given URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeychainCredentialsManager

public KeychainCredentialsManager()
Method Detail

getUIMechanismName

public java.lang.String getUIMechanismName()
Gets the localized name of the storage mechanism this provider uses. The string can be in any format but it should be unique among implementations and cannot be empty.

Specified by:
getUIMechanismName in interface CredentialsManager
Returns:
the human-readable name of the storage mechanism used (never null)

canWrite

public boolean canWrite()
Tests whether this credentials provider is writable. Some credentials providers provide read-only views of the credentials data.

Specified by:
canWrite in interface CredentialsManager
Returns:
true if the credentials provider is writable, false otherwise

isSecure

public boolean isSecure()
Queries whether the credentials are stored in a secure mechanism as determined by the operating system, for example, Apple Keychain, GNOME Keyring, Windows CredMan, Eclipse's credential store, or encrypted using a system mechanism such as Windows DPAPI.

Specified by:
isSecure in interface CredentialsManager
Returns:
true if these credentials are stored securely, false otherwise

getCredentials

public CachedCredentials[] getCredentials()
Returns all the credentials that are currently configured for any server.

Specified by:
getCredentials in interface CredentialsManager
Returns:
All credentials that are configured (may be null)

getCredentials

public CachedCredentials getCredentials(java.net.URI serverURI)
Provides the credentials for the given URI. The given URI may be a TFS server, an HTTP proxy or a TFS proxy.

This method may return CachedCredentials that match only some parts of the given URI (instead of all parts).

Specified by:
getCredentials in interface CredentialsManager
Parameters:
serverURI - The URI to connect to (never null)
Returns:
The credentials to connect with (never null)

setCredentials

public boolean setCredentials(CachedCredentials cachedCredentials)
Sets the credentials for the given URI. The given URI may be a TFS server, an HTTP proxy or a TFS proxy.

Users should ensure that this credentials provider is writable by calling the CredentialsManager.canWrite() method for calling this one.

See class documentation for CredentialsManager for information on how this URI may be altered before being saved.

Specified by:
setCredentials in interface CredentialsManager
Parameters:
cachedCredentials - The credentials to connect with (never null)
Returns:
true if the credentials were successfully saved, false otherwise

removeCredentials

public boolean removeCredentials(CachedCredentials cachedCredentials)
Removes the credentials for the given URI. Note that the given username and password need not match for a cached credentials object to be removed, only the server URI need match.

Users should ensure that this credentials provider is writable by calling the CredentialsManager.canWrite() method for calling this one.

Specified by:
removeCredentials in interface CredentialsManager
Parameters:
cachedCredentials - The credentials to remove (not null)
Returns:
true if the credentials were successfully removed, false otherwise

removeCredentials

public boolean removeCredentials(java.net.URI uri)
Removes the credentials for the given URI.

Users should ensure that this credentials provider is writable by calling the CredentialsManager.canWrite() method for calling this one.

Specified by:
removeCredentials in interface CredentialsManager
Returns:
true if the credentials were successfully removed, false otherwise


© 2015 Microsoft. All rights reserved.