-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes gh-1004
- Loading branch information
Showing
14 changed files
with
212 additions
and
32 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
core/src/main/java/org/springframework/ldap/convert/ConverterUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2002-2025 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.convert; | ||
|
||
import org.springframework.core.convert.converter.ConverterRegistry; | ||
|
||
/** | ||
* A utility class for working with Spring LDAP converters | ||
* | ||
* @author Josh Cummings | ||
* @since 3.3 | ||
*/ | ||
public final class ConverterUtils { | ||
|
||
/** | ||
* Register Spring LDAP's default converters to the given {@link ConverterRegistry}. | ||
* @param registry the {@link ConverterRegistry} to configure | ||
*/ | ||
public static void addDefaultConverters(ConverterRegistry registry) { | ||
registry.addConverter(new StringToNameConverter()); | ||
registry.addConverter(new NameToStringConverter()); | ||
} | ||
|
||
private ConverterUtils() { | ||
|
||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
core/src/main/java/org/springframework/ldap/convert/NameToStringConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2002-2025 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.convert; | ||
|
||
import javax.naming.Name; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
|
||
/** | ||
* A converer from {@link Name} to {@link String}. | ||
* | ||
* <p> | ||
* Helpful for {@link org.springframework.ldap.odm.core.ObjectDirectoryMapper} for | ||
* converting fields. Also helpful when working with {@link Name} instances in Spring MVC | ||
* applications. | ||
* | ||
* @author Josh Cummings | ||
* @since 3.3 | ||
*/ | ||
public final class NameToStringConverter implements Converter<Name, String> { | ||
|
||
@Override | ||
public String convert(Name source) { | ||
if (source == null) { | ||
return null; | ||
} | ||
|
||
return source.toString(); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
core/src/main/java/org/springframework/ldap/convert/StringToNameConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2002-2025 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.convert; | ||
|
||
import javax.naming.Name; | ||
|
||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.ldap.support.LdapUtils; | ||
|
||
/** | ||
* A converer from {@link String} to {@link Name}. | ||
* | ||
* <p> | ||
* Helpful for {@link org.springframework.ldap.odm.core.ObjectDirectoryMapper} for | ||
* converting fields. Also helpful when working with {@link Name} instances in Spring MVC | ||
* applications. | ||
* | ||
* @author Josh Cummings | ||
* @since 3.3 | ||
*/ | ||
public final class StringToNameConverter implements Converter<String, Name> { | ||
|
||
@Override | ||
public Name convert(String source) { | ||
if (source == null) { | ||
return null; | ||
} | ||
|
||
return LdapUtils.newLdapName(source); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.