@@ -0,0 +1,2379 @@
+package solutions.digamma.damas.jaas;%0A%0Aimport javax.security.auth.Subject;%0Aimport javax.security.auth.callback.CallbackHandler;%0Aimport javax.security.auth.callback.NameCallback;%0Aimport javax.security.auth.callback.PasswordCallback;%0Aimport javax.security.auth.callback.UnsupportedCallbackException;%0Aimport javax.security.auth.spi.LoginModule;%0Aimport java.io.IOException;%0Aimport java.security.Principal;%0Aimport java.util.Map;%0A%0Apublic abstract class PasswordBasedLoginModule implements LoginModule %7B%0A    protected Subject subject;%0A    private CallbackHandler callbackHandler;%0A    protected String login;%0A    protected char%5B%5D password;%0A    protected Map sharedState;%0A%0A    private static final String USERNAME = %22javax.security.auth.login.name%22;%0A    private static final String PASSWORD = %22javax.security.auth.login.password%22;%0A%0A    @Override%0A    public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) %7B%0A        this.subject = subject;%0A        this.callbackHandler = callbackHandler;%0A        this.sharedState = sharedState;%0A        this.extractCredentials();%0A    %7D%0A%0A    private void extractCredentials() %7B%0A        Object userObj = this.sharedState.get(USERNAME);%0A        Object passObj = this.sharedState.get(PASSWORD);%0A        if (userObj instanceof Principal) %7B%0A            this.login = ((Principal) userObj).getName();%0A        %7D else if (userObj != null) %7B%0A            this.login = userObj.toString();%0A        %7D else %7B%0A            NameCallback callback = new NameCallback(%22username%22);%0A            try %7B%0A                this.callbackHandler.handle(new NameCallback%5B%5D %7Bcallback%7D);%0A                this.login = callback.getName();%0A            %7D catch (UnsupportedCallbackException %7C IOException e) %7B%0A                this.login = null;%0A            %7D%0A        %7D%0A        if (passObj instanceof char%5B%5D) %7B%0A            this.password = (char%5B%5D) passObj;%0A        %7D else if (passObj != null) %7B%0A            this.password = passObj.toString().toCharArray();%0A        %7D else %7B%0A            PasswordCallback callback = new PasswordCallback(%22password%22, false);%0A            try %7B%0A                this.callbackHandler.handle(new PasswordCallback%5B%5D %7Bcallback%7D);%0A                this.password = callback.getPassword();%0A            %7D catch (UnsupportedCallbackException %7C IOException e) %7B%0A                this.password = null;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add utility `LoginModule` for future use