java.io.Externalizable, java.io.Serializable, ServerEnvironment, ClientEnvironment@Service @PerLookup public final class Environment extends java.lang.Object implements java.io.Externalizable, ServerEnvironment
Here's an example of how to create an initial context:
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL, "t3://weblogic:7001");
props.put(Context.SECURITY_PRINCIPAL, "fred");
props.put(Context.SECURITY_CREDENTIALS, "seafood");
Context ctx = new InitialContext(props);
This code can be rewritten using an Environment object
as illustrated here:
Environment env = new Environment();
env.setProviderUrl("t3://weblogicServer:7001");
env.setSecurityPrincipal("fred");
env.setSecurityCredentials("seafood");
Context ctx = env.getInitialContext();| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
DEFAULT_INITIAL_CONTEXT_FACTORY |
|
static java.lang.String |
LOCAL_URL_PROTOCOL |
| Constructor | Description |
|---|---|
Environment() |
Constructs an Environment with default properties, that is,
with a WebLogic initial context.
|
Environment(java.util.Hashtable properties) |
Constructs an Environment and initializes it with the properties
contained in the specified Hashtable.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
getBoolean(java.lang.String name,
boolean defaultValue) |
Gets the value of the specified property as a boolean.
|
java.lang.String |
getClusterProviderUrl() |
|
long |
getConnectionTimeout() |
Get the request timeout value.
|
javax.naming.Context |
getContext() |
Returns a context that can be used with this environment.
|
javax.naming.Context |
getContext(java.lang.String contextName) |
Returns a subcontext of the initial context with the
specified name.
|
boolean |
getCreateIntermediateContexts() |
Returns the value of the
WLContext.CREATE_INTERMEDIATE_CONTEXTS property.
|
java.util.Hashtable |
getDelegateEnvironment() |
Returns the value of the WLContext.DELEGATE_ENVIRONMENT
property.
|
boolean |
getEnableDefaultUser() |
|
boolean |
getEnableServerAffinity() |
Returns the value of the WLContext.ENABLE_SERVER_AFFINITY
property.
|
boolean |
getForceResolveDNSName() |
Returns the value of the Context.FORCE_RESOLVE_DNS_NAME
property.
|
javax.naming.Context |
getInitialContext() |
Returns an initial context based on the properties in an
Environment.
|
java.lang.String |
getInitialContextFactory() |
Returns the value of Context.INITIAL_CONTEXT_FACTORY.
|
boolean |
getPinToPrimaryServer() |
Returns the value of the WLContext.PIN_TO_PRIMARY_SERVER
property.
|
java.util.Hashtable |
getProperties() |
Returns the properties associated with an Environment as
a Hashtable.
|
java.lang.Object |
getProperty(java.lang.String name) |
Returns the value of the specified property.
|
java.lang.Object |
getPropertyFromEnv(java.lang.String name) |
|
java.lang.String |
getProviderUrl() |
Returns the Context.PROVIDER_URL property value.
|
boolean |
getReplicateBindings() |
Returns the value of the WLContext.REPLICATE_BINDINGS
property.
|
long |
getRequestTimeout() |
Deprecated.
- Use setConnectionTimeout() instead
|
long |
getResponseReadTimeout() |
Get the request timeout value.
|
long |
getRMIClientTimeout() |
Deprecated.
- Use getResponseReadTimeout instead.
|
java.lang.Object |
getSecurityCredentials() |
Returns the Context.SECURITY_CREDENTIAL property value.
|
java.lang.String |
getSecurityIdentityDomain() |
Returns the WLContext.IDENTITY_DOMAIN property value.
|
java.lang.String |
getSecurityPrincipal() |
Returns the value of the Context.SECURITY_PRINCIPAL
property.
|
java.lang.Object |
getSSLClientCertificate() |
Returns an RSA private key and chain of X.509 certificates set for SSL
client authentication on the current thread.
|
java.lang.Object |
getSSLClientKeyPassword() |
Deprecated.
This method will be removed in the next major
release.
|
TrustManager |
getSSLClientTrustManager() |
Returns the custom trust manager on the current thread used for
SSL certificate chain validation.
|
byte[][] |
getSSLRootCAFingerprints() |
Returns the fingerprints of the certificates of trusted
authorities associated with the current thread.
|
java.lang.String |
getSSLServerName() |
Gets the specified expected name from the current thread of the
SSL server.
|
java.lang.String |
getString(java.lang.String name) |
Gets the value of the specified property as a String.
|
void |
loadLocalIdentity(java.security.cert.Certificate[] certs,
java.security.PrivateKey privateKey) |
Loads the local identity onto the current thread given an array
of certs and the private key.
|
void |
readExternal(java.io.ObjectInput in) |
|
java.lang.Object |
removeProperty(java.lang.String name) |
Removes the specified property.
|
void |
setBoolean(java.lang.String name,
boolean value) |
Sets the value of the specified property as a boolean.
|
void |
setConnectionTimeout(long timeout) |
Set the request timeout value in milliseconds.
|
void |
setCreateIntermediateContexts(boolean flag) |
Set the WLContext.CREATE_INTERMEDIATE_CONTEXTS property to
the String equivalent of the boolean argument flag.
|
void |
setDelegateEnvironment(java.util.Hashtable delegateEnv) |
Sets the WLContext.DELEGATE_ENVIRONMENT property to
the value of the argument delegateEnv.
|
void |
setEnableDefaultUser(boolean defaultUser) |
|
void |
setEnableServerAffinity(boolean enable) |
Sets the WLContext.ENABLE_SERVER_AFFINITY property to the String
equivalent of the boolean argument enable.
|
void |
setInitialContextFactory(java.lang.String factoryName) |
Sets the Context.INITIAL_CONTEXT_FACTORY property value
to the value of factoryName.
|
void |
setPinToPrimaryServer(boolean enable) |
Sets the WLContext.PIN_TO_PRIMARY_SERVER property to the String
equivalent of the boolean argument enable.
|
java.lang.Object |
setProperty(java.lang.String name,
java.lang.Object value) |
Sets the specified property.
|
void |
setProviderUrl(java.lang.String url) |
Sets the Context.PROVIDER_URL property value to
the value of the argument url.
|
void |
setProviderURL(java.lang.String url) |
Sets the Context.PROVIDER_URL property
|
void |
setReplicateBindings(boolean enable) |
Sets the WLContext.REPLICATE_BINDINGS property to
the String equivalent of the boolean argument enable.
|
void |
setRequestTimeout(long timeout) |
Deprecated.
|
void |
setResponseReadTimeout(long timeout) |
Set the request timeout value.
|
void |
setRMIClientTimeout(long timeout) |
Deprecated.
- Use setResponseReadTimeout() instead
|
void |
setSecurityCredentials(java.lang.Object password) |
Sets the value of the Context.SECURITY_CREDENTIAL
property to the value of the argument password.
|
void |
setSecurityIdentityDomain(java.lang.String idd) |
Sets the value of the WLContext.IDENTITY_DOMAIN
property to the value of the argument idd.
|
void |
setSecurityPrincipal(java.lang.String principal) |
Sets the Context.SECURITY_PRINCIPAL property to
the value of the argument principal.
|
void |
setSSLClientCertificate(java.io.InputStream[] chain) |
Deprecated.
As of 12.2.1.1.0, use
loadLocalIdentity(Certificate[], PrivateKey) |
void |
setSSLClientKeyPassword(java.lang.String pass) |
Deprecated.
As of 12.2.1.1.0, see
loadLocalIdentity(Certificate[], PrivateKey) |
void |
setSSLClientTrustManager(TrustManager trustManager) |
Customizes the trust manager on the current thread used for SSL
certificate chain validation.
|
void |
setSSLContext(javax.net.ssl.SSLContext sslctx) |
Accept SSLContext from client
|
void |
setSSLRootCAFingerprints(byte[][] fps) |
Establishes a set of trusted certificate authorities on the
current thread.
|
void |
setSSLRootCAFingerprints(java.lang.String fps) |
Establishes a set of trusted certificate authorities on the
current thread.
|
void |
setSSLServerName(java.lang.String name) |
Sets an expected name on the current thread for the SSL
server.
|
void |
writeExternal(java.io.ObjectOutput out) |
public static final java.lang.String DEFAULT_INITIAL_CONTEXT_FACTORY
public static final java.lang.String LOCAL_URL_PROTOCOL
public Environment()
public Environment(java.util.Hashtable properties)
properties - Hashtable containing initial propertiespublic java.util.Hashtable getProperties()
getProperties in interface ClientEnvironmentpublic final javax.naming.Context getInitialContext()
throws javax.naming.NamingException
getInitialContext in interface ServerEnvironmentjavax.naming.NamingException - if the initial context cannot be obtainedpublic final javax.naming.Context getContext()
throws javax.naming.NamingException
ClientEnvironmentgetContext in interface ClientEnvironmentjavax.naming.NamingExceptionpublic final javax.naming.Context getContext(java.lang.String contextName)
throws javax.naming.NamingException
contextName - of the context to retrievejavax.naming.NamingException - if the initial context cannot be obtainedpublic final java.lang.String getClusterProviderUrl()
public java.lang.String getInitialContextFactory()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the context name is unavailable or invalid
at runtimeContext.INITIAL_CONTEXT_FACTORYpublic final void setInitialContextFactory(java.lang.String factoryName)
setInitialContextFactory in interface ServerEnvironmentfactoryName - Initial context factory nameContext.INITIAL_CONTEXT_FACTORYpublic final java.lang.String getProviderUrl()
getProviderUrl in interface ServerEnvironmentContext.PROVIDER_URLpublic final void setProviderUrl(java.lang.String url)
setProviderUrl in interface ServerEnvironmenturl - Provider urlContext.PROVIDER_URLpublic final void setProviderURL(java.lang.String url)
ClientEnvironmentsetProviderURL in interface ClientEnvironmenturl - The url to use with this environmentpublic final java.util.Hashtable getDelegateEnvironment()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.DELEGATE_ENVIRONMENTpublic final void setDelegateEnvironment(java.util.Hashtable delegateEnv)
delegateEnv - Hashtable of propertiesWLContext.DELEGATE_ENVIRONMENTpublic final boolean getForceResolveDNSName()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.FORCE_RESOLVE_DNS_NAMEpublic final java.lang.String getSecurityPrincipal()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeContext.SECURITY_PRINCIPALpublic final void setSecurityPrincipal(java.lang.String principal)
setSecurityPrincipal in interface ClientEnvironmentprincipal - UsernameContext.SECURITY_PRINCIPALpublic final java.lang.Object getSecurityCredentials()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeContext.SECURITY_PRINCIPALpublic final void setSecurityCredentials(java.lang.Object password)
setSecurityCredentials in interface ClientEnvironmentpassword - Password (String)Context.SECURITY_CREDENTIALSpublic final java.lang.String getSecurityIdentityDomain()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.IDENTITY_DOMAINpublic final void setSecurityIdentityDomain(java.lang.String idd)
idd - Identity Domain (String)WLContext.IDENTITY_DOMAINpublic final boolean getCreateIntermediateContexts()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.CREATE_INTERMEDIATE_CONTEXTSpublic final void setCreateIntermediateContexts(boolean flag)
throws java.lang.IllegalArgumentException
setCreateIntermediateContexts in interface ServerEnvironmentflag - to turn on use of intermediate contextsjava.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.CREATE_INTERMEDIATE_CONTEXTSpublic final boolean getReplicateBindings()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.REPLICATE_BINDINGSpublic final void setReplicateBindings(boolean enable)
setReplicateBindings in interface ServerEnvironmentenable - True to enable replicated bindingsWLContext.REPLICATE_BINDINGSpublic final boolean getPinToPrimaryServer()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.PIN_TO_PRIMARY_SERVERpublic final void setPinToPrimaryServer(boolean enable)
enable - True to force use of primary serverWLContext.PIN_TO_PRIMARY_SERVERpublic final void setEnableServerAffinity(boolean enable)
setEnableServerAffinity in interface ClientEnvironmentenable - True to force use of server affinityWLContext.ENABLE_SERVER_AFFINITYpublic final boolean getEnableServerAffinity()
java.lang.IllegalArgumentException - if the property is unavailable or invalid
at runtimeWLContext.ENABLE_SERVER_AFFINITY@Deprecated public final void setRequestTimeout(long timeout)
RequestTimeoutException. A value
of 0 implies that request will never timeout.timeout - value in milliseconds.@Deprecated public final long getRequestTimeout()
public final void setConnectionTimeout(long timeout)
RequestTimeoutException. A value
of 0 implies that request will never timeout.setConnectionTimeout in interface ClientEnvironmenttimeout - value in milliseconds.public final long getConnectionTimeout()
@Deprecated public final void setRMIClientTimeout(long timeout)
timeout - @Deprecated public final long getRMIClientTimeout()
public final void setResponseReadTimeout(long timeout)
ClientEnvironmentRequestTimeoutException.
A value of 0, default, implies the request will never timeout.setResponseReadTimeout in interface ClientEnvironmenttimeout - value in millisecondspublic final long getResponseReadTimeout()
public final java.lang.String getString(java.lang.String name)
throws java.lang.IllegalArgumentException
name - Name of property to retrievejava.lang.IllegalArgumentException - if the
property value is not a Stringpublic final boolean getBoolean(java.lang.String name,
boolean defaultValue)
throws java.lang.IllegalArgumentException
name - Name of property to retrievedefaultValue - Default value for the propertyjava.lang.IllegalArgumentException - if the context name is unavailable or invalid
at runtimejava.lang.IllegalArgumentException - if the
property value is not "true" or "false"public final void setSSLRootCAFingerprints(java.lang.String fps)
fps - MD5 fingerprints of certificate(s)public final void setSSLRootCAFingerprints(byte[][] fps)
fps - MD5 fingerprints of certificatespublic final byte[][] getSSLRootCAFingerprints()
public final void setSSLServerName(java.lang.String name)
name - Domain name of an SSL serverpublic final java.lang.String getSSLServerName()
public final java.lang.Object getSSLClientCertificate()
throws java.io.IOException
java.io.IOExceptionPEMInputStream,
BufferedInputStream@Deprecated public final void setSSLClientCertificate(java.io.InputStream[] chain)
loadLocalIdentity(Certificate[], PrivateKey)The InputStreams you use must support mark and reset. If you have PEM-encoded data, you can wrap your InputStreams in PEMInputStream classes before passing them in here.
chain - Array of InputStreams of DER encoded valuesPEMInputStream,
BufferedInputStream@Deprecated public final void setSSLClientKeyPassword(java.lang.String pass)
loadLocalIdentity(Certificate[], PrivateKey)pass - Password for private key@Deprecated public final java.lang.Object getSSLClientKeyPassword()
public final void setSSLClientTrustManager(TrustManager trustManager)
trustManager - Custom trust managerpublic final TrustManager getSSLClientTrustManager()
public final void setBoolean(java.lang.String name,
boolean value)
name - Name of property to setvalue - Value to be set as a booleanpublic final java.lang.Object getProperty(java.lang.String name)
name - Name of property to retrievepublic final java.lang.Object getPropertyFromEnv(java.lang.String name)
public final java.lang.Object setProperty(java.lang.String name,
java.lang.Object value)
setProperty in interface ServerEnvironmentname - Name of property to be setvalue - Value (as object) to be setpublic final java.lang.Object removeProperty(java.lang.String name)
name - Name of property to removepublic void setEnableDefaultUser(boolean defaultUser)
setEnableDefaultUser in interface ServerEnvironmentpublic boolean getEnableDefaultUser()
getEnableDefaultUser in interface ServerEnvironmentpublic final void loadLocalIdentity(java.security.cert.Certificate[] certs,
java.security.PrivateKey privateKey)
certs - An array of certificatesprivateKey - The private keypublic final void setSSLContext(javax.net.ssl.SSLContext sslctx)
sslctx - SSLContextpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundException