Convert to Linux Line Endings

This commit is contained in:
Josh Cummings
2022-07-21 15:09:00 -06:00
parent 15f0a8a79d
commit 9ded1758d6
270 changed files with 27844 additions and 27844 deletions

View File

@@ -1,41 +1,41 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.dao;
import org.springframework.ldap.samples.plain.domain.Person;
import java.util.List;
/**
* Data Access Object interface for the Person entity.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public interface PersonDao {
void create(Person person);
void update(Person person);
void delete(Person person);
List<String> getAllPersonNames();
List<Person> findAll();
Person findByPrimaryKey(String country, String company, String fullname);
}
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.dao;
import org.springframework.ldap.samples.plain.domain.Person;
import java.util.List;
/**
* Data Access Object interface for the Person entity.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public interface PersonDao {
void create(Person person);
void update(Person person);
void delete(Person person);
List<String> getAllPersonNames();
List<Person> findAll();
Person findByPrimaryKey(String country, String company, String fullname);
}

View File

@@ -1,147 +1,147 @@
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.dao;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.ContextMapper;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.AbstractContextMapper;
import org.springframework.ldap.samples.plain.domain.Person;
import org.springframework.ldap.support.LdapNameBuilder;
import org.springframework.ldap.support.LdapUtils;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.ldap.LdapName;
import java.util.List;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
/**
* Default implementation of PersonDao. This implementation uses
* DirContextAdapter for managing attribute values. We use a ContextMapper
* to map from the found contexts to our domain objects. This is especially useful
* since we in this case have properties in our domain objects that depend on parts of the DN.
*
* We could have worked with Attributes and an AttributesMapper implementation
* instead, but working with Attributes is a bore and also, working with
* AttributesMapper objects (or, indeed Attributes) does not give us access to
* the distinguished name. However, we do use it in one method that only needs a
* single attribute: {@link #getAllPersonNames()}.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public class PersonDaoImpl implements PersonDao {
private LdapTemplate ldapTemplate;
@Override
public void create(Person person) {
Name dn = buildDn(person);
DirContextAdapter context = new DirContextAdapter(dn);
mapToContext(person, context);
ldapTemplate.bind(dn, context, null);
}
@Override
public void update(Person person) {
Name dn = buildDn(person);
DirContextAdapter context = (DirContextAdapter) ldapTemplate.lookup(dn);
mapToContext(person, context);
ldapTemplate.modifyAttributes(dn, context.getModificationItems());
}
@Override
public void delete(Person person) {
ldapTemplate.unbind(buildDn(person));
}
@Override
public List<String> getAllPersonNames() {
return ldapTemplate.search(query()
.attributes("cn")
.where("objectclass").is("person"),
new AttributesMapper<String>() {
public String mapFromAttributes(Attributes attrs) throws NamingException {
return attrs.get("cn").get().toString();
}
});
}
@Override
public List<Person> findAll() {
return ldapTemplate.search(query()
.where("objectclass").is("person"),
PERSON_CONTEXT_MAPPER);
}
@Override
public Person findByPrimaryKey(String country, String company, String fullname) {
LdapName dn = buildDn(country, company, fullname);
return ldapTemplate.lookup(dn, PERSON_CONTEXT_MAPPER);
}
private LdapName buildDn(Person person) {
return buildDn(person.getCountry(), person.getCompany(), person.getFullName());
}
private LdapName buildDn(String country, String company, String fullname) {
return LdapNameBuilder.newInstance()
.add("c", country)
.add("ou", company)
.add("cn", fullname)
.build();
}
private void mapToContext(Person person, DirContextAdapter context) {
context.setAttributeValues("objectclass", new String[] { "top", "person" });
context.setAttributeValue("cn", person.getFullName());
context.setAttributeValue("sn", person.getLastName());
context.setAttributeValue("description", person.getDescription());
context.setAttributeValue("telephoneNumber", person.getPhone());
}
/**
* Maps from DirContextAdapter to Person objects. A DN for a person will be
* of the form <code>cn=[fullname],ou=[company],c=[country]</code>, so
* the values of these attributes must be extracted from the DN. For this,
* we use the LdapName along with utility methods in LdapUtils.
*/
private final static ContextMapper<Person> PERSON_CONTEXT_MAPPER = new AbstractContextMapper<Person>() {
@Override
public Person doMapFromContext(DirContextOperations context) {
Person person = new Person();
LdapName dn = LdapUtils.newLdapName(context.getDn());
person.setCountry(LdapUtils.getStringValue(dn, 0));
person.setCompany(LdapUtils.getStringValue(dn, 1));
person.setFullName(context.getStringAttribute("cn"));
person.setLastName(context.getStringAttribute("sn"));
person.setDescription(context.getStringAttribute("description"));
person.setPhone(context.getStringAttribute("telephoneNumber"));
return person;
}
};
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
}
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.dao;
import org.springframework.ldap.core.AttributesMapper;
import org.springframework.ldap.core.ContextMapper;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DirContextOperations;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.AbstractContextMapper;
import org.springframework.ldap.samples.plain.domain.Person;
import org.springframework.ldap.support.LdapNameBuilder;
import org.springframework.ldap.support.LdapUtils;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.ldap.LdapName;
import java.util.List;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
/**
* Default implementation of PersonDao. This implementation uses
* DirContextAdapter for managing attribute values. We use a ContextMapper
* to map from the found contexts to our domain objects. This is especially useful
* since we in this case have properties in our domain objects that depend on parts of the DN.
*
* We could have worked with Attributes and an AttributesMapper implementation
* instead, but working with Attributes is a bore and also, working with
* AttributesMapper objects (or, indeed Attributes) does not give us access to
* the distinguished name. However, we do use it in one method that only needs a
* single attribute: {@link #getAllPersonNames()}.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public class PersonDaoImpl implements PersonDao {
private LdapTemplate ldapTemplate;
@Override
public void create(Person person) {
Name dn = buildDn(person);
DirContextAdapter context = new DirContextAdapter(dn);
mapToContext(person, context);
ldapTemplate.bind(dn, context, null);
}
@Override
public void update(Person person) {
Name dn = buildDn(person);
DirContextAdapter context = (DirContextAdapter) ldapTemplate.lookup(dn);
mapToContext(person, context);
ldapTemplate.modifyAttributes(dn, context.getModificationItems());
}
@Override
public void delete(Person person) {
ldapTemplate.unbind(buildDn(person));
}
@Override
public List<String> getAllPersonNames() {
return ldapTemplate.search(query()
.attributes("cn")
.where("objectclass").is("person"),
new AttributesMapper<String>() {
public String mapFromAttributes(Attributes attrs) throws NamingException {
return attrs.get("cn").get().toString();
}
});
}
@Override
public List<Person> findAll() {
return ldapTemplate.search(query()
.where("objectclass").is("person"),
PERSON_CONTEXT_MAPPER);
}
@Override
public Person findByPrimaryKey(String country, String company, String fullname) {
LdapName dn = buildDn(country, company, fullname);
return ldapTemplate.lookup(dn, PERSON_CONTEXT_MAPPER);
}
private LdapName buildDn(Person person) {
return buildDn(person.getCountry(), person.getCompany(), person.getFullName());
}
private LdapName buildDn(String country, String company, String fullname) {
return LdapNameBuilder.newInstance()
.add("c", country)
.add("ou", company)
.add("cn", fullname)
.build();
}
private void mapToContext(Person person, DirContextAdapter context) {
context.setAttributeValues("objectclass", new String[] { "top", "person" });
context.setAttributeValue("cn", person.getFullName());
context.setAttributeValue("sn", person.getLastName());
context.setAttributeValue("description", person.getDescription());
context.setAttributeValue("telephoneNumber", person.getPhone());
}
/**
* Maps from DirContextAdapter to Person objects. A DN for a person will be
* of the form <code>cn=[fullname],ou=[company],c=[country]</code>, so
* the values of these attributes must be extracted from the DN. For this,
* we use the LdapName along with utility methods in LdapUtils.
*/
private final static ContextMapper<Person> PERSON_CONTEXT_MAPPER = new AbstractContextMapper<Person>() {
@Override
public Person doMapFromContext(DirContextOperations context) {
Person person = new Person();
LdapName dn = LdapUtils.newLdapName(context.getDn());
person.setCountry(LdapUtils.getStringValue(dn, 0));
person.setCompany(LdapUtils.getStringValue(dn, 1));
person.setFullName(context.getStringAttribute("cn"));
person.setLastName(context.getStringAttribute("sn"));
person.setDescription(context.getStringAttribute("description"));
person.setPhone(context.getStringAttribute("telephoneNumber"));
return person;
}
};
public void setLdapTemplate(LdapTemplate ldapTemplate) {
this.ldapTemplate = ldapTemplate;
}
}

View File

@@ -1,104 +1,104 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.domain;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* Simple class representing a single person.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public class Person {
private String fullName;
private String lastName;
private String description;
private String country;
private String company;
private String phone;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(
this, obj);
}
public int hashCode() {
return HashCodeBuilder
.reflectionHashCode(this);
}
public String toString() {
return ToStringBuilder.reflectionToString(
this, ToStringStyle.MULTI_LINE_STYLE);
}
}
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ldap.samples.plain.domain;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
* Simple class representing a single person.
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public class Person {
private String fullName;
private String lastName;
private String description;
private String country;
private String company;
private String phone;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(
this, obj);
}
public int hashCode() {
return HashCodeBuilder
.reflectionHashCode(this);
}
public String toString() {
return ToStringBuilder.reflectionToString(
this, ToStringStyle.MULTI_LINE_STYLE);
}
}