/*
  * (non-Javadoc)
  *
  * @see com.sslexplorer.wizard.forms.AbstractWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence)
  */
 public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
   resourceName =
       (String) sequence.getAttribute(AthenticationSchemeDetailsForm.ATTR_RESOURCE_NAME, null);
   PropertyList l =
       (PropertyList)
           sequence.getAttribute(
               AthenticationSchemePolicySelectionForm.ATTR_SELECTED_POLICIES, null);
   selectedPolicies = new ArrayList();
   for (Iterator i = l.iterator(); i.hasNext(); ) {
     selectedPolicies.add(
         PolicyDatabaseFactory.getInstance()
             .getPolicy(Integer.parseInt(i.next().toString()))
             .getResourceName());
   }
   user = (User) sequence.getAttribute(AthenticationSchemeSelectionAction.ATTR_USER, null);
 }
Ejemplo n.º 2
0
  /**
   * Complete the authentication process.
   *
   * @param scheme scheme
   * @param request request
   * @param response response
   * @return forward to
   * @throws Exception on any error
   */
  public static ActionForward finishAuthentication(
      AuthenticationScheme scheme, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    // Check we have a user object
    if (scheme.getUser() == null) {
      throw new Exception("No authentication module provided a user.");
    }

    // now add the policies associated with this scheme to the http session
    // if the property says so.
    if (Property.getPropertyBoolean(
        new SystemConfigKey("security.enforce.policy.resource.access"))) {
      List signOnPolicies =
          PolicyDatabaseFactory.getInstance()
              .getPoliciesAttachedToResource(scheme, scheme.getUser().getRealm());
      scheme.getServletSession().setAttribute("auth.scheme.policies", signOnPolicies);
    }

    // If the user is a manager, check if there is a new SSL-Explorer
    // version, or if there any exension updates
    if (PolicyDatabaseFactory.getInstance()
        .isAnyAccessRightAllowed(scheme.getUser(), true, true, false)) {

      if ("false"
              .equals(Property.getProperty(new ContextKey("webServer.disableCertificateWarning")))
          && !KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE)
              .isCertificateTrusted(Property.getProperty(new ContextKey("webServer.alias")))) {
        GlobalWarningManager.getInstance()
            .addMultipleGlobalWarning(
                new GlobalWarning(
                    GlobalWarning.MANAGEMENT_USERS,
                    new BundleActionMessage("keystore", "keyStore.untrustedCertificate.warning"),
                    DismissType.DISMISS_FOR_USER));
      }
    }

    /*
     * Each authentication module needs to be informed that authentication
     * is now complete so it may perform any last minute checks
     */
    scheme.authenticationComplete(request, response);

    // Allow the home page to be redirected.
    request.getSession().setAttribute(Constants.REDIRECT_HOME, "true");

    // Authenitcation sequence complete
    if (log.isDebugEnabled())
      log.debug(scheme.getUsername() + " [" + request.getRemoteHost() + "] has been authenticated");

    // Forward control to the specified success URI (possibly from the
    // initial unautenticated request)
    String originalRequest = (String) request.getSession().getAttribute(Constants.ORIGINAL_REQUEST);
    ActionForward forward = null;

    // Where next?
    List profiles = (List) request.getSession().getAttribute(Constants.PROFILES);
    int selectProfileAtLogin = -1;
    try {
      selectProfileAtLogin =
          Property.getPropertyInt(
              new UserAttributeKey(scheme.getUser(), User.USER_STARTUP_PROFILE));
    } catch (NumberFormatException nfe) {
    }
    if (selectProfileAtLogin == -1 && profiles != null && profiles.size() > 1) {
      // Prompt for the profile
      forward = new ActionForward("/showSelectPropertyProfile.do");
    } else {
      if (null == originalRequest
          || "/showHome.do".equals(originalRequest)
          || "".equals(originalRequest)) {
        boolean admin = LogonControllerFactory.getInstance().isAdministrator(scheme.getUser());
        if (admin) {
          originalRequest = "/showSystemConfiguration.do";
        } else {
          originalRequest = "/showHome.do";
        }
        request.getSession().removeAttribute(Constants.ORIGINAL_REQUEST);
      }
      if (Property.getPropertyBoolean(
          new ProfilePropertyKey(
              "client.autoStart", LogonControllerFactory.getInstance().getSessionInfo(request)))) {
        request.getSession().removeAttribute(Constants.ORIGINAL_REQUEST);
        request.getSession().setAttribute(Constants.REQ_ATTR_LAUNCH_AGENT_REFERER, originalRequest);
        forward = new ActionForward("/launchAgent.do", false);
      } else {
        forward = new ActionForward(originalRequest, true);
      }
    }
    return forward;
  }