Hello Andreas,

We have an environment where usernames can be *any* character thus the
> rules enforced by Username does not apply to us. We were thinking about
> subclassing it, until we saw it has a private constructor signaling that it
> isn't meant for extending.
>

Do you mean org.apache.james.core.Username ?

If I understand correctly, the only character restriction there is you
can't put an @ in the local part ...  even
org.apache.james.core.Username#fromLocalPartWithoutDomain[1] won't bypass
that ( and of course the usual not null, not empty)
As you can see in
https://github.com/apache/james-project/blob/master/core/src/main/java/org/apache/james/core/Username.java#L132,
a Username has a mapping to a org.apache.james.core.MailAddress and this
mapping is used in multiple places. Allowing @ in the username would break
that conversion.

Can you provide a more detailed picture of what you are trying to achieve
and why you would want @ as part of the username ?

(I'll admit that the current check is overly restrictive as it doesn't
account for quoting in the local part [2] which allows using @ in a quoted
string or escaping @ using a \)

[1]
https://github.com/apache/james-project/blob/master/core/src/main/java/org/apache/james/core/Username.java#L71
[2] https://datatracker.ietf.org/doc/html/rfc3696#section-3

Cheers,
Jean


>
>

> I propose to change this constructor to be protected so one may extend
> this class with custom validation-logic for the userName. How are others
> handling this problem?
>
> --
> *Andreas Joseph Krogh*
> CTO / Partner - Visena AS
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
> For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to