GithubHelp home page GithubHelp logo

spring-projects / spring-data-ldap Goto Github PK

View Code? Open in Web Editor NEW
65.0 11.0 54.0 2.4 MB

Repository abstraction for Spring LDAP

Home Page: http://projects.spring.io/spring-data-ldap

License: Apache License 2.0

Java 100.00%
ddd spring-ldap spring-data ldap framework

spring-data-ldap's Introduction

Spring Data LDAP icon?job=spring data ldap%2Fmain&subject=Build Gitter Revved up by Develocity

The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.

The Spring Data LDAP project aims to provide familiar and consistent repository abstractions for Spring LDAP.

Features

  • Spring configuration support using Java-based @Configuration classes or an XML namespace.

  • Annotation based mapping metadata.

  • Automatic implementation of Repository interfaces including support for custom query methods.

  • QueryDSL integration to support type-safe queries.

Code of Conduct

This project is governed by the Spring Code of Conduct. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].

Getting Started

Here is a quick teaser of an application using Spring Data Repositories in Java:

public interface PersonRepository extends CrudRepository<Person, Long> {

  List<Person> findByLastname(String lastname);

  List<Person> findByFirstnameLike(String firstname);
}

@Service
public class MyService {

  private final PersonRepository repository;

  public MyService(PersonRepository repository) {
    this.repository = repository;
  }

  public void doWork() {

    repository.deleteAll();

    Person person = new Person();
    person.setFirstname("Rob");
    person.setLastname("Winch");
    repository.save(person);

    List<Person> lastNameResults = repository.findByLastname("Winch");
    List<Person> firstNameResults = repository.findByFirstnameLike("R*");
 }
}

@Configuration
@EnableLdapRepositories
class ApplicationConfig {

}

Maven configuration

Add the Maven dependency:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-ldap</artifactId>
  <version>${version}</version>
</dependency>

If you’d rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-ldap</artifactId>
  <version>${version}-SNAPSHOT</version>
</dependency>

<repository>
  <id>spring-snapshot</id>
  <name>Spring Snapshot Repository</name>
  <url>https://repo.spring.io/snapshot</url>
</repository>

Getting Help

Having trouble with Spring Data? We’d love to help!

Reporting Issues

Spring Data uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem.

  • If the issue doesn’t already exist, create a new issue.

  • Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version.

  • If you need to paste code, or include a stack trace use Markdown ``` escapes before and after your text.

  • If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.

Building from Source

You don’t need to build from source to use Spring Data (binaries in repo.spring.io), but if you want to try out the latest and greatest, Spring Data can be easily built with the maven wrapper. You also need JDK 1.8.

 $ ./mvnw clean install

If you want to build with the regular mvn command, you will need Maven v3.8.0 or above.

Also see CONTRIBUTING.adoc if you wish to submit pull requests, and in particular please sign the Contributor’s Agreement before your first non-trivial change.

Building reference documentation

Building the documentation builds also the project without running tests.

 $ ./mvnw clean install -Pantora

The generated documentation is available from target/antora/site/index.html.

Examples

License

Spring Data LDAP is Open Source software released under the Apache 2.0 license.

spring-data-ldap's People

Contributors

christophstrobl avatar eddumelendez avatar erichaagdev avatar gregturn avatar jumarko avatar jxblum avatar koraktor avatar mp911de avatar odrotbohm avatar runbing avatar schauder avatar spring-builds avatar sxhinzvc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-data-ldap's Issues

Spring Data Example Tests fail with NoClassDefFoundError: LdapContextSource [DATALDAP-38]

Jens Schauder opened DATALDAP-38 and commented

The LDAP example fails when run with JDK9 without the --permit-illegal-access flag.

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContextSource' defined in class path resource [org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ldap.core.ContextSource]: Factory method 'ldapContextSource' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.ldap.core.support.LdapContextSource
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ldap.core.ContextSource]: Factory method 'ldapContextSource' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.ldap.core.support.LdapContextSource
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.ldap.core.support.LdapContextSource

Issue Links:

Ldap Repository can not be created using latest Spring Boot 2.0 with Spring Framework 5.0 [DATALDAP-13]

Guan Wang opened DATALDAP-13 and commented

My code stopped working since 2 days ago and I submitted this at Spring Boot:
spring-projects/spring-boot#7670

It seems this issue has been solved. However, I still have issue to make my code working: If I put @EnableLapRepositories on a class with a @Bean for ldapTemplate to enable a LDAP Repository, Spring complains the following:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)

My guess is that userRepository needs a ldapTemplate bean, which is not available at this moment.

I am not sure if I made a classic "amateur" mistake or this has something to do with the recent upgrade to SPF 5.0


Affects: 1.0 RC1 (Ingalls)

Create ability to do string replacements on base= @Query in interfaces [DATALDAP-22]

Brett Maxfield opened DATALDAP-22 and commented

It would be nice to be able to replace parameters in base dn of a custom @Query

For example, you can do this as of 1.0.0 (using default SimpleLdapRepository) :

@Query(value="(mail={0})", searchScope=SearchScope.SUBTREE, base="o=hosting,dc=example,dc=com")
MailAccount findByMail(String mail);

The {0} is replaced with the 0'th parameter on the interface, tokens repalced by the spring QueryBuilder

But something you cannot do (so it's a theoretical example, of scope single) :

@Query(value="(mail={0})", searchScope=SearchScope.ONELEVEL, base="jvd={1},o=hosting,dc=example,dc=com")
MailAccount findByDomain(String mail, String domain);

The intent would be to expands the placeholder(s) in the base= field in the annotation, with the numbered argument, and do a search in the requested scope, using the search filter with the replaced parameters. Alternatively (perhaps in addition) using the named @Param annotation, as used by spring-data-jpa

In this case there is a LDAP structure like :

o=hosting
jvd=domain1
mail=somebody@domain1
jvd=domain2
...

The first query is valid, and it works, as it has a subtree scope, and it so happens the mail=* entries under the jvd=domain structure are also unique when queried from o=hosting scope, but it is only a happy accident. In my application i do a findAll() with an LdapQuery incl., a crafted base, this was pushed up to the business objects implementations, a bit messy.

A per-domain search in this application should search in that subtree only. The standard @DnAttribute paradigm is too inflexible for this, as the domain does not stand by itself in any ldap field, that can be mapped to a bean field (without custom logic to split the mail).

If there were (uid=x) entries, which are only valid if searched within the jvd=domain structure, then this would not be appropriate. The (jvd=x) structures are managed by separate organizations, it is a standard structure for virtual mailbox applications


Affects: 1.0 GA (Ingalls)

1.0 RC1 (Ingalls) Backported Issues

  • Adapt API in RepositoryFactoryBeanSupport implementation #26
  • Upgrade to Spring LDAP 2.2.0 GA #31
  • Upgrade to a newer JDK version on TravisCI #32
  • Add build profile for next Spring LDAP version #35
  • Upgrade to Spring LDAP 2.3 RC1 #36

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.