{@inheritDoc}

@see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
493374
@Override
    public void handle ( Callback[] callbacks ) throws IOException, UnsupportedCallbackException {
        for ( Callback cb : callbacks ) {
            if ( log.isDebugEnabled() ) {
                log.debug("Got callback " + cb.getClass().getName());
            }

            if ( cb instanceof NameCallback ) {
                NameCallback nc = (NameCallback) cb;
                String userDomain = this.getSpecifiedUserDomain();
                if ( this.getUsername() != null && userDomain != null ) {
                    nc.setName(this.getUsername() + "@" + userDomain);
                }
            }
            else if ( cb instanceof PasswordCallback ) {
                PasswordCallback pc = (PasswordCallback) cb;
                if ( this.getPassword() != null ) {
                    pc.setPassword(this.getPassword().toCharArray());
                }
            }
        }
    }
314701
@Override
    public String handle(final Object value) {
        final StringBuilder s = new StringBuilder();
        if (value instanceof List) {
            final List<?> l = (List<?>) value;
            for (final Object o : l) {
                if (s.length() > 0) {
                    s.append(',');
                }
                s.append(o.toString());
            }
        } else {
            s.append(value);
        }
        return s.toString();
    }
521868
public static void handle(Throwable t) {
		if (logger.isDebugEnabled()) {
			t.printStackTrace();
		}
		JKExceptionUtil.handle(t);
	}
564613
@Override
    public void handle(RequestContext context) throws SecurityProviderException, IOException {
        RedirectUtils.redirect(context.getRequest(), context.getResponse(), getTargetUrl());
    }
523469
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        List<Callback> toRespondTo = new LinkedList<Callback>();

        String userName = null;
        boolean userFound = false;

        Properties users = getProperties();

        // A single pass may be sufficient but by using a two pass approach the Callbackhandler will not
        // fail if an unexpected order is encountered.

        // First Pass - is to double check no unsupported callbacks and to retrieve
        // information from the callbacks passing in information.
        for (Callback current : callbacks) {

            if (current instanceof AuthorizeCallback) {
                toRespondTo.add(current);
            } else if (current instanceof NameCallback) {
                NameCallback nameCallback = (NameCallback) current;
                userName = nameCallback.getDefaultName();
                userFound = users.containsKey(userName);
            } else if (current instanceof PasswordCallback && plainText) {
                toRespondTo.add(current);
            } else if (current instanceof CredentialCallback) {
                toRespondTo.add(current);
            } else if (current instanceof EvidenceVerifyCallback && ((EvidenceVerifyCallback)current).getEvidence() instanceof PasswordGuessEvidence) {
                toRespondTo.add(current);
            } else if (current instanceof RealmCallback) {
                String realm = ((RealmCallback) current).getDefaultText();
                if (this.realm.equals(realm) == false) {
                    throw DomainManagementLogger.ROOT_LOGGER.invalidRealm(realm, this.realm);
                }
            } else {
                throw new UnsupportedCallbackException(current);
            }
        }

        // Second Pass - Now iterate the Callback(s) requiring a response.
        for (Callback current : toRespondTo) {
            if (current instanceof AuthorizeCallback) {
                AuthorizeCallback acb = (AuthorizeCallback) current;
                boolean authorized = acb.getAuthenticationID().equals(acb.getAuthorizationID());
                if (authorized == false) {
                    SECURITY_LOGGER.tracef(
                            "Checking 'AuthorizeCallback', authorized=false, authenticationID=%s, authorizationID=%s.",
                            acb.getAuthenticationID(), acb.getAuthorizationID());
                }
                acb.setAuthorized(authorized);
            } else if (current instanceof PasswordCallback) {
                if (userFound == false) {
                    SECURITY_LOGGER.tracef("User '%s' not found in properties file.", userName);
                    throw new UserNotFoundException(userName);
                }
                String password = users.get(userName).toString();
                ((PasswordCallback) current).setPassword(password.toCharArray());
            } else if (current instanceof CredentialCallback) {
                if (userFound == false) {
                    SECURITY_LOGGER.tracef("User '%s' not found in properties file.", userName);
                    throw new UserNotFoundException(userName);
                }

                CredentialCallback cc = (CredentialCallback) current;
                if (PasswordCredential.class.isAssignableFrom(cc.getCredentialType())) {
                    String algorithmName = cc.getAlgorithm();
                    final Password password;
                    if ((algorithmName == null || ALGORITHM_CLEAR.equals(algorithmName)) && plainText) {
                        password = ClearPassword.createRaw(ALGORITHM_CLEAR, ((String) users.get(userName)).toCharArray());
                    } else if ((algorithmName == null || ALGORITHM_DIGEST_MD5.equals(algorithmName)) && plainText == false) {
                        byte[] hashed = ByteIterator.ofBytes(((String) users.get(userName)).getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain();
                        password = DigestPassword.createRaw(ALGORITHM_DIGEST_MD5, userName, realm, hashed);
                    } else {
                        continue;
                    }
                    cc.setCredential(cc.getCredentialType().cast(new PasswordCredential(password)));
                }
            } else if (current instanceof EvidenceVerifyCallback) {
                if (userFound == false) {
                    SECURITY_LOGGER.tracef("User '%s' not found in properties file.", userName);
                    throw new UserNotFoundException(userName);
                }
                EvidenceVerifyCallback evc = (EvidenceVerifyCallback) current;
                PasswordGuessEvidence evidence = (PasswordGuessEvidence) evc.getEvidence();
                char[] guess = evidence.getGuess();
                if (plainText) {
                    String password = users.get(userName).toString();
                    boolean verified = password.equals(new String(guess));
                    if (verified == false) {
                        SECURITY_LOGGER.tracef("Password verification failed for user '%s'", userName);
                    }
                    evc.setVerified(verified);
                } else {
                    UsernamePasswordHashUtil hashUtil = getHashUtil();
                    String hash;
                    synchronized (hashUtil) {
                        hash = hashUtil.generateHashedHexURP(userName, realm, guess);
                    }
                    String expected = users.get(userName).toString();
                    boolean verified = expected.equals(hash);
                    if (verified == false) {
                        SECURITY_LOGGER.tracef("Digest verification failed for user '%s'", userName);
                    }
                    evc.setVerified(verified);
                }
            }
        }
    }
742282
public boolean handle(CallbackQuery query, int button) {
        if (button < 0 || button > buttons.size()) {
            return false;
        }

        buttonAt(button).handlePress(query);
        return true;
    }
738254
protected void handle(HttpConnection httpConnection) throws IOException {
		try {
			getServerThread().handleIncomingHttp(httpConnection);
			httpConnection.waitForResponse();
		}
		catch (ConnectException ex) {
			httpConnection.respond(HttpStatus.GONE);
		}
	}
1230114
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        final ModelNode userMap = this.userDomain;

        List<Callback> toRespondTo = new LinkedList<Callback>();

        String userName = null;
        ModelNode user = null;
        ExceptionSupplier<CredentialSource, Exception> userCredentialSourceSupplier = null;

        // A single pass may be sufficient but by using a two pass approach the Callbackhandler will not
        // fail if an unexpected order is encountered.

        // First Pass - is to double check no unsupported callbacks and to retrieve
        // information from the callbacks passing in information.
        for (Callback current : callbacks) {

            if (current instanceof AuthorizeCallback) {
                toRespondTo.add(current);
            } else if (current instanceof NameCallback) {
                NameCallback nameCallback = (NameCallback) current;
                userName = nameCallback.getDefaultName();
                if (userMap.get(USER).hasDefined(userName)) {
                    user = userMap.get(USER, userName);
                }
                userCredentialSourceSupplier = getUserCredentialSourceSupplier(userName);
            } else if (current instanceof PasswordCallback) {
                toRespondTo.add(current);
            } else if (current instanceof RealmCallback) {
                String realm = ((RealmCallback) current).getDefaultText();
                if (this.realm.equals(realm) == false) {
                    // TODO - Check if this needs a real error or of just an unexpected internal error.
                    throw DomainManagementLogger.ROOT_LOGGER.invalidRealm(realm, this.realm);
                }
            } else {
                throw new UnsupportedCallbackException(current);
            }
        }

        // Second Pass - Now iterate the Callback(s) requiring a response.
        for (Callback current : toRespondTo) {
            if (current instanceof AuthorizeCallback) {
                AuthorizeCallback acb = (AuthorizeCallback) current;
                boolean authorized = acb.getAuthenticationID().equals(acb.getAuthorizationID());
                if (authorized == false) {
                    SECURITY_LOGGER.tracef(
                            "Checking 'AuthorizeCallback', authorized=false, authenticationID=%s, authorizationID=%s.",
                            acb.getAuthenticationID(), acb.getAuthorizationID());
                }
                acb.setAuthorized(authorized);
            } else if (current instanceof PasswordCallback) {
                if (user == null) {
                    SECURITY_LOGGER.tracef("User '%s' not found.", userName);
                    throw new UserNotFoundException(userName);
                }
                char[] password =EMPTY_PASSWORD;
                if (user.hasDefined(PASSWORD)) {
                    password = user.require(PASSWORD).asString().toCharArray();
                }
                ((PasswordCallback) current).setPassword(resolvePassword(userCredentialSourceSupplier, password));
            }

        }
    }
871999
@Override
  public void handle(
      final String target,
      final HttpServletRequest request,
      final HttpServletResponse response,
      final int i)
      throws IOException, ServletException {
    LOG.log(Level.INFO, "JettyHandler handle is entered with target: {0} ", target);

    final Request baseRequest = (request instanceof Request) ? (Request) request :
        HttpConnection.getCurrentConnection().getRequest();

    response.setContentType("text/html;charset=utf-8");

    final ParsedHttpRequest parsedHttpRequest = new ParsedHttpRequest(request);
    final HttpHandler handler = validate(request, response, parsedHttpRequest);
    if (handler != null) {
      LOG.log(Level.INFO, "calling HttpHandler.onHttpRequest from JettyHandler.handle() for {0}.",
          handler.getUriSpecification());
      handler.onHttpRequest(parsedHttpRequest, response);
      response.setStatus(HttpServletResponse.SC_OK);
    }

    baseRequest.setHandled(true);
    LOG.log(Level.INFO, "JettyHandler handle exists");
  }
1348704
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (Callback c : callbacks) {
            if (c instanceof NameCallback) {
                LOG.debug("name callback");
            } else if (c instanceof PasswordCallback) {
                LOG.debug("password callback");
                LOG.warn("Could not login: the client is being asked for a password, but the "
                        + " client code does not currently support obtaining a password from the user."
                        + " Make sure that the client is configured to use a ticket cache (using"
                        + " the JAAS configuration setting 'useTicketCache=true)' and restart the client. If"
                        + " you still get this message after that, the TGT in the ticket cache has expired and must"
                        + " be manually refreshed. To do so, first determine if you are using a password or a"
                        + " keytab. If the former, run kinit in a Unix shell in the environment of the user who" + " is running this client using the command"
                        + " 'kinit <princ>' (where <princ> is the name of the client's Kerberos principal)." + " If the latter, do"
                        + " 'kinit -k -t <keytab> <princ>' (where <princ> is the name of the Kerberos principal, and"
                        + " <keytab> is the location of the keytab file). After manually refreshing your cache,"
                        + " restart this client. If you continue to see this message after manually refreshing"
                        + " your cache, ensure that your KDC host's clock is in sync with this host's clock.");
            } else if (c instanceof AuthorizeCallback) {
                LOG.debug("authorization callback");
                AuthorizeCallback ac = (AuthorizeCallback) c;
                String authid = ac.getAuthenticationID();
                String authzid = ac.getAuthorizationID();
                if (authid.equals(authzid)) {
                    ac.setAuthorized(true);
                } else {
                    ac.setAuthorized(false);
                }
                if (ac.isAuthorized()) {
                    ac.setAuthorizedID(authzid);
                }
            } else {
                throw new UnsupportedCallbackException(c);
            }
        }
    }
552635
@EventHandler
    public void handle(AuthorizationListChangedEvent event) {
        ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId());

        if (chargingStation != null) {
            Set<LocalAuthorization> updatedLocalAuthorizations = toLocalAuthorizationSet(event.getIdentifyingTokens());

            if(AuthorizationListUpdateType.FULL.equals(event.getUpdateType())) {
                chargingStation.setLocalAuths(updatedLocalAuthorizations);
            } else {
                updateAuthorizationList(chargingStation, updatedLocalAuthorizations);
            }
            chargingStation.setLocalAuthorizationListVersion(event.getVersion());
            repository.createOrUpdate(chargingStation);
        }
    }
1071371
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        if (callbacks.length == 1 && callbacks[0] instanceof AuthorizeCallback) {
            AuthorizeCallback acb = (AuthorizeCallback) callbacks[0];
            boolean authorized = acb.getAuthenticationID().equals(acb.getAuthorizationID());
            if (authorized == false) {
                SECURITY_LOGGER.tracef(
                        "Checking 'AuthorizeCallback', authorized=false, authenticationID=%s, authorizationID=%s.",
                        acb.getAuthenticationID(), acb.getAuthorizationID());
            }
            acb.setAuthorized(authorized);

            return;
        }

        NameCallback nameCallBack = null;
        EvidenceVerifyCallback evidenceVerifyCallback = null;
        SubjectCallback subjectCallback = null;

        for (Callback current : callbacks) {
            if (current instanceof NameCallback) {
                nameCallBack = (NameCallback) current;
            } else if (current instanceof RealmCallback) {
            } else if (current instanceof EvidenceVerifyCallback) {
                evidenceVerifyCallback = (EvidenceVerifyCallback) current;
            } else if (current instanceof SubjectCallback) {
                subjectCallback = (SubjectCallback) current;
            } else {
                throw new UnsupportedCallbackException(current);
            }
        }

        if (nameCallBack == null) {
            SECURITY_LOGGER.trace("No username supplied in Callbacks.");
            throw DomainManagementLogger.ROOT_LOGGER.noUsername();
        }
        final String userName = nameCallBack.getDefaultName();
        if (userName == null || userName.length() == 0) {
            SECURITY_LOGGER.trace("NameCallback either has no username or is 0 length.");
            throw DomainManagementLogger.ROOT_LOGGER.noUsername();
        }
        if (evidenceVerifyCallback == null || evidenceVerifyCallback.getEvidence() == null) {
            SECURITY_LOGGER.trace("No password to verify.");
            throw DomainManagementLogger.ROOT_LOGGER.noPassword();
        }

        final char[] password;

        if (evidenceVerifyCallback.getEvidence() instanceof PasswordGuessEvidence) {
            password = ((PasswordGuessEvidence) evidenceVerifyCallback.getEvidence()).getGuess();
        } else {
            SECURITY_LOGGER.trace("No password to verify.");
            throw DomainManagementLogger.ROOT_LOGGER.noPassword();
        }

        Subject subject = subjectCallback != null && subjectCallback.getSubject() != null ? subjectCallback.getSubject()
                : new Subject();
        evidenceVerifyCallback.setVerified(verify(userName, password, subject, subjectCallback != null ? subjectCallback::setSubject : null));
    }
1330716
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		if (target.indexOf('.') != -1) {
			return ;
		}
		
		isHandled[0] = true;
		String[] urlPara = {null};
		Action action = actionMapping.getAction(target, urlPara);
		
		if (action == null) {
			if (log.isWarnEnabled()) {
				String qs = request.getQueryString();
				log.warn("404 Action Not Found: " + (qs == null ? target : target + "?" + qs));
			}
			renderManager.getRenderFactory().getErrorRender(404).setContext(request, response).render();
			return ;
		}
		
		Controller controller = null;
		try {
			// Controller controller = action.getControllerClass().newInstance();
			controller = controllerFactory.getController(action.getControllerClass());
			if (injectDependency) {com.jfinal.aop.Aop.inject(controller);}
			controller._init_(action, request, response, urlPara[0]);
			
			if (devMode) {
				if (ActionReporter.isReportAfterInvocation(request)) {
					new Invocation(action, controller).invoke();
					ActionReporter.report(target, controller, action);
				} else {
					ActionReporter.report(target, controller, action);
					new Invocation(action, controller).invoke();
				}
			}
			else {
				new Invocation(action, controller).invoke();
			}
			
			Render render = controller.getRender();
			if (render instanceof ForwardActionRender) {
				String actionUrl = ((ForwardActionRender)render).getActionUrl();
				if (target.equals(actionUrl)) {
					throw new RuntimeException("The forward action url is the same as before.");
				} else {
					handle(actionUrl, request, response, isHandled);
				}
				return ;
			}
			
			if (render == null) {
				render = renderManager.getRenderFactory().getDefaultRender(action.getViewPath() + action.getMethodName());
			}
			render.setContext(request, response, action.getViewPath()).render();
		}
		catch (RenderException e) {
			if (log.isErrorEnabled()) {
				String qs = request.getQueryString();
				log.error(qs == null ? target : target + "?" + qs, e);
			}
		}
		catch (ActionException e) {
			handleActionException(target, request, response, action, e);
		}
		catch (Exception e) {
			if (log.isErrorEnabled()) {
				String qs = request.getQueryString();
				log.error(qs == null ? target : target + "?" + qs, e);
			}
			renderManager.getRenderFactory().getErrorRender(500).setContext(request, response, action.getViewPath()).render();
		} finally {
			controllerFactory.recycle(controller);
		}
	}
1201210
public void handle(Callback[] callbacks) throws IOException,
            UnsupportedCallbackException {
        for (Callback c : callbacks) {
            if (c instanceof NameCallback) {
                ((NameCallback) c).setName(username);
            } else if (c instanceof PasswordCallback) {
                ((PasswordCallback) c).setPassword(password.toCharArray());
            } else {
                throw new UnsupportedCallbackException(c);
            }
        }
    }
757613
@Override
    public void handle(Message<Void> msg) {
        msg.reply(dependency.getClass().getName());
    }
377505
@Override
    public void handleNotification(Notification notification, Object handback) {
       try {
           method.invoke(target, notification, handback);
       } catch (Exception e) {
           LOG.error("Could not invoke MessageListener method " + method + " on " + target, e);
       }
        
    }
591192
@Override
    public void handle(CommandContext ctx, String commandLine) {
        String[] commands = commandLine.split(" ");
        if (commands.length != 1) {
            ctx.printLine("Invalid command.");
            return;
        }

        ctx.terminateSession();
    }