List of usage examples for javax.security.auth.callback NameCallback getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:edu.vt.middleware.ldap.jaas.AbstractLoginModule.java
/** * This attempts to retrieve credentials for the supplied name and password * callbacks. If useFirstPass or tryFirstPass is set, then name and password * data is retrieved from shared state. Otherwise a callback handler is used * to get the data. Set useCallback to force a callback handler to be used. * * @param nameCb to set name for//from w w w .j a va 2s .c om * @param passCb to set password for * @param useCallback whether to force a callback handler * * @throws LoginException if the callback handler fails */ protected void getCredentials(final NameCallback nameCb, final PasswordCallback passCb, final boolean useCallback) throws LoginException { if (this.logger.isTraceEnabled()) { this.logger.trace("Begin getCredentials"); this.logger.trace(" useFistPass = " + this.useFirstPass); this.logger.trace(" tryFistPass = " + this.tryFirstPass); this.logger.trace(" useCallback = " + useCallback); this.logger.trace(" callbackhandler class = " + this.callbackHandler.getClass().getName()); this.logger.trace(" name callback class = " + nameCb.getClass().getName()); this.logger.trace(" password callback class = " + passCb.getClass().getName()); } try { if ((this.useFirstPass || this.tryFirstPass) && !useCallback) { nameCb.setName((String) this.sharedState.get(LOGIN_NAME)); passCb.setPassword((char[]) this.sharedState.get(LOGIN_PASSWORD)); } else if (this.callbackHandler != null) { this.callbackHandler.handle(new Callback[] { nameCb, passCb }); } else { throw new LoginException("No CallbackHandler available. " + "Set useFirstPass, tryFirstPass, or provide a CallbackHandler"); } } catch (IOException e) { if (this.logger.isErrorEnabled()) { this.logger.error("Error reading data from callback handler", e); } this.loginSuccess = false; throw new LoginException(e.getMessage()); } catch (UnsupportedCallbackException e) { if (this.logger.isErrorEnabled()) { this.logger.error("Unsupported callback", e); } this.loginSuccess = false; throw new LoginException(e.getMessage()); } }