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);
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations