本文整理汇总了Java中org.apache.directory.api.ldap.model.cursor.CursorException类的典型用法代码示例。如果您正苦于以下问题:Java CursorException类的具体用法?Java CursorException怎么用?Java CursorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CursorException类属于org.apache.directory.api.ldap.model.cursor包,在下文中一共展示了CursorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isMemberOfAllowedGroups
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
private boolean isMemberOfAllowedGroups(LdapConnection connection,
String username) throws CursorException, LdapException {
if (ldapAllowedGroups.size() == 0) {
return true;
}
for (String group : ldapAllowedGroups) {
Entry result = connection.lookup("cn=" + group + ","
+ ldapGroupSearchBase);
if (result == null) {
return false;
}
Attribute members = result.get("memberuid");
if (members == null) {
return false;
}
return members.contains(username);
}
return false;
}
示例2: addLdapGroup
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
protected Entry addLdapGroup(String cn, String description, String... memberDns) throws LdapException, IOException, CursorException {
LdapNetworkConnection connection = ldapConnect();
Entry entry = createGroupEntry(cn, description, memberDns);
LOGGER.trace("Adding LDAP entry:\n{}", entry);
connection.add(entry);
display("Added LDAP group:"+entry);
ldapDisconnect(connection);
return entry;
}
示例3: searchNode
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This method will search the directory and return at most one record. If more than one record is found
* an ldap exception will be thrown.
*
* @param connection is LdapConnection object used for all communication with host.
* @param baseDn contains address of distinguished name to begin ldap search
* @param scope indicates depth of search starting at basedn. 0 (base dn),
* 1 (one level down) or 2 (infinite) are valid values.
* @param filter contains the search criteria
* @param attrs is the requested list of attritubutes to return from directory search.
* @param attrsOnly if true pull back attribute names only.
* @return entry containing target ldap node.
* @throws LdapException thrown in the event of error in ldap client or server code.
* @throws CursorException If we weren't able to fetch an element from the search result
*/
protected Entry searchNode( LdapConnection connection, String baseDn, SearchScope scope, String filter,
String[] attrs, boolean attrsOnly ) throws LdapException, CursorException
{
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( new Dn( baseDn ) );
searchRequest.setFilter( filter );
searchRequest.setScope( scope );
searchRequest.setTypesOnly( attrsOnly );
searchRequest.addAttributes( attrs );
SearchCursor result = connection.search( searchRequest );
Entry entry = result.getEntry();
if ( result.next() )
{
throw new LdapException( "searchNode failed to return unique record for LDAP search of base DN [" +
baseDn + "] filter [" + filter + "]" );
}
return entry;
}
示例4: getUserRoles
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
@Override
public Set<String> getUserRoles(String userId) throws UserException {
Set<String> roles = new HashSet<String>();
try {
String filter = "(" + config.getGroupFilter().replace("{0}", userDn(userId)) + ")";
EntryCursor cursor = connection.search(config.getGroupSearchBase(), filter,
SearchScope.SUBTREE);
while(cursor.next()) {
Entry entry = cursor.get();
roles.add(entry.get("cn").getString());
}
} catch (LdapException | CursorException e) {
throw new UserException(e);
}
return roles;
}
示例5: getChildList
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* Get child list
*
* @param entryDN The distinguished name of an Entry in the LDAP
* @param connection An initialized LDAP-Context
* @return All child's of an Entry
* @throws IOException
* @throws CursorException
* @throws LdapException
*/
private List<String> getChildList(String entryDN, LdapConnection connection) throws CursorException, IOException, LdapException {
List<String> childs = new ArrayList<String>();
EntryCursor cursor = connection.search("ou=system", "(objectclass=*)", SearchScope.ONELEVEL);
while (cursor.next()) {
Entry entry = cursor.get();
childs.add(entry.get("distinguishedName").getString());
}
//SearchResultDone done = cursor.getSearchResultDone();
//ResultCodeEnum resultCode = done.getLdapResult().getResultCode();
cursor.close();
// ResultCodeEnum.SUCCESS == resultCode
return childs;
}
示例6: getAccountData
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* Get account data
*
* @param accountDN The distinguished Name of the Account (e.g
* "cn=Daniel Trabe,ou=USERS,ou=SRFG,dc=salzburgresearch,dc=at")
* @param connection An initialized LDAP-Context
* @return a Map of Attributes and Values of an Account
* @throws DataRetrievalException
* @throws IOException
* @throws CursorException
* @throws LdapException
*/
private Map<String, List<String>> getAccountData(String accountDN, LdapConnection connection) throws DataRetrievalException, LdapException, CursorException, IOException {
Map<String, List<String>> account = new HashMap<String, List<String>>();
Dn dn = new Dn(accountDN);
EntryCursor cursor = connection.search(dn, accountDN, SearchScope.ONELEVEL, (String[])null);
if (cursor.next()) {
//FIXME: only the first entry?
Entry entry = cursor.get();
for (Attribute attr : entry.getAttributes()) {
String id = attr.getId();
List<String> values;
if (account.containsKey(id)) {
values = account.get(id);
} else {
values = new ArrayList<String>();
}
values.add(attr.get().getValue().toString());
account.put(id, values);
}
}
return account;
}
示例7: get
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Entry get() throws CursorException
{
if ( !searchCursor.available() )
{
throw new InvalidCursorPositionException();
}
try
{
do
{
if ( response instanceof SearchResultEntry )
{
return ( ( SearchResultEntry ) response ).getEntry();
}
if ( response instanceof SearchResultReference )
{
throw new LdapReferralException( ( ( SearchResultReference ) response ).getReferral().getLdapUrls() );
}
}
while ( next() && !( response instanceof SearchResultDone ) );
}
catch ( LdapReferralException lre )
{
throw new CursorLdapReferralException( lre );
}
catch ( Exception e )
{
throw new CursorException( e );
}
return null;
}
示例8: after
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public void after( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "after( Response element )" ) ) );
}
示例9: afterLast
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public void afterLast() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "afterLast()" ) ) );
}
示例10: before
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public void before( Entry element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "before( Response element )" ) ) );
}
示例11: beforeFirst
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public void beforeFirst() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "beforeFirst()" ) ) );
}
示例12: first
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public boolean first() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "first()" ) ) );
}
示例13: last
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public boolean last() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "last()" ) ) );
}
示例14: previous
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public boolean previous() throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "previous()" ) ) );
}
示例15: after
import org.apache.directory.api.ldap.model.cursor.CursorException; //导入依赖的package包/类
/**
* This operation is not supported in SearchCursor.
* {@inheritDoc}
*/
@Override
public void after( Response element ) throws LdapException, CursorException
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION, getClass().getName()
.concat( "." ).concat( "after( Response element )" ) ) );
}