当前位置: 首页>>代码示例>>Java>>正文


Java UncategorizedLdapException类代码示例

本文整理汇总了Java中org.springframework.ldap.UncategorizedLdapException的典型用法代码示例。如果您正苦于以下问题:Java UncategorizedLdapException类的具体用法?Java UncategorizedLdapException怎么用?Java UncategorizedLdapException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UncategorizedLdapException类属于org.springframework.ldap包,在下文中一共展示了UncategorizedLdapException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newApplicationUserSaveFail

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
@Test(expected = UncategorizedLdapException.class)
public void newApplicationUserSaveFail() {
	final LdapPluginResource resource = new LdapPluginResource();
	resource.userResource = Mockito.mock(UserOrgResource.class);
	Mockito.when(resource.userResource.findByIdNoCache("flast123")).thenReturn(null);
	Mockito.doThrow(new UncategorizedLdapException("")).when(resource.userResource).saveOrUpdate(ArgumentMatchers.any(UserOrgEditionVo.class));

	final UserOrg user = new UserOrg();
	user.setMails(Collections.singletonList("[email protected]"));
	user.setFirstName("First");
	user.setLastName("Last123");
	user.setName("secondarylogin");
	user.setCompany("gfi");
	resource.newApplicationUser(user);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:16,代码来源:LdapPluginResourceTest.java

示例2: loadLdif

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) {
       try {
           LdapName baseDn = (LdapName)
                   context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY);

           LdifParser parser = new LdifParser(ldifFile);
           parser.open();
           while (parser.hasMoreRecords()) {
               LdapAttributes record = parser.getRecord();

               LdapName dn = record.getName();

               if(baseDn != null) {
                   dn = LdapUtils.removeFirst(dn, baseDn);
               }

               if(!rootNode.isEmpty()) {
                   dn = LdapUtils.prepend(dn, rootNode);
               }
               context.bind(dn, null, record);
           }
       } catch (Exception e) {
           throw new UncategorizedLdapException("Failed to populate LDIF", e);
       }
   }
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:27,代码来源:LdapTestUtils.java

示例3: loadControlClasses

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
protected void loadControlClasses() {
	Assert.notNull(defaultRequestControl, "defaultRequestControl must not be null");
	Assert.notNull(defaultResponseControl, "defaultResponseControl must not be null");
	Assert.notNull(fallbackRequestControl, "fallbackRequestControl must not be null");
	Assert.notNull(fallbackResponseControl, "fallbackReponseControl must not be null");
	try {
		requestControlClass = Class.forName(defaultRequestControl);
		responseControlClass = Class.forName(defaultResponseControl);
	}
	catch (ClassNotFoundException e) {
		log.debug("Default control classes not found - falling back to LdapBP classes", e);

		try {
			requestControlClass = Class.forName(fallbackRequestControl);
			responseControlClass = Class.forName(fallbackResponseControl);
		}
		catch (ClassNotFoundException e1) {
			throw new UncategorizedLdapException(
					"Neither default nor fallback classes are available - unable to proceed", e);
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:23,代码来源:AbstractFallbackRequestAndResponseControlDirContextProcessor.java

示例4: loadControlClasses

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
private void loadControlClasses() {
	try {
		requestControlClass = Class.forName(DEFAULT_REQUEST_CONTROL);
		responseControlClass = Class.forName(DEFAULT_RESPONSE_CONTROL);
	}
	catch (ClassNotFoundException e) {
		log.debug("Default control classes not found - falling back to LdapBP classes", e);

		try {
			requestControlClass = Class.forName(LDAPBP_REQUEST_CONTROL);
			responseControlClass = Class.forName(LDAPBP_RESPONSE_CONTROL);
		}
		catch (ClassNotFoundException e1) {
			throw new UncategorizedLdapException(
					"Neither default nor fallback classes are available - unable to proceed", e);
		}

	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:20,代码来源:PagedResultsRequestControl.java

示例5: testRename_NamingException

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
@Test
public void testRename_NamingException() throws Exception {
    expectGetReadWriteContext();

    javax.naming.NamingException ne = new javax.naming.NamingException();

    doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock);

    try {
        tested.rename(oldNameMock, newNameMock);
        fail("UncategorizedLdapException expected");
    } catch (UncategorizedLdapException expected) {
        assertThat(true).isTrue();
    }

    verify(dirContextMock).close();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:18,代码来源:LdapTemplateRenameTest.java

示例6: testAuthenticateWithErrorInCallbackShouldFail

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
@Test
public void testAuthenticateWithErrorInCallbackShouldFail() throws Exception {
	when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);

	Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
			LdapUtils.newLdapName("dc=jayway, dc=se"));
	SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());

	singleSearchResult(searchControlsRecursive(), searchResult);

	when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
               .thenReturn(authenticatedContextMock);
       doThrow(new UncategorizedLdapException("Authentication failed")).when(entryContextCallbackMock)
               .executeWithContext(authenticatedContextMock,
                       new LdapEntryIdentification(
                               LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe")));

	boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock);

       verify(authenticatedContextMock).close();
       verify(dirContextMock).close();

       assertThat(result).isFalse();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:25,代码来源:LdapTemplateTest.java

示例7: loadLdif

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) {
    try {
        LdapName baseDn = (LdapName)
                context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY);

        LdifParser parser = new LdifParser(ldifFile);
        parser.open();
        while (parser.hasMoreRecords()) {
            LdapAttributes record = parser.getRecord();

            LdapName dn = record.getName();

            if(baseDn != null) {
                dn = LdapUtils.removeFirst(dn, baseDn);
            }

            if(!rootNode.isEmpty()) {
                dn = LdapUtils.prepend(dn, rootNode);
            }
            context.bind(dn, null, record);
        }
    } catch (Exception e) {
        throw new UncategorizedLdapException("Failed to populate LDIF", e);
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:26,代码来源:LdapTestUtils.java

示例8: mapFromAttributes

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @throws UncategorizedLdapException
 *             in case the wrapped mapper could not map the attributes. The actual exception
 *             will be contained in the cause.
 */
@Override
public Object mapFromAttributes(Attributes attributes) throws NamingException,
UncategorizedLdapException {
    try {
        return mapper.mapAttributes(dn, attributes);
    } catch (LdapAttributeMappingException e) {
        throw new UncategorizedLdapException("Mapping LDAP attributes failed", e);
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:17,代码来源:SpringAttributesMapperAdapter.java

示例9: startEmbeddedServer

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
/**
 * Start an embedded Apache Directory Server. Only one embedded server will be permitted in the same JVM.
 *
 * @param port                   the port on which the server will be listening.
 * @param defaultPartitionSuffix The default base suffix that will be used
 *                               for the LDAP server.
 * @param defaultPartitionName   The name to use in the directory server
 *                               configuration for the default base suffix.
 *
 * @throws IllegalStateException if an embedded server is already started.
 */
public static void startEmbeddedServer(int port, String defaultPartitionSuffix, String defaultPartitionName) {
    if(embeddedServer != null) {
        throw new IllegalStateException("An embedded server is already started");
    }

    try {
        embeddedServer = EmbeddedLdapServer.newEmbeddedServer(defaultPartitionName, defaultPartitionSuffix, port);
    } catch (Exception e) {
        throw new UncategorizedLdapException("Failed to start embedded server", e);
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:23,代码来源:LdapTestUtils.java

示例10: newCollectionInstance

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<Object> newCollectionInstance() {
    try {
        return (Collection<Object>) collectionClass.newInstance();
    } catch (Exception e) {
        throw new UncategorizedLdapException("Failed to instantiate collection class", e);
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:9,代码来源:AttributeMetaData.java

示例11: clone

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
/**
 * @see java.lang.Object#clone()
 */
public Object clone() {
	try {
		DistinguishedName result = (DistinguishedName) super.clone();
		result.names = new LinkedList(names);
		return result;
	}
	catch (CloneNotSupportedException e) {
		LOG.error("CloneNotSupported thrown from superclass - this should not happen");
		throw new UncategorizedLdapException("Fatal error in clone", e);
	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:DistinguishedName.java

示例12: nameEncodeForUrl

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
static String nameEncodeForUrl(String value) {
    try {
        String ldapEncoded = LdapEncoder.nameEncode(value);
        URI valueUri = new URI(null, null, ldapEncoded, null);
        return valueUri.toString();
    } catch (URISyntaxException e) {
        throw new UncategorizedLdapException("This really shouldn't happen - report this", e);
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:AbstractContextSource.java

示例13: processContextAfterCreation

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
public final DirContext processContextAfterCreation(DirContext ctx, String userDn, String password)
		throws NamingException {

	if (ctx instanceof LdapContext) {
		final LdapContext ldapCtx = (LdapContext) ctx;
		final StartTlsResponse tlsResponse = (StartTlsResponse) ldapCtx.extendedOperation(new StartTlsRequest());
		try {
			if (hostnameVerifier != null) {
				tlsResponse.setHostnameVerifier(hostnameVerifier);
			}
			tlsResponse.negotiate(sslSocketFactory); // If null, the default SSL socket factory is used
			applyAuthentication(ldapCtx, userDn, password);

			if (shutdownTlsGracefully) {
				// Wrap the target context in a proxy to intercept any calls
				// to 'close', so that we can shut down the TLS connection
				// gracefully first.
				return (DirContext) Proxy.newProxyInstance(DirContextProxy.class.getClassLoader(), new Class<?>[] {
						LdapContext.class, DirContextProxy.class }, new TlsAwareDirContextProxy(ldapCtx,
						tlsResponse));
			}
			else {
				return ctx;
			}
		}
		catch (IOException e) {
			LdapUtils.closeContext(ctx);
			throw new UncategorizedLdapException("Failed to negotiate TLS session", e);
		}
	}
	else {
		throw new IllegalArgumentException(
				"Processed Context must be an LDAPv3 context, i.e. an LdapContext implementation");
	}

}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:37,代码来源:AbstractTlsDirContextAuthenticationStrategy.java

示例14: authenticate

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T> T authenticate(LdapQuery query, String password, AuthenticatedLdapEntryContextMapper<T> mapper) {
    SearchControls searchControls = searchControlsForQuery(query, RETURN_OBJ_FLAG);
    ReturningAuthenticatedLdapEntryContext<T> mapperCallback =
            new ReturningAuthenticatedLdapEntryContext<T>(mapper);
    CollectingAuthenticationErrorCallback errorCallback =
            new CollectingAuthenticationErrorCallback();

    AuthenticationStatus authenticationStatus = authenticate(query.base(),
            query.filter().encode(),
            password,
            searchControls,
            mapperCallback,
            errorCallback);

    if(errorCallback.hasError()) {
        Exception error = errorCallback.getError();

        if (error instanceof NamingException) {
            throw (NamingException) error;
        } else {
            throw new UncategorizedLdapException(error);
        }
    } else if(AuthenticationStatus.EMPTYRESULT == authenticationStatus) {
    	throw new EmptyResultDataAccessException(1);
    } else if(!authenticationStatus.isSuccess()) {
        throw new AuthenticationException();
    }

    return mapperCallback.collectedObject;
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:35,代码来源:LdapTemplate.java

示例15: formatForUrl

import org.springframework.ldap.UncategorizedLdapException; //导入依赖的package包/类
static String formatForUrl(LdapName ldapName) {
    StringBuilder sb = new StringBuilder();
    ListIterator<Rdn> it = ldapName.getRdns().listIterator(ldapName.size());
    while (it.hasPrevious()) {
        Rdn component = it.previous();

        Attributes attributes = component.toAttributes();

        // Loop through all attribute of the rdn (usually just one, but more are supported by RFC)
        NamingEnumeration<? extends Attribute> allAttributes = attributes.getAll();
        while(allAttributes.hasMoreElements()) {
            Attribute oneAttribute = allAttributes.nextElement();
            String encodedAttributeName = nameEncodeForUrl(oneAttribute.getID());

            // Loop through all values of the attribute (usually just one, but more are supported by RFC)
            NamingEnumeration <?> allValues;
            try {
                allValues = oneAttribute.getAll();
            } catch (NamingException e) {
                throw new UncategorizedLdapException("Unexpected error occurred formatting base URL", e);
            }

            while(allValues.hasMoreElements()) {
                sb.append(encodedAttributeName).append('=');

                Object oneValue = allValues.nextElement();
                if (oneValue instanceof String) {
                    String oneString = (String) oneValue;
                    sb.append(nameEncodeForUrl(oneString));
                } else {
                    throw new IllegalArgumentException("Binary attributes not supported for base URL");
                }

                if(allValues.hasMoreElements()) {
                    sb.append('+');
                }
            }
            if(allAttributes.hasMoreElements()) {
                sb.append('+');
            }
        }

        if(it.hasPrevious()) {
            sb.append(',');
        }
    }
    return sb.toString();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:49,代码来源:AbstractContextSource.java


注:本文中的org.springframework.ldap.UncategorizedLdapException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。