本文整理匯總了Java中javax.naming.directory.DirContext.removeFromEnvironment方法的典型用法代碼示例。如果您正苦於以下問題:Java DirContext.removeFromEnvironment方法的具體用法?Java DirContext.removeFromEnvironment怎麽用?Java DirContext.removeFromEnvironment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.directory.DirContext
的用法示例。
在下文中一共展示了DirContext.removeFromEnvironment方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: userCredentialsRemove
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
/**
* Configure the context to use {@link #connectionName} and
* {@link #connectionPassword} if specified or an anonymous connection if
* those attributes are not specified.
*
* @param context DirContext to configure
*/
private void userCredentialsRemove(DirContext context)
throws NamingException {
// Restore the original security environment
if (connectionName != null) {
context.addToEnvironment(Context.SECURITY_PRINCIPAL,
connectionName);
} else {
context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
}
if (connectionPassword != null) {
context.addToEnvironment(Context.SECURITY_CREDENTIALS,
connectionPassword);
}
else {
context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
}
}
示例2: restoreEnvironmentParameter
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
private void restoreEnvironmentParameter(DirContext context, String parameterName,
Hashtable<?, ?> preservedEnvironment) {
try {
context.removeFromEnvironment(parameterName);
if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
context.addToEnvironment(parameterName, preservedEnvironment.get(parameterName));
}
} catch (NamingException e) {
// Ignore
}
}
示例3: restoreEnvironmentParameter
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
private void restoreEnvironmentParameter(DirContext context,
String parameterName, Hashtable<?, ?> preservedEnvironment) {
try {
context.removeFromEnvironment(parameterName);
if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
context.addToEnvironment(parameterName,
preservedEnvironment.get(parameterName));
}
} catch (NamingException e) {
// Ignore
}
}
示例4: userCredentialsRemove
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
/**
* Configure the context to use {@link #connectionName} and
* {@link #connectionPassword} if specified or an anonymous connection if
* those attributes are not specified.
*
* @param context
* DirContext to configure
*/
private void userCredentialsRemove(DirContext context) throws NamingException {
// Restore the original security environment
if (connectionName != null) {
context.addToEnvironment(Context.SECURITY_PRINCIPAL, connectionName);
} else {
context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
}
if (connectionPassword != null) {
context.addToEnvironment(Context.SECURITY_CREDENTIALS, connectionPassword);
} else {
context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
}
}
示例5: bindAsUser
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
/**
* Check credentials by binding to the directory as the user
*
* @param context The directory context
* @param user The User to be authenticated
* @param credentials Authentication credentials
*
* @exception NamingException if a directory server error occurs
*/
protected boolean bindAsUser(DirContext context,
User user,
String credentials)
throws NamingException {
if (credentials == null || user == null)
return (false);
String dn = user.dn;
if (dn == null)
return (false);
// Validate the credentials specified by the user
if (containerLog.isTraceEnabled()) {
containerLog.trace(" validating credentials by binding as the user");
}
// Set up security environment to bind as the user
context.addToEnvironment(Context.SECURITY_PRINCIPAL, dn);
context.addToEnvironment(Context.SECURITY_CREDENTIALS, credentials);
// Elicit an LDAP bind operation
boolean validated = false;
try {
if (containerLog.isTraceEnabled()) {
containerLog.trace(" binding as " + dn);
}
context.getAttributes("", null);
validated = true;
}
catch (AuthenticationException e) {
if (containerLog.isTraceEnabled()) {
containerLog.trace(" bind attempt failed");
}
}
// Restore the original security environment
if (connectionName != null) {
context.addToEnvironment(Context.SECURITY_PRINCIPAL,
connectionName);
} else {
context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
}
if (connectionPassword != null) {
context.addToEnvironment(Context.SECURITY_CREDENTIALS,
connectionPassword);
}
else {
context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
}
return (validated);
}
示例6: bindAsUser
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
/**
* Check credentials by binding to the directory as the user
*
* @param context The directory context
* @param user The User to be authenticated
* @param credentials Authentication credentials
*
* @exception NamingException if a directory server error occurs
*/
protected boolean bindAsUser(DirContext context,
User user,
String credentials)
throws NamingException {
Attributes attr;
if (credentials == null || user == null)
return (false);
String dn = user.dn;
if (dn == null)
return (false);
// Validate the credentials specified by the user
if (debug >= 3) {
log(" validating credentials by binding as the user");
}
// Set up security environment to bind as the user
context.addToEnvironment(Context.SECURITY_PRINCIPAL, dn);
context.addToEnvironment(Context.SECURITY_CREDENTIALS, credentials);
// Elicit an LDAP bind operation
boolean validated = false;
try {
if (debug > 2) {
log(" binding as " + dn);
}
attr = context.getAttributes("", null);
validated = true;
}
catch (AuthenticationException e) {
if (debug > 2) {
log(" bind attempt failed");
}
}
// Restore the original security environment
if (connectionName != null) {
context.addToEnvironment(Context.SECURITY_PRINCIPAL, connectionName);
} else {
context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
}
if (connectionPassword != null) {
context.addToEnvironment(Context.SECURITY_CREDENTIALS,
connectionPassword);
}
else {
context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
}
return (validated);
}
示例7: bindAsUser
import javax.naming.directory.DirContext; //導入方法依賴的package包/類
/**
* Check credentials by binding to the directory as the user
*
* @param context The directory context
* @param user The User to be authenticated
* @param credentials Authentication credentials
* @throws NamingException if a directory server error occurs
*/
private boolean bindAsUser(final DirContext context, final JNDIUser user, final String credentials)
throws NamingException {
if (credentials == null || user == null) {
return false;
}
// Validate the credentials specified by the user
final String dn = user.getDn();
if (log.isDebugEnabled()) {
log.debug("validating credentials by binding as: " + dn);
}
if (dn == null) {
return false;
}
// Set up security environment to bind as the user
context.addToEnvironment(Context.SECURITY_PRINCIPAL, dn);
context.addToEnvironment(Context.SECURITY_CREDENTIALS, credentials);
// Elicit an LDAP bind operation
boolean validated = false;
try {
//noinspection UNUSED_SYMBOL,UnusedDeclaration
context.getAttributes("", null);
validated = true;
} catch (AuthenticationException e) {
if (log.isDebugEnabled()) {
log.debug("bind attempt failed: " + e, e);
}
}
// Restore the original security environment
if (connectionPrincipal != null) {
context.addToEnvironment(Context.SECURITY_PRINCIPAL, connectionPrincipal);
} else {
context.removeFromEnvironment(Context.SECURITY_PRINCIPAL);
}
if (connectionCredentials != null) {
context.addToEnvironment(Context.SECURITY_CREDENTIALS, connectionCredentials);
} else {
context.removeFromEnvironment(Context.SECURITY_CREDENTIALS);
}
return validated;
}