Hi devs,
how you doing?

I was checking out the security API proposed by Undertow and I've identified that io.undertow.security.idm.IdentityManager receive an empty credential as parameter in two of its methods. After taking a look into the Java Docs and the exemple codes I figure out why.

As proposed in the original design, an IdentityManager should know which kind of credential was created by the AuthenticationMechanism, cast it, and then apply the desired identity match. It means that there's an existance relation between both IdentityManager and AuthenticationMechanism.

Maybe, making Credential a generic parameter of IdentityManager it will make IdentityManager more plugable. It also forces us the improve SecurityContext with this new design.

A little sample copied from BasicAuthenticationMechanism.java[106~110] as an exemple.

final IdentityManager<PasswordCredential> idm = securityContext.getIdentityManagerFor( PasswordCredential.class );
final PasswordCredential credential = new PasswordCredential(password);
try {
    final AuthenticationMechanismOutcome result;
    Account account = idm.verify(userName, credential);

Let me know if this makes sense for Undertow needs!

Regards