org.teiid.connector.api
Class CredentialMap

java.lang.Object
  extended by org.teiid.connector.api.CredentialMap
All Implemented Interfaces:
java.io.Serializable

public class CredentialMap
extends java.lang.Object
implements java.io.Serializable

Allows credentials to be passed on a per user basis to a connector. A CredentialsMap object is produced based on information provided in the JDBC URL. The static method parseCredentials() is used for this purpose. This CredentialMap serves as the session "trusted payload". It is the responsibility of a Connector to call ExecutionContext.getTrustedPayload() to retrieve the CredentialMap. The system name should be the same as the Connector Binding Name retrieved from ConnectorEnvironment.getConnectorName(). To get the keyword/value pairs use getSystemCredentials(systemName), this will return a Map that contains the properties for the specified system. Specific user and password values can be retrieved with getUser(systemName) and getPassword(systemName)

See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_SYSTEM
           
static java.lang.String ESCAPE_CHAR
           
static short MODE_IGNORE_DEFAULTS
          In this mode, the CredentialMap will ignore the default credentials and only credentials set for a system will be exposed.
static short MODE_USE_DEFAULTS_GLOBALLY
          In this mode, the default credentials will be returned for any system, overlaid with any system-specific credentials.
static short MODE_USE_DEFAULTS_ON_EXISTING
          In this mode, the default credentials will be returned for any system, overlaid with any system-specific credentials.
static java.lang.String PASSWORD_KEYWORD
           
static java.lang.String SYSTEM_KEYWORD
           
static java.lang.String USER_KEYWORD
           
 
Constructor Summary
CredentialMap()
           
 
Method Summary
 void addSystemCredentials(java.lang.String system, java.util.Map credentials)
          Method to add a user name and credentials (e.g.
 java.lang.String getPassword(java.lang.String systemName)
          Get the password property for the specified system, if it exists.
 java.util.Map getSystemCredentials(java.lang.String systemName)
          Method to return the credentials map for a system
 java.lang.String[] getSystems()
          Method to return an array of systems that have been added to this CredentialMap.
 java.lang.String getUser(java.lang.String systemName)
          Get the user property for the specified system, if it exists.
static CredentialMap parseCredentials(java.lang.String inputStr)
          Method to parse a credentials substring extracted from a JDBC URL.
 void setDefaultCredentialMode(short mode)
          Set the default credential mode to determine when default credentials should be returned.
 void setDefaultCredentials(java.util.Map defaultCredentials)
          Set the default credentials to use with this credential map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SYSTEM_KEYWORD

public static final java.lang.String SYSTEM_KEYWORD
See Also:
Constant Field Values

USER_KEYWORD

public static final java.lang.String USER_KEYWORD
See Also:
Constant Field Values

PASSWORD_KEYWORD

public static final java.lang.String PASSWORD_KEYWORD
See Also:
Constant Field Values

ESCAPE_CHAR

public static final java.lang.String ESCAPE_CHAR
See Also:
Constant Field Values

DEFAULT_SYSTEM

public static final java.lang.String DEFAULT_SYSTEM
See Also:
Constant Field Values

MODE_IGNORE_DEFAULTS

public static final short MODE_IGNORE_DEFAULTS
In this mode, the CredentialMap will ignore the default credentials and only credentials set for a system will be exposed. This is the default setting for the CredentialMap.

See Also:
Constant Field Values

MODE_USE_DEFAULTS_GLOBALLY

public static final short MODE_USE_DEFAULTS_GLOBALLY
In this mode, the default credentials will be returned for any system, overlaid with any system-specific credentials. If a system is unknown, all default credentials are returned for that system.

See Also:
Constant Field Values

MODE_USE_DEFAULTS_ON_EXISTING

public static final short MODE_USE_DEFAULTS_ON_EXISTING
In this mode, the default credentials will be returned for any system, overlaid with any system-specific credentials. If a system is unknown, the default credentials are NOT used.

See Also:
Constant Field Values
Constructor Detail

CredentialMap

public CredentialMap()
Method Detail

parseCredentials

public static CredentialMap parseCredentials(java.lang.String inputStr)
                                      throws ConnectorException
Method to parse a credentials substring extracted from a JDBC URL. The presumed command line syntax is ...;credentials=(...);... Only the substring starting and ending with the parentheses is passed to this method. That is, the first non-blank character must be a '(' and the last non-blank character must be a ')', or an exception will be thrown. Syntax is: (credentialspec1/credentialspec2/.../credentialspecn) Any number one or greater of credential specifications may be included, separated by '/' characters. Each credentials spec will be specified in the following way: Keyword-specified, order-independent name-value pairs of the form keyword=value. The only required keyword is "system", which must be specified for each credentials spec, and must have a value corresponding to the name of an EIS already known to the system. Ex: system=sys1,user=sys1un,pass=sys1pw, whatever=somevalue. Each of the keywords must be unique. All blank space is ignored, except within a keyword or value. Any syntax error will cause an Exception to be thrown.

Parameters:
inputStr - the string to be parsed; first non-blank must be a '(', last non-blank must be a ')'
Returns:
a CredentialMap containing the input
Throws:
ConnectorException - upon any syntax error; descriptive text included

getSystems

public java.lang.String[] getSystems()
Method to return an array of systems that have been added to this CredentialMap.

Returns:
array of the systems that have been added using addSystemCredentials() - always uppercase

addSystemCredentials

public void addSystemCredentials(java.lang.String system,
                                 java.util.Map credentials)
Method to add a user name and credentials (e.g. password) for a system

Parameters:
system - system name corresponding to the user and credentials
credentials - Map containing name/val pairs

setDefaultCredentials

public void setDefaultCredentials(java.util.Map defaultCredentials)
Set the default credentials to use with this credential map. See the various default credential modes to understand when and how these will be returned.

Parameters:
defaultCredentials - Map of credentials
Since:
4.3

setDefaultCredentialMode

public void setDefaultCredentialMode(short mode)
Set the default credential mode to determine when default credentials should be returned.

Parameters:
mode - The mode
Since:
4.3
See Also:
MODE_IGNORE_DEFAULTS, MODE_USE_DEFAULTS_GLOBALLY, MODE_USE_DEFAULTS_ON_EXISTING

getSystemCredentials

public java.util.Map getSystemCredentials(java.lang.String systemName)
Method to return the credentials map for a system

Parameters:
systemName - system name
Returns:
Map

getUser

public java.lang.String getUser(java.lang.String systemName)
Get the user property for the specified system, if it exists. The user property is defined by the static constant USER_KEYWORD.

Parameters:
systemName - The system to look up (case insensitive)
Returns:
The user name for this system if the system was found and the system had a user property
Since:
4.3

getPassword

public java.lang.String getPassword(java.lang.String systemName)
Get the password property for the specified system, if it exists. The password property is defined by the static constant PASSWORD_KEYWORD.

Parameters:
systemName - The system to look up (case insensitive)
Returns:
The password for this system if the system was found and the system had a password property
Since:
4.3

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.