本文整理汇总了Java中org.springframework.ldap.support.LdapUtils.convertLdapException方法的典型用法代码示例。如果您正苦于以下问题:Java LdapUtils.convertLdapException方法的具体用法?Java LdapUtils.convertLdapException怎么用?Java LdapUtils.convertLdapException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.support.LdapUtils
的用法示例。
在下文中一共展示了LdapUtils.convertLdapException方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleResponse
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
protected void handleResponse(Object control)
{
byte[] result = (byte[]) invokeMethod("getContextID",
responseControlClass, control);
Integer listSize = (Integer) invokeMethod("getListSize",
responseControlClass, control);
Integer targetOffset = (Integer) invokeMethod(
"getTargetOffset", responseControlClass, control);
this.exception = (NamingException) invokeMethod("getException",
responseControlClass, control);
this.cookie = new VirtualListViewResultsCookie(result,
targetOffset.intValue(), listSize.intValue());
if (exception != null) {
throw LdapUtils.convertLdapException(exception);
}
}
示例2: NameAwareAttribute
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* Construct a new instance from the supplied Attribute.
*
* @param attribute the Attribute to copy.
*/
public NameAwareAttribute(Attribute attribute) {
this(attribute.getID(), attribute.isOrdered());
try {
NamingEnumeration<?> incomingValues = attribute.getAll();
while(incomingValues.hasMore()) {
this.add(incomingValues.next());
}
} catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
if (attribute instanceof NameAwareAttribute) {
NameAwareAttribute nameAwareAttribute = (NameAwareAttribute) attribute;
populateValuesAsNames(nameAwareAttribute, this);
}
}
示例3: doGetContext
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
private DirContext doGetContext(String principal, String credentials, boolean explicitlyDisablePooling) {
Hashtable<String, Object> env = getAuthenticatedEnv(principal, credentials);
if(explicitlyDisablePooling) {
env.remove(SUN_LDAP_POOLING_FLAG);
}
DirContext ctx = createContext(env);
try {
DirContext processedDirContext = authenticationStrategy.processContextAfterCreation(ctx, principal, credentials);
return processedDirContext;
}
catch (NamingException e) {
closeContext(ctx);
throw LdapUtils.convertLdapException(e);
}
}
示例4: createContext
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* Create a DirContext using the supplied environment.
*
* @param environment the LDAP environment to use when creating the
* <code>DirContext</code>.
* @return a new DirContext implementation initialized with the supplied
* environment.
*/
protected DirContext createContext(Hashtable<String, Object> environment) {
DirContext ctx = null;
try {
ctx = getDirContextInstance(environment);
if (LOG.isInfoEnabled()) {
Hashtable<?, ?> ctxEnv = ctx.getEnvironment();
String ldapUrl = (String) ctxEnv.get(Context.PROVIDER_URL);
LOG.debug("Got Ldap context on server '" + ldapUrl + "'");
}
return ctx;
}
catch (NamingException e) {
closeContext(ctx);
throw LdapUtils.convertLdapException(e);
}
}
示例5: bindAsUser
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
private DirContext bindAsUser(String username, String password) {
// TODO. add DNS lookup based on domain
final String bindUrl = url;
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");
String bindPrincipal = createBindPrincipal(username);
env.put(Context.SECURITY_PRINCIPAL, bindPrincipal);
env.put(Context.PROVIDER_URL, bindUrl);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.OBJECT_FACTORIES, DefaultDirObjectFactory.class.getName());
try {
return contextFactory.createContext(env);
}
catch (NamingException e) {
if ((e instanceof AuthenticationException) || (e instanceof OperationNotSupportedException)) {
handleBindException(bindPrincipal, e);
throw badCredentials(e);
}
else {
throw LdapUtils.convertLdapException(e);
}
}
}
示例6: getObjectFromNameClassPair
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* Cast the NameClassPair to a SearchResult and pass its attributes to the
* {@link AttributesMapper}.
*
* @param nameClassPair a <code> SearchResult</code> instance.
* @return the Object returned from the mapper.
*/
public T getObjectFromNameClassPair(NameClassPair nameClassPair) {
if (!(nameClassPair instanceof SearchResult)) {
throw new IllegalArgumentException("Parameter must be an instance of SearchResult");
}
SearchResult searchResult = (SearchResult) nameClassPair;
Attributes attributes = searchResult.getAttributes();
try {
return mapper.mapFromAttributes(attributes);
}
catch (javax.naming.NamingException e) {
throw LdapUtils.convertLdapException(e);
}
}
示例7: mapWithContext
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Override
public DirContextOperations mapWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) {
try {
return (DirContextOperations) ctx.lookup(ldapEntryIdentification.getRelativeName());
}
catch (NamingException e) {
// rethrow, because we aren't allowed to throw checked exceptions.
throw LdapUtils.convertLdapException(e);
}
}
示例8: executeWithContext
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
private <T> T executeWithContext(ContextExecutor<T> ce, DirContext ctx) {
try {
return ce.executeWithContext(ctx);
}
catch (javax.naming.NamingException e) {
throw LdapUtils.convertLdapException(e);
}
finally {
closeContext(ctx);
}
}
示例9: getObjectFromNameClassPair
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public T getObjectFromNameClassPair(NameClassPair nameClassPair) {
try {
return mapper.mapFromNameClassPair(nameClassPair);
}
catch (javax.naming.NamingException e) {
throw LdapUtils.convertLdapException(e);
}
}
示例10: getNamesOfModifiedAttributes
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String[] getNamesOfModifiedAttributes() {
List<String> tmpList = new ArrayList<String>();
NamingEnumeration<? extends Attribute> attributesEnumeration;
if (isUpdateMode()) {
attributesEnumeration = updatedAttrs.getAll();
}
else {
attributesEnumeration = originalAttrs.getAll();
}
try {
while (attributesEnumeration.hasMore()) {
Attribute oneAttribute = attributesEnumeration
.next();
tmpList.add(oneAttribute.getID());
}
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
finally {
closeNamingEnumeration(attributesEnumeration);
}
return tmpList.toArray(new String[tmpList.size()]);
}
示例11: getModificationItems
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ModificationItem[] getModificationItems() {
if (!updateMode) {
return new ModificationItem[0];
}
List<ModificationItem> tmpList = new LinkedList<ModificationItem>();
NamingEnumeration<? extends Attribute> attributesEnumeration = null;
try {
attributesEnumeration = updatedAttrs.getAll();
// find attributes that have been changed, removed or added
while (attributesEnumeration.hasMore()) {
NameAwareAttribute oneAttr = (NameAwareAttribute) attributesEnumeration.next();
collectModifications(oneAttr, tmpList);
}
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
finally {
closeNamingEnumeration(attributesEnumeration);
}
if (log.isDebugEnabled()) {
log.debug("Number of modifications:" + tmpList.size());
}
return tmpList.toArray(new ModificationItem[tmpList.size()]);
}
示例12: getObjectAttribute
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object getObjectAttribute(String name) {
Attribute oneAttr = originalAttrs.get(name);
if (oneAttr == null || oneAttr.size() == 0) { // LDAP-215
return null;
}
try {
return oneAttr.get();
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
}
示例13: update
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void update() {
NamingEnumeration<? extends Attribute> attributesEnumeration = null;
try {
attributesEnumeration = updatedAttrs.getAll();
// find what to update
while (attributesEnumeration.hasMore()) {
Attribute a = attributesEnumeration.next();
// if it does not exist it should be added
if (isEmptyAttribute(a)) {
originalAttrs.remove(a.getID());
}
else {
// Otherwise it should be set.
originalAttrs.put(a);
}
}
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
finally {
closeNamingEnumeration(attributesEnumeration);
}
// Reset the attributes to be updated
updatedAttrs = new NameAwareAttributes();
}
示例14: setupAuthenticatedEnvironment
import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
* Default implementation of setting the environment up to be authenticated.
* This method should typically NOT be overridden; any customization to the
* authentication mechanism should be managed by setting a different
* {@link DirContextAuthenticationStrategy} on this instance.
*
* @param env the environment to modify.
* @param principal the principal to authenticate with.
* @param credentials the credentials to authenticate with.
* @see DirContextAuthenticationStrategy
* @see #setAuthenticationStrategy(DirContextAuthenticationStrategy)
*/
protected void setupAuthenticatedEnvironment(Hashtable<String, Object> env, String principal, String credentials) {
try {
authenticationStrategy.setupEnvironment(env, principal, credentials);
}
catch (NamingException e) {
throw LdapUtils.convertLdapException(e);
}
}