@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 and Description |
---|---|
private static boolean |
cantReadSystemProperties |
private boolean |
copyOnWrite |
static java.lang.String |
DEFAULT_INITIAL_CONTEXT_FACTORY |
private boolean |
enableDefaultUser |
private java.util.Hashtable |
env |
private static java.lang.Class |
factoryReference |
private static java.lang.String |
FALSE |
private javax.naming.Context |
initialContext |
static java.lang.String |
LOCAL_URL |
static java.lang.String |
LOCAL_URL_PROTOCOL |
private weblogic.security.acl.UserInfo |
securityUser |
private static long |
serialVersionUID |
private static weblogic.jndi.internal.SSL.SSLProxy |
sslProxy |
private weblogic.security.acl.internal.AuthenticatedSubject |
subject |
private static java.lang.String |
TRUE |
Constructor and 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 and Description |
---|---|
private javax.naming.Context |
createInitialContext() |
private weblogic.jndi.internal.SSL.SSLProxy |
findOrCreateSSLProxy() |
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.
|
javax.naming.Context |
getContext(java.lang.String contextName,
HostID hostIDToIgnore)
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 |
getDisableLoggingOfWarningMsg() |
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.
|
javax.naming.Context |
getInitialContext(boolean cached)
Returns an initial context based on the properties in an
Environment.
|
java.lang.String |
getInitialContextFactory()
Returns the value of Context.INITIAL_CONTEXT_FACTORY.
|
java.rmi.Remote |
getInitialReference(java.lang.Class<?> rirClass)
Returns an initial reference based on the properties in an
Environment.
|
private int |
getIntProperty(java.lang.String name,
int default_value) |
private long |
getLongProperty(java.lang.String name,
long default_value) |
private java.lang.Object |
getObsoleteProperty(java.lang.String oldProperty,
java.lang.String newConstant)
Gets the value of the specified property,
but prints a warning to the log if it's found and
gives the newer property name.
|
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 |
getProviderChannel()
Returns the WLContext.PROVIDER_CHANNEL property value.
|
ServerIdentity |
getProviderIdentity()
Deprecated.
|
java.lang.String |
getProviderUrl()
Returns the Context.PROVIDER_URL property value.
|
private java.lang.String |
getProviderURLInternal() |
(package private) java.util.Hashtable |
getRemoteProperties()
Returns a Hashtable containing properties to be sent
to remote provider.
|
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 |
getRetryInterval()
Get create InitialContext retry interval.
|
int |
getRetryTimes()
Get create InitialContext retry time.
|
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.
|
weblogic.security.acl.internal.AuthenticatedSubject |
getSecuritySubject() |
weblogic.security.acl.UserInfo |
getSecurityUser()
see bug 16397612
|
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.
|
weblogic.security.subject.AbstractSubject |
getSubject()
see bug 16397612
|
boolean |
isClientCertAvailable() |
boolean |
isLocalIdentitySet() |
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.
|
private void |
setClusterProviderUrl(java.lang.String url) |
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 |
setDisableLoggingOfWarningMsg(boolean enable)
Set the property to disable logging of warning msg that is printed
when context is created in one thread and closed on another thread.
|
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 |
setInitialProperties(java.util.Hashtable<java.lang.String,java.lang.Object> properties)
Sets the initial properties of the ServerEnvironment.
|
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 |
setProviderChannel(java.lang.String channel)
Sets the WLContext.PROVIDER_CHANNEL property value to
the value of the argument url.
|
void |
setProviderIdentity(ServerIdentity rjvm)
Deprecated.
|
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 |
setSecuritySubject(weblogic.security.acl.internal.AuthenticatedSubject s) |
void |
setSecurityUser(weblogic.security.acl.UserInfo user)
see bug 16397612
|
void |
setSSLClientCertificate(java.io.InputStream[] chain)
Deprecated.
As of 12.2.1.1.0, use
Environment.loadLocalIdentity(Certificate[], PrivateKey) |
void |
setSSLClientKeyPassword(java.lang.String pass)
Deprecated.
As of 12.2.1.1.0, see
Environment.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) |
private static final long serialVersionUID
public static final java.lang.String DEFAULT_INITIAL_CONTEXT_FACTORY
public static final java.lang.String LOCAL_URL
public static final java.lang.String LOCAL_URL_PROTOCOL
private static final boolean cantReadSystemProperties
private transient boolean copyOnWrite
private transient javax.naming.Context initialContext
private java.util.Hashtable env
private boolean enableDefaultUser
private static final weblogic.jndi.internal.SSL.SSLProxy sslProxy
private static java.lang.Class factoryReference
private weblogic.security.acl.UserInfo securityUser
private weblogic.security.acl.internal.AuthenticatedSubject subject
private static final java.lang.String TRUE
private static final java.lang.String FALSE
public Environment()
public Environment(java.util.Hashtable properties)
properties
- Hashtable containing initial propertiespublic void setInitialProperties(java.util.Hashtable<java.lang.String,java.lang.Object> properties)
ServerEnvironment
setInitialProperties
in interface ServerEnvironment
properties
- The possibly null set of propertiesprivate weblogic.jndi.internal.SSL.SSLProxy findOrCreateSSLProxy()
public java.util.Hashtable getProperties()
getProperties
in interface ClientEnvironment
public final javax.naming.Context getInitialContext() throws javax.naming.NamingException
getInitialContext
in interface ServerEnvironment
javax.naming.NamingException
- if the initial context cannot be obtainedpublic final javax.naming.Context getInitialContext(boolean cached) throws javax.naming.NamingException
cached
- true
if a previously cached context
can be returned. false
if a new
context instance needs to be returned using the
same environment propertiesjavax.naming.NamingException
- if the initial context cannot be obtainedprivate javax.naming.Context createInitialContext() throws javax.naming.NamingException
javax.naming.NamingException
public final javax.naming.Context getContext() throws javax.naming.NamingException
ClientEnvironment
getContext
in interface ClientEnvironment
javax.naming.NamingException
public final java.rmi.Remote getInitialReference(java.lang.Class<?> rirClass) throws javax.naming.NamingException
getInitialReference
in interface ServerEnvironment
rirClass
- class for initial referencejavax.naming.NamingException
- if the initial reference cannot be obtainedpublic final void setProviderChannel(java.lang.String channel)
channel
- Provider channelRmiContextConstants.PROVIDER_CHANNEL
public final java.lang.String getProviderChannel()
getProviderChannel
in interface ServerEnvironment
RmiContextConstants.PROVIDER_CHANNEL
public 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 javax.naming.Context getContext(java.lang.String contextName, HostID hostIDToIgnore) throws javax.naming.NamingException
contextName
- of the context to retrievehostIDToIgnore
- hostID to ignore if trying to get context from a clusterjavax.naming.NamingException
- if the initial context cannot be obtainedprivate java.lang.String getProviderURLInternal() throws javax.naming.NamingException
javax.naming.NamingException
private void setClusterProviderUrl(java.lang.String url)
public 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_FACTORY
public final void setInitialContextFactory(java.lang.String factoryName)
setInitialContextFactory
in interface ServerEnvironment
factoryName
- Initial context factory nameContext.INITIAL_CONTEXT_FACTORY
public final java.lang.String getProviderUrl()
getProviderUrl
in interface ServerEnvironment
Context.PROVIDER_URL
public final void setProviderUrl(java.lang.String url)
setProviderUrl
in interface ServerEnvironment
url
- Provider urlContext.PROVIDER_URL
public final void setProviderURL(java.lang.String url)
ClientEnvironment
setProviderURL
in interface ClientEnvironment
url
- 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_ENVIRONMENT
public final void setDelegateEnvironment(java.util.Hashtable delegateEnv)
delegateEnv
- Hashtable of propertiesWLContext.DELEGATE_ENVIRONMENT
public final boolean getForceResolveDNSName() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.FORCE_RESOLVE_DNS_NAME
public final java.lang.String getSecurityPrincipal() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeContext.SECURITY_PRINCIPAL
public final void setSecurityPrincipal(java.lang.String principal)
setSecurityPrincipal
in interface ClientEnvironment
principal
- UsernameContext.SECURITY_PRINCIPAL
public final java.lang.Object getSecurityCredentials() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeContext.SECURITY_PRINCIPAL
public final void setSecurityCredentials(java.lang.Object password)
setSecurityCredentials
in interface ClientEnvironment
password
- Password (String)Context.SECURITY_CREDENTIALS
public final java.lang.String getSecurityIdentityDomain() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.IDENTITY_DOMAIN
public final void setSecurityIdentityDomain(java.lang.String idd)
idd
- Identity Domain (String)WLContext.IDENTITY_DOMAIN
public final weblogic.security.acl.UserInfo getSecurityUser() throws java.lang.IllegalArgumentException
getSecurityUser
in interface ServerEnvironment
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimepublic final void setSecurityUser(weblogic.security.acl.UserInfo user)
setSecurityUser
in interface ServerEnvironment
public void setSecuritySubject(weblogic.security.acl.internal.AuthenticatedSubject s)
setSecuritySubject
in interface ServerEnvironment
public weblogic.security.acl.internal.AuthenticatedSubject getSecuritySubject()
public weblogic.security.subject.AbstractSubject getSubject()
getSubject
in interface ClientEnvironment
public final boolean getCreateIntermediateContexts() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.CREATE_INTERMEDIATE_CONTEXTS
public final void setCreateIntermediateContexts(boolean flag) throws java.lang.IllegalArgumentException
setCreateIntermediateContexts
in interface ServerEnvironment
flag
- to turn on use of intermediate contextsjava.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.CREATE_INTERMEDIATE_CONTEXTS
public final boolean getReplicateBindings() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.REPLICATE_BINDINGS
public final void setReplicateBindings(boolean enable)
setReplicateBindings
in interface ServerEnvironment
enable
- True to enable replicated bindingsWLContext.REPLICATE_BINDINGS
public final boolean getPinToPrimaryServer() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the property is unavailable or invalid
at runtimeWLContext.PIN_TO_PRIMARY_SERVER
public final void setPinToPrimaryServer(boolean enable)
enable
- True to force use of primary serverWLContext.PIN_TO_PRIMARY_SERVER
public final void setEnableServerAffinity(boolean enable)
setEnableServerAffinity
in interface ClientEnvironment
enable
- True to force use of server affinityWLContext.ENABLE_SERVER_AFFINITY
public 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 ClientEnvironment
timeout
- 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)
ClientEnvironment
RequestTimeoutException
.
A value of 0, default, implies the request will never timeout.setResponseReadTimeout
in interface ClientEnvironment
timeout
- 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.IOException
PEMInputStream
,
BufferedInputStream
@Deprecated public final void setSSLClientCertificate(java.io.InputStream[] chain)
Environment.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)
Environment.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)
private final java.lang.Object getObsoleteProperty(java.lang.String oldProperty, java.lang.String newConstant)
oldProperty
- Property name to look upnewConstant
- Property name that should have been usedpublic final java.lang.Object setProperty(java.lang.String name, java.lang.Object value)
setProperty
in interface ServerEnvironment
name
- 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 remove@Deprecated public final ServerIdentity getProviderIdentity() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
@Deprecated public final void setProviderIdentity(ServerIdentity rjvm)
java.util.Hashtable getRemoteProperties()
public void setEnableDefaultUser(boolean defaultUser)
setEnableDefaultUser
in interface ServerEnvironment
public boolean getEnableDefaultUser()
getEnableDefaultUser
in interface ServerEnvironment
public 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 final boolean isClientCertAvailable()
isClientCertAvailable
in interface ServerEnvironment
public final boolean isLocalIdentitySet()
public final void setDisableLoggingOfWarningMsg(boolean enable)
setDisableLoggingOfWarningMsg
in interface ClientEnvironment
enable
- - boolean to disable the warningpublic final boolean getDisableLoggingOfWarningMsg()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public int getRetryTimes()
public long getRetryInterval()
private long getLongProperty(java.lang.String name, long default_value)
private int getIntProperty(java.lang.String name, int default_value)