public class ShimConfig extends java.lang.Object implements ShimParams.ReferenceResolver, ShimHost.StateListener, ShimHost.DriverPasswordCheck, ConfigElement
init()
methods. However, it may also be useful as the back end
for a configuration editor.
The ShimConfig
class is designed to read and write all the configuration data from
a single XML document. However, ShimConfig
can also be used as an aggregator for configuration data
from multiple sources. In either case, a ShimConfig
instance can be used to
construct XML documents to be used as parameters to shim init()
methods.Modifier and Type | Class and Description |
---|---|
static class |
ShimConfig.BadPasswordException |
static class |
ShimConfig.RemoteLoaderConfig
Class encapsulating Remote Loader connection data.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTR_SECURE
Name for XML attribute 'secure'.
|
static java.lang.String |
ATTR_USE
Name for XML attribute 'use'.
|
static java.lang.String |
TAG_APP_PASSWORD
Tag name for XML element 'app-password'.
|
static java.lang.String |
TAG_APP_SCHEMA_DEF
Tag name for XML element 'app-schema-def'.
|
static java.lang.String |
TAG_AUTH_CONTEXT
Tag name for XML element 'auth-context'.
|
static java.lang.String |
TAG_AUTH_ID
Tag name for XML element 'auth-id'.
|
static java.lang.String |
TAG_CLASS_NAME
Tag name for XML element 'class-name'.
|
static java.lang.String |
TAG_CONNECTION_STRING
Tag name for XML element 'connection-string'.
|
static java.lang.String |
TAG_DESIGNER_APP_ID
Tag name for XML element 'designer-app-id'
|
static java.lang.String |
TAG_DIRXML_SCHEMA_DEF
Tag name for XML element 'dirxml-schema-def'.
|
static java.lang.String |
TAG_DRIVER_DN
Tag name for XML element 'driver-dn'.
|
static java.lang.String |
TAG_DRIVER_PASSWORD
Tag name for XML element 'driver-password'.
|
static java.lang.String |
TAG_LOADER_PASSWORD
Tag name for XML element 'loader-password'.
|
static java.lang.String |
TAG_PUBLISHER_DN
Tag name for XML element 'publisher-dn'.
|
static java.lang.String |
TAG_REMOTE_LOADER
Tag name for XML element 'remote-loader'.
|
static java.lang.String |
TAG_SECURE_HASH
Tag name for XML element 'secure-hash'.
|
static java.lang.String |
TAG_SHIM_CONFIG
Tag name for XML element 'shim-config'.
|
static java.lang.String |
TAG_SHIM_STATE
Tag name for XML element 'shim-state'.
|
static java.lang.String |
TAG_SUBSCRIBER_DN
Tag name for XML element 'subscriber-dn'.
|
static java.lang.String |
VAL_EMPTY_STRING
""
|
static java.lang.String |
VAL_FALSE
"false"
|
static java.lang.String |
VAL_TRUE
"true"
|
Constructor and Description |
---|
ShimConfig()
Construct a default, empty
ShimConfig object. |
ShimConfig(org.w3c.dom.Node configParent)
Construct a
ShimConfig object given parsed XML. |
ShimConfig(ShimConfig source)
Construct a copy of an existing
ShimConfig object. |
ShimConfig(java.lang.String configFilename)
Construct a
ShimConfig object given a file name. |
Modifier and Type | Method and Description |
---|---|
boolean |
checkDriverPassword(java.lang.String password)
Method that will be called to handle a <check-password> command received on
the Publisher channel.
|
org.w3c.dom.Document |
createGetSchemaInitDoc()
Create an XML
Document suitable for passing to DriverShim.getSchema() . |
org.w3c.dom.Document[] |
createInitDocs()
Create three XML
Document s suitable for passing to the DriverShim ,
SubscriptionShim , and PublicationShim init() methods. |
Password |
getAppPassword()
Get the Password instance encapsulating the application password for the shim.
|
SchemaDef |
getAppSchemaDef()
Get the application
SchemaDef instance associated with this instance. |
java.lang.String |
getAuthContext()
Return the "authorization context" from the configuration data.
|
java.lang.String |
getAuthID()
Return the "authorization ID" from the configuration data.
|
java.lang.String |
getClassName()
Return the class name from the configuration data.
|
char[] |
getConfigPassword()
Return the configuration password.
|
java.lang.String |
getDesignerAppID()
Return the "Designer application ID" from the configuration data.
|
SchemaDef |
getDirXMLSchemaDef()
Get the DirXML
SchemaDef instance associated with this instance. |
java.lang.String[] |
getFakeDNs()
Return an array of
String s containing the "fake" DN values
in this configuration instance. |
Filter |
getFilter()
Get the
Filter instance associated with this instance. |
GCDefinitions |
getGCVs()
Get the
GCDefinitions instance associated with this instance. |
NamedPasswords |
getNamedPasswords()
Get the
NamedPasswords instance associated with this instance. |
NameMap |
getNameMap()
Get the
NameMap instance associated with this instance. |
GCValue |
getReferencedValue(java.lang.String name)
Supply a value given the name of the referenced item.
|
ShimConfig.RemoteLoaderConfig |
getRemoteLoaderConfig()
Get the
RemoteLoaderConfig instance associated with this instance. |
java.lang.String |
getShimClassName()
Return the class name of the shim.
|
ShimConfigParams |
getShimConfigParams()
Get the
ShimConfigParams instance associated with this instance. |
ShimState |
getShimState()
Get the
ShimState instance associated with this instance. |
boolean |
hasBeenModified()
Return
true if this instance has been modified. |
boolean |
isSecure()
Return
true if the password data and any other sensitive data associated with this
instance is encrypted. |
void |
notifyShimState(org.w3c.dom.Element[] stateElements)
Method that will be notified when a <driver-state>, <subscriber-state>,
or a <publisher-state> element is found in a shim document.
|
void |
resetModified()
Reset the modified flag for this instance such that
hasBeenModified()
will return false . |
void |
resetSecure()
Set the sensitive data in this instance to be unencrypted.
|
void |
setAppPassword(char[] newAppPassword)
Set a new app password value for this instance.
|
void |
setAppSchemaDef(SchemaDef newSchemaDef)
Set a
SchemaDef instance as application schema definition. |
void |
setAuthContext(java.lang.String newAuthContext)
Set the "authorization context" for this instance.
|
void |
setAuthID(java.lang.String newAuthID)
Set the "authorization ID" for this instance.
|
void |
setClassName(java.lang.String newClassName)
Set the class name for this instance.
|
void |
setConfigPassword(char[] newConfigPassword)
Set the password used to decrypt sensitive data in this instance.
|
void |
setDesignerAppID(java.lang.String newAppID)
Set the "Designer application ID" for this instance.
|
void |
setDirXMLSchemaDef(SchemaDef newSchemaDef)
Set a
SchemaDef instance as the DirXML schema definition. |
void |
setFakeDNs(java.lang.String[] newFakeDNs)
Set the "fake" DNs to use in building init documents.
|
void |
setFilter(Filter newFilter)
Set a
Filter instance as the "live" data for this
instance. |
void |
setGCVs(GCDefinitions newGCVs)
Set a
GCDefinitions instance as the "live" data for this
instance. |
void |
setNamedPasswords(NamedPasswords newNamedPasswords)
Set a
NamedPasswords instance as the "live" data for this
instance. |
void |
setNameMap(NameMap newNameMap)
Set a
NameMap instance as the "live" data for this
instance. |
void |
setRemoteLoaderConfig(ShimConfig.RemoteLoaderConfig newConfig)
Set a
RemoteLoaderConfig instance as the "live" data for this
instance. |
void |
setSecure(char[] newConfigPassword)
Set the sensitive data in this instance to be encrypted.
|
void |
setShimConfigParams(ShimConfigParams newConfigParams)
Set a
ShimConfigParams instance as the "live" data for this
instance. |
void |
setShimState(ShimState newShimState)
Set a
ShimState instance as the "live" data for this
instance. |
org.w3c.dom.Element |
toXML(org.w3c.dom.Node parent)
Construct an XML representation of the configuration data
in this instance.
|
void |
write(java.io.File file)
Serialize the configuration data in this instance as XML and write the bytes to a new
file based on the passed
File . |
void |
write(java.io.OutputStream outputStream)
Serialize the configuration data in this instance as XML and write the bytes to an
OutputStream . |
void |
write(java.lang.String filename)
Serialize the configuration data in this instance as XML and write the bytes to a new
file with the passed file name.
|
public static final java.lang.String TAG_SHIM_CONFIG
public static final java.lang.String TAG_CLASS_NAME
public static final java.lang.String TAG_REMOTE_LOADER
public static final java.lang.String TAG_CONNECTION_STRING
public static final java.lang.String TAG_LOADER_PASSWORD
public static final java.lang.String TAG_DRIVER_PASSWORD
public static final java.lang.String TAG_AUTH_ID
public static final java.lang.String TAG_AUTH_CONTEXT
public static final java.lang.String TAG_APP_PASSWORD
public static final java.lang.String TAG_DRIVER_DN
public static final java.lang.String TAG_SUBSCRIBER_DN
public static final java.lang.String TAG_PUBLISHER_DN
public static final java.lang.String TAG_SHIM_STATE
public static final java.lang.String TAG_APP_SCHEMA_DEF
public static final java.lang.String TAG_DIRXML_SCHEMA_DEF
public static final java.lang.String TAG_SECURE_HASH
public static final java.lang.String TAG_DESIGNER_APP_ID
public static final java.lang.String ATTR_SECURE
public static final java.lang.String ATTR_USE
public static final java.lang.String VAL_TRUE
public static final java.lang.String VAL_FALSE
public static final java.lang.String VAL_EMPTY_STRING
public ShimConfig()
ShimConfig
object.public ShimConfig(ShimConfig source)
ShimConfig
object.source
- existing ShimConfig
instancepublic ShimConfig(java.lang.String configFilename) throws java.io.IOException, XMLException
ShimConfig
object given a file name.configFilename
- name of file containing configuration XML.java.io.IOException
- if an error occurs opening or reading the fileXMLException
- if an error occurs parsing the XMLpublic ShimConfig(org.w3c.dom.Node configParent) throws XMLException
ShimConfig
object given parsed XML.configParent
- DOM node that is the parent of the shim-config element.XMLException
- if an error occurs parsing the XMLpublic boolean hasBeenModified()
true
if this instance has been modified.
The instance is considered to have been modified if a change was made
that affects the persistent representation since:
resetModified()
was last calledhasBeenModified
in interface ConfigElement
true
or false
resetModified()
public void resetModified()
hasBeenModified()
will return false
.resetModified
in interface ConfigElement
hasBeenModified()
public java.lang.String getClassName()
getShimClassName()
.null
)getShimClassName()
public java.lang.String getShimClassName()
getClassName()
or ShimHost.REMOTE_SHIM_CLASS_NAME
if the Remote Loader is
being used.null
, or ShimHost.REMOTE_SHIM_CLASS_NAME
getClassName()
public void setClassName(java.lang.String newClassName)
newClassName
- class namepublic java.lang.String getAuthID()
null
)public void setAuthID(java.lang.String newAuthID)
newAuthID
- auth IDpublic java.lang.String getAuthContext()
null
)public void setAuthContext(java.lang.String newAuthContext)
newAuthContext
- auth contextpublic java.lang.String getDesignerAppID()
null
)public void setDesignerAppID(java.lang.String newAppID)
newAppID
- application ID Stringpublic Password getAppPassword()
null
)public void setAppPassword(char[] newAppPassword) throws java.lang.IllegalStateException, CipherException
isSecure()
returns true
, the configuration password must have been
set via setConfigPassword()
if the newAppPassword
parameter is non-null
.newAppPassword
- password characters (may be null)java.lang.IllegalStateException
- if isSecure()
returns true
and
no configuration password has been set.CipherException
- if an error occurs while encrypting the new password valueisSecure()
,
setConfigPassword(char[])
public java.lang.String[] getFakeDNs()
String
s containing the "fake" DN values
in this configuration instance. The fake DN values are
used for the "src-dn" attribute in configuration documents
for shim init()
methods.String
s: 0 is driver DN, 1 is subscriber DN, 2 is publisher DNpublic void setFakeDNs(java.lang.String[] newFakeDNs) throws java.lang.IllegalArgumentException
newFakeDNs
- array of three String
s: 0 is driver DN, 1 is subscriber DN, 2 is publisher DN
(any or all of which may be null
, or the array itself may be null
)java.lang.IllegalArgumentException
- if the array parameter is less than 3 elements in lengthpublic ShimConfig.RemoteLoaderConfig getRemoteLoaderConfig()
RemoteLoaderConfig
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.null
)public void setRemoteLoaderConfig(ShimConfig.RemoteLoaderConfig newConfig)
RemoteLoaderConfig
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newConfig
- config instance to use (may be null
)public Filter getFilter()
Filter
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.null
)public void setFilter(Filter newFilter)
Filter
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newFilter
- filter instance to use (may be null
)public NameMap getNameMap()
NameMap
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.
The NameMap
instance is used to map class and attribute names in the Filter
when constructing init documents.NameMap
instance (may be null
)public void setNameMap(NameMap newNameMap)
NameMap
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.
The NameMap
instance is used to map class and attribute names in the Filter
when constructing init documents.newNameMap
- NameMap
instance to use (may be null
)public ShimConfigParams getShimConfigParams()
ShimConfigParams
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.ShimConfigParams
instance (may be null
)public void setShimConfigParams(ShimConfigParams newConfigParams)
ShimConfigParams
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newConfigParams
- ShimConfigParams
instance to use (may be null
)public GCDefinitions getGCVs()
GCDefinitions
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.GCDefinitions
instance (may be null
)public void setGCVs(GCDefinitions newGCVs)
GCDefinitions
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newGCVs
- GCDefinitions
instance to use (may be null
)public NamedPasswords getNamedPasswords()
NamedPasswords
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.NamedPasswords
instance (may be null
)public void setNamedPasswords(NamedPasswords newNamedPasswords)
NamedPasswords
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newNamedPasswords
- NamedPasswords
instance to use (may be null
)public ShimState getShimState()
ShimState
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.ShimState
instance (may be null
)public void setShimState(ShimState newShimState)
ShimState
instance as the "live" data for this
instance. Any changes made to the passed object will be reflected
in this instance's configuration data.newShimState
- ShimState
instance to use (may be null
)public SchemaDef getAppSchemaDef()
SchemaDef
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.SchemaDef
instance (may be null
)public void setAppSchemaDef(SchemaDef newSchemaDef)
SchemaDef
instance as application schema definition.newSchemaDef
- SchemaDef
instance to use (may be null
)public SchemaDef getDirXMLSchemaDef()
SchemaDef
instance associated with this instance.
Note that if non-null
, the returned instance is "live" and changes
made to it will be reflected in this instance's configuration data.SchemaDef
instance (may be null
)public void setDirXMLSchemaDef(SchemaDef newSchemaDef)
SchemaDef
instance as the DirXML schema definition.newSchemaDef
- SchemaDef
instance to use (may be null
)public boolean isSecure()
true
if the password data and any other sensitive data associated with this
instance is encrypted.true
or false
public void setSecure(char[] newConfigPassword) throws java.lang.IllegalArgumentException, CipherException
setConfigPassword()
to supply the password for
already-encrypted data.newConfigPassword
- password to use in encrypting the sensitive datajava.lang.IllegalArgumentException
- if newConfigPassword
is nullCipherException
- if an error occurs during the encryption processsetConfigPassword(char[])
public void resetSecure() throws CipherException
CipherException
- if an error occurs during the decryption processpublic void setConfigPassword(char[] newConfigPassword) throws ShimConfig.BadPasswordException
setSecure()
to secure unencrypted
data.newConfigPassword
- passwordShimConfig.BadPasswordException
- if this ShimConfig instance is secure and the passed
password isn't correctsetSecure(char[])
public final char[] getConfigPassword()
null
or array containing configuration passwordpublic void write(java.lang.String filename) throws java.io.IOException
filename
- name of filejava.io.IOException
- if an error occurs while creating/opening or writing the filepublic void write(java.io.File file) throws java.io.IOException
File
. The XML is serialized with UTF-8 encoding.file
- File
object representing the file to usejava.io.IOException
- if an error occurs while creating/opening or writing the filepublic void write(java.io.OutputStream outputStream) throws java.io.IOException
OutputStream
. The XML is serialized with UTF-8 encoding.outputStream
- OutputStream
to which to writejava.io.IOException
- if an error occurs while writing to the OutputStream
public org.w3c.dom.Element toXML(org.w3c.dom.Node parent)
resetModified()
.toXML
in interface ConfigElement
parent
- Node
under which to construct the XML representationhasBeenModified()
,
resetModified()
public org.w3c.dom.Document[] createInitDocs() throws ConfigException
Document
s suitable for passing to the DriverShim
,
SubscriptionShim
, and PublicationShim
init()
methods.
The created documents are returned in an array suitable for use as the parameter to
ShimHost.start()
.DriverShim
, SubscriptionShim
, and PublicationShim
, respectively.ConfigException
- if an error occurs while constructing the documents (e.g., a password
decryption error occurs)ShimHost.start(org.w3c.dom.Document[])
public org.w3c.dom.Document createGetSchemaInitDoc() throws ConfigException
Document
suitable for passing to DriverShim.getSchema()
.
The created document is suitable for use as the parameter to ShimHost.getSchema()
.Document
for use with DriverShim.getSchema()
ConfigException
- if an error occurs while constructing the documents (e.g., a password
decryption error occurs)ShimHost.getSchema(org.w3c.dom.Document)
public GCValue getReferencedValue(java.lang.String name)
null
.
Implementation of ShimParams.ReferenceResolver
. This
will look for the named GCV in any GCV definition that exists as
part of this ShimConfig
instance.getReferencedValue
in interface ShimParams.ReferenceResolver
name
- name of referenced itemnull
or the referenced itemShimParams.ReferenceResolver
public void notifyShimState(org.w3c.dom.Element[] stateElements)
notifyShimState
in interface ShimHost.StateListener
stateElements
- 3-element array containing 1 or more shim state
elements.ShimHost.StateListener
public boolean checkDriverPassword(java.lang.String password)
checkDriverPassword
in interface ShimHost.DriverPasswordCheck
password
- value to checktrue
if password matches; false
otherwiseShimHost.DriverPasswordCheck