/** * Checks the request for the presence of a parameter named * 'javax.servlet.request.X509Certificate', if present and not null or empty takes the first * certificate from the array and sets it on the X509CerificateCallback and returns true. * * <p>{@inheritDoc} */ public boolean updateCallbackFromRequest( HttpHeaders headers, HttpServletRequest request, HttpServletResponse response, X509CertificateCallback callback) { X509Certificate[] certificates = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); if (certificates != null && certificates.length > 0) { callback.setCertificate(certificates[0]); } return true; }
/* * process callbacks */ private void processRequirements( String xml, AuthContextLocal authContext, AuthXMLResponse authResponse, String params, HttpServletRequest servletRequest) { String[] paramArray = null; StringTokenizer paramsSet = null; if (params != null) { paramsSet = new StringTokenizer(params, ISAuthConstants.PIPE_SEPARATOR); } boolean allCallbacksAreSet = true; String param; while (authContext.hasMoreRequirements()) { Callback[] reqdCallbacks = authContext.getRequirements(); for (int i = 0; i < reqdCallbacks.length; i++) { if (reqdCallbacks[i] instanceof X509CertificateCallback) { X509CertificateCallback certCallback = (X509CertificateCallback) reqdCallbacks[i]; LoginState loginState = AuthUtils.getLoginState(authContext); if (loginState != null) { X509Certificate cert = loginState.getX509Certificate(servletRequest); if (cert != null) { certCallback.setCertificate(cert); certCallback.setReqSignature(false); } else { allCallbacksAreSet = false; } } } else { param = null; if (reqdCallbacks[i] instanceof NameCallback) { param = getNextParam(paramsSet); if (param != null) { NameCallback nc = (NameCallback) reqdCallbacks[i]; nc.setName(param); if (messageEnabled) { debug.message("Name callback set to " + param); } } else { allCallbacksAreSet = false; break; } } else if (reqdCallbacks[i] instanceof PasswordCallback) { param = getNextParam(paramsSet); if (param != null) { PasswordCallback pc = (PasswordCallback) reqdCallbacks[i]; pc.setPassword(param.toCharArray()); if (messageEnabled) { debug.message("Password callback is set"); } } else { allCallbacksAreSet = false; break; } } else { if (params == null) { allCallbacksAreSet = false; } } // add more callbacks if required } } if (getNextParam(paramsSet) != null) { allCallbacksAreSet = false; } if (allCallbacksAreSet) { if (messageEnabled) { debug.message("submit callbacks with passed in params"); } authContext.submitRequirements(reqdCallbacks); } else { authResponse.setReqdCallbacks(reqdCallbacks); break; } } if (!authContext.hasMoreRequirements()) { AuthContext.Status loginStatus = authContext.getStatus(); if (messageEnabled) { debug.message(" Status: " + loginStatus); } authResponse.setLoginStatus(loginStatus); } }