Search in sources :

Example 1 with LdapPrincipal

use of org.apache.directory.server.core.api.LdapPrincipal in project structr by structr.

the class StructrPartition method add.

@Override
public void add(AddOperationContext addContext) throws LdapException {
    final LdapPrincipal principal = addContext.getEffectivePrincipal();
    final Entry entry = addContext.getEntry();
    getWrapper(principal).add(entry);
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal)

Example 2 with LdapPrincipal

use of org.apache.directory.server.core.api.LdapPrincipal in project structr by structr.

the class StructrPartition method hasEntry.

@Override
public boolean hasEntry(HasEntryOperationContext hasEntryContext) throws LdapException {
    final LdapPrincipal principal = hasEntryContext.getEffectivePrincipal();
    final Dn dn = hasEntryContext.getDn();
    return getWrapper(principal).get(dn) != null;
}
Also used : LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal) Dn(org.apache.directory.api.ldap.model.name.Dn)

Example 3 with LdapPrincipal

use of org.apache.directory.server.core.api.LdapPrincipal in project structr by structr.

the class StructrPartition method search.

@Override
public EntryFilteringCursor search(SearchOperationContext searchContext) throws LdapException {
    logger.info("{}", searchContext);
    final LdapPrincipal principal = searchContext.getEffectivePrincipal();
    final Dn dn = searchContext.getDn();
    final ExprNode filter = searchContext.getFilter();
    final SearchScope scope = searchContext.getScope();
    final List<Entry> list = getWrapper(principal).filter(dn, filter, scope);
    final Cursor<Entry> cursor = new ListCursor<>(list);
    final SchemaManager manager = getSchemaManager();
    return new EntryFilteringCursorImpl(cursor, searchContext, manager);
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) ListCursor(org.apache.directory.api.ldap.model.cursor.ListCursor) EntryFilteringCursorImpl(org.apache.directory.server.core.api.filtering.EntryFilteringCursorImpl) Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal) SearchScope(org.apache.directory.api.ldap.model.message.SearchScope) Dn(org.apache.directory.api.ldap.model.name.Dn) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager)

Example 4 with LdapPrincipal

use of org.apache.directory.server.core.api.LdapPrincipal in project structr by structr.

the class StructrPartition method delete.

@Override
public Entry delete(DeleteOperationContext deleteContext) throws LdapException {
    final LdapPrincipal principal = deleteContext.getEffectivePrincipal();
    final Dn dn = deleteContext.getDn();
    final Entry entry = deleteContext.getEntry();
    getWrapper(principal).delete(dn);
    return entry;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal) Dn(org.apache.directory.api.ldap.model.name.Dn)

Example 5 with LdapPrincipal

use of org.apache.directory.server.core.api.LdapPrincipal in project aws-iam-ldap-bridge by denismo.

the class AWSIAMAuthenticator method authenticate.

@Override
public LdapPrincipal authenticate(BindOperationContext bindContext) throws Exception {
    if (!isAWSAccount(bindContext) || disabled) {
        LOG.debug("Skipping " + bindContext.getDn() + " - not an AWS account");
        if (delegatedAuth == null) {
            LOG.error("Delegated auth is null");
            return null;
        }
        return delegatedAuth.authenticate(bindContext);
    }
    LOG.debug("Authenticating " + bindContext.getDn());
    byte[] password = bindContext.getCredentials();
    LookupOperationContext lookupContext = new LookupOperationContext(getDirectoryService().getAdminSession(), bindContext.getDn(), SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES);
    Entry userEntry = getDirectoryService().getPartitionNexus().lookup(lookupContext);
    if (validator.verifyIAMPassword(userEntry, new String(password))) {
        LdapPrincipal principal = new LdapPrincipal(getDirectoryService().getSchemaManager(), bindContext.getDn(), AuthenticationLevel.SIMPLE, password);
        IoSession session = bindContext.getIoSession();
        if (session != null) {
            SocketAddress clientAddress = session.getRemoteAddress();
            principal.setClientAddress(clientAddress);
            SocketAddress serverAddress = session.getServiceAddress();
            principal.setServerAddress(serverAddress);
        }
        bindContext.setEntry(new ClonedServerEntry(userEntry));
        return principal;
    } else {
        // Bad password ...
        String message = I18n.err(I18n.ERR_230, bindContext.getDn().getName());
        LOG.info(message);
        throw new LdapAuthenticationException(message);
    }
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) ClonedServerEntry(org.apache.directory.server.core.api.entry.ClonedServerEntry) LdapPrincipal(org.apache.directory.server.core.api.LdapPrincipal) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) LookupOperationContext(org.apache.directory.server.core.api.interceptor.context.LookupOperationContext) SocketAddress(java.net.SocketAddress) ClonedServerEntry(org.apache.directory.server.core.api.entry.ClonedServerEntry) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

LdapPrincipal (org.apache.directory.server.core.api.LdapPrincipal)5 Entry (org.apache.directory.api.ldap.model.entry.Entry)4 Dn (org.apache.directory.api.ldap.model.name.Dn)3 SocketAddress (java.net.SocketAddress)1 ListCursor (org.apache.directory.api.ldap.model.cursor.ListCursor)1 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)1 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)1 SearchScope (org.apache.directory.api.ldap.model.message.SearchScope)1 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)1 ClonedServerEntry (org.apache.directory.server.core.api.entry.ClonedServerEntry)1 EntryFilteringCursorImpl (org.apache.directory.server.core.api.filtering.EntryFilteringCursorImpl)1 LookupOperationContext (org.apache.directory.server.core.api.interceptor.context.LookupOperationContext)1 IoSession (org.apache.mina.core.session.IoSession)1