[cas-dev] Principal.toString
Andrew Petro
apetro at unicon.net
Thu May 31 12:15:05 EDT 2007
Marvin,
I'm not familiar with adding toString() to an interface -- I've only
seen people advocating adding it to implementations. Is that what you
mean, that implementations of the interface, like implementations of all
Java classes, should implement toString()?
I'd be reluctant for the Principal *interface* to constrain
implementations as to what they ought to do the details of what their
toString() output ought to look like, but I'm in wholehearted agreement
that the implementations should implement the method.
Andrew
> I propose adding a toString method to the Principal interface. The
> value would be in simplifying logging statements:
>
> if (log.isDebugEnabled()) {
> log.debug("Resolved " + principal);
> }
>
> As principals grow to include useful attributes (e.g. SimplePrincipal),
> it would be enormously helpful to have simple debugging statements as
> above print something like:
>
> SimplePrincipal::id=serac,
> attributes=mail:{serac at vt.edu,serac at exchange.vt.edu},
> groups={staff,cas,admins}
>
> Of course other classes/interfaces could benefit from toString methods,
> but Principal is used so often in logging/debugging that requiring
> implementers to provide a string representation makes sense.
>
> Thoughts and feedback appreciated.
>
> Marvin
>
More information about the cas-dev
mailing list