spring-projects / spring-projects/spring-ldap
Add default UUID to byte array converter with little endian support
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 375
- Forks
- 501
- Avg merge
- 6h 4m
- Merged PRs (30d)
- 63
Description
Since all binary data is stored in little endian format in ldap, it is not very obvious that the following objectGUID 90d1c68e-01be-4485-aafd-b3ffb9ddb026 should be converted to an octet string \8e\c6\d1\90\be\01\85\44\aa\fd\b3\ff\b9\dd\b0\26.
Please, provide the default converters for byte[] <-> java.util.UUID transformations. Here are some of my ideas for these converters:
@Component
class ByteArrayToUuidConverter : Converter<ByteArray, UUID> {
override fun convert(guidBytes: ByteArray): UUID {
require(guidBytes.size == 16) {
"Guid bytes must be 16 byte long, but was ${guidBytes.size}"
}
val bytes = guidBytes.copyOf().apply {
reverse(0, 4)
reverse(4, 6)
reverse(6, 8)
}
return ByteBuffer.wrap(bytes).let { UUID(it.long, it.long) }
}
}
@Component
class UuidToByteArrayConverter : Converter<UUID, ByteArray> {
override fun convert(source: UUID): ByteArray {
val byteBuffer = ByteBuffer.wrap(ByteArray(16)).apply {
putLong(source.mostSignificantBits)
putLong(source.leastSignificantBits)
}
val guidBytes = byteBuffer.array().apply {
reverse(0, 4)
reverse(4, 6)
reverse(6, 8)
}
return guidBytes
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue specifies the UUID and expected LDAP octet-string representation, along with converter sketches. Start by locating how default byte[] and UUID conversions are registered and where their tests belong; done means both conversion directions support the little-endian representation and reject byte arrays that are not 16 bytes long.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100