Hi Fredrik,
sorry for being late in this thread, was quite busy with day jobs lately...
There is a class that check that the syntax is correct:
org.apache.directory.api.ldap.model.schema.syntaxCheckers.PostalAddressSyntaxChecker
which offers a isValidSyntax(Object value) method. if you call it with a
proper Postal Address, it will return true (and false if it's improper).
Now, it's a bit different from what you want (encode and decode) but all
in all, what you probably need is a way to create a syntaxically correct
Postal Address accordingly to the RFC, and it may be the correct class
to do that. Actually, calling it escape() instead of encode might make
sense, because you just want to produce a syntaxically correct address.
But let me ask: how will you know if the '$' should be escaped (if it's
part of a line)?
On 07/03/2025 20:18, Fredrik Roubert wrote:
On Thu 06 Mar 2025 at 09:57 -0600, Shawn McKinney wrote:
What do the API changes look like? Do you have a sample interface?
I was thinking that an obvious first step would be to copy the utility
functions for Postal Address syntax from Studio (where they were added
by myself a few years ago):
https://github.com/apache/directory-studio/blob/master/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/utils/Utils.java
Then they'd show up in the API libraries like this:
package org.apache.directory.api.util;
/**
* Create decoders and encoders for the RFC 4517 Postal Address syntax.
*
* <pre>
* PostalAddress = line *( DOLLAR line )
* line = 1*line-char
* line-char = %x00-23
* / (%x5C "24") ; escaped "$"
* / %x25-5B
* / (%x5C "5C") ; escaped "\"
* / %x5D-7F
* / UTFMB
* </pre>
*/
public final class PostalAddress
{
/**
* Creates a decoder that uses the specified line separator.
*
* @param separator the separator to output between address lines
* @return a commons-text translator object for decoding
*/
public static CharSequenceTranslator createDecoder( String separator );
/**
* Creates an encoder that uses the specified line separator.
*
* @param separator the separator used between address lines
* @return a commons-text translator object for encoding
*/
public static CharSequenceTranslator createEncoder( String separator );
}
(Then, once this has been released and Studio has been updated to use
that version of the API libraries, Studio will no longer need to keep
its own implementation, so we have a real first user of the functions
while also providing this functionality to others.)
Cheers // Fredrik Roubert
--
------------------------ Emmanuel Lécharny emm...@worteks.com
elecha...@apache.org ------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@directory.apache.org
For additional commands, e-mail: dev-h...@directory.apache.org