當前位置: 首頁>>代碼示例>>Java>>正文


Java DirContext.removeFromEnvironment方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:26,代碼來源:JNDIRealm.java

示例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
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:12,代碼來源:JNDIRealm.java

示例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
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:13,代碼來源:JNDIRealm.java

示例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);
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:23,代碼來源:JNDIRealm.java

示例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);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:64,代碼來源:JNDIRealm.java

示例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);
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:64,代碼來源:JNDIRealm.java

示例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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:56,代碼來源:JNDIAuthenticator.java


注:本文中的javax.naming.directory.DirContext.removeFromEnvironment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。