Package com.adito.security

Examples of com.adito.security.SessionInfo


             * SessionInfo will be null if session can yet be determined
             */
            if (!transaction.attemptToAuthorize()) {
                return;
            }
            SessionInfo sessionInfo = transaction.getSessionInfo();

            // Timeout block is not needed if we have no session
            int timeoutId = sessionInfo == null ? -1 : LogonControllerFactory.getInstance().addSessionTimeoutBlock(
                transaction.getSessionInfo().getHttpSession(), "DAV Transaction");
            ;
            try {
                processor.process(transaction);
            } catch (DAVAuthenticationRequiredException dare) {
                /*
                 * If the session is temporary, then we are probably dealing
                 * with a client that doesn't support cookies. This means that
                 * secondary authentication that may be required for some mounts
                 * won't work as we cannot have two different sets of
                 * credentials without session tracking
                 */
                if (sessionInfo != null && sessionInfo.isTemporary()) {
                    throw new IOException("Mount requires further authentication. This cannot work "
                                    + "on WebDAV clients that do not support cookies.");
                } else {
                    throw dare;
                }
View Full Code Here


     */
    public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        UserAccountForm account = (UserAccountForm) form;
        PolicyUtil.checkPermission(PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE, PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, request);
        SessionInfo info = this.getSessionInfo(request);
        UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
        User user = null;
        if(udb.supportsAccountCreation()) {
            PropertyList roleList = account.getRolesList();
            int idx = 0;
            Role[] roles = new Role[roleList.size()];
            for(Iterator i = roleList.iterator(); i.hasNext(); ) {
                roles[idx++] = udb.getRole((String)i.next());
            }

            if (account.getEditing()) {
                user = udb.getAccount(account.getUsername());
                try {
                    udb.updateAccount(user, account.getEmail(), account.getFullname(), roles);
                    CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.USER_EDITED, user, info)
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, user.getPrincipalName())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_FULL_NAME, user.getFullname())
                      .addAttribute(CoreAttributeConstants.EVENT_ATTR_ACCOUNT_EMAIL, user.getEmail());

                    if(roles.length != 0) {
                        for(int i = 0; i < roles.length; i++ ) {
                            coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_GROUP + Integer.toString(i+1), roles[i].getPrincipalName());
                        }
                    }
                    CoreServlet.getServlet().fireCoreEvent(coreEvent);
                } catch (GroupsRequiredForUserException e) {
                    saveError(request, "createAccount.error.groupsRequired");
                    return mapping.findForward("display");
                } catch (UserDatabaseException e) {
                    if(UserDatabaseException.INTERNAL_ERROR == e.getCode()) {
                        handleException(CoreEventConstants.USER_CREATED, account, info, roles, e);
                        throw e;
                    } else {
                        saveError(request, e.getBundleActionMessage());
                        return mapping.findForward("display");
                    }
                } catch (Exception e) {
                    handleException(CoreEventConstants.USER_EDITED, account, info, roles, e);
                  throw e;
                }
            } else {
              try {
                    user = udb.createAccount(account.getUsername(), String.valueOf((int) (Math.random() * 100000)),
                    // Set a random password
                         account.getEmail(), account.getFullname(), roles);
                    CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.USER_CREATED, null, info, CoreEvent.STATE_SUCCESSFUL)
                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, account.getUsername())
                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_FULL_NAME, account.getFullname())
                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_ACCOUNT_EMAIL, account.getEmail());

                    if(roles.length != 0) {
                        for(int i = 0; i < roles.length; i++ ) {
                            coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_GROUP + Integer.toString(i+1), roles[i].getPrincipalName());
                        }
                    }
                    CoreServlet.getServlet().fireCoreEvent(coreEvent);
              } catch (GroupsRequiredForUserException e) {
                    saveError(request, "createAccount.error.groupsRequired");
                    return mapping.findForward("display");
              } catch (UserDatabaseException e) {
                    if(UserDatabaseException.INTERNAL_ERROR == e.getCode()) {
                        handleException(CoreEventConstants.USER_CREATED, account, info, roles, e);
                        throw e;
                    } else {
                        saveError(request, e.getBundleActionMessage());
                        return mapping.findForward("display");
                    }
              } catch (Exception e) {
                    handleException(CoreEventConstants.USER_CREATED, account, info, roles, e);
                throw e;
              }
            }
        }
        else {
            user = udb.getAccount(account.getUsername());
        }

        // Update the attributes
        for(Iterator i = account.getAttributeValueItems().iterator(); i.hasNext(); ) {
           AttributeValueItem v = (AttributeValueItem)i.next();
           if(v.getDefinition().getVisibility() != AttributeDefinition.USER_CONFIDENTIAL_ATTRIBUTE) {
               Property.setProperty(new UserAttributeKey(user, v.getDefinition().getName()), v.getDefinition().formatAttributeValue(v.getValue()), info);
           }
        }
        // XXX HACK to ensure user attributes in memory are the same as persisted
        for(Iterator j = LogonControllerFactory.getInstance().getActiveSessions().entrySet().iterator(); j.hasNext(); ) {
            Map.Entry e = (Map.Entry)j.next();
            SessionInfo sinfo = (SessionInfo)e.getValue();
            if(sinfo.getUser().getPrincipalName().equals(user.getPrincipalName())) {
                sinfo.setUser(user);
            }
        }

        // Reset the enabled state if it is different
        if (PolicyUtil.isEnabled(user) != account.isEnabled()) {
View Full Code Here

                    if (logonStatus == LogonController.INVALID_TICKET) {
                        ActionMessages msgs = new ActionMessages();
                        msgs.add(Globals.ERROR_KEY, new ActionMessage("login.invalidTicket"));
                        saveErrors(request, msgs);
                    } else if (logonStatus == LogonController.LOGGED_ON) {
                        SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request);
                        // Set the logon ticket / domain logon ticket again
                        LogonControllerFactory.getInstance().addCookies(new ServletRequestAdapter(request),
                            new ServletResponseAdapter(response),
                            (String) request.getSession().getAttribute(Constants.LOGON_TICKET), getSessionInfo(request));
View Full Code Here

     * @throws Exception
     */
    public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PromptForPrivateKeyPassphraseForm f = (PromptForPrivateKeyPassphraseForm) form;
        SessionInfo session = getSessionInfo(request);
        UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(session.getUser().getRealm());
        if(!udb.checkPassword(session.getUser().getPrincipalName(),
            f.getPassphrase())) {
          // User has entered incorrect passphrase - go back
          ActionErrors errs = new ActionErrors();
            errs.add(Globals.ERROR_KEY, new ActionMessage("promptForPrivateKeyPassphrase.error.incorrectPassphrase"));
            saveErrors(request.getSession(), errs);
View Full Code Here

    }

    if (!udb.supportsPasswordChange()) {
      throw new Exception("Underlying database does not support changing of passwords.");
    }
    SessionInfo info = this.getSessionInfo(request);

    // Read in all of the confidential user attribute values

    /* BPS - Can only do this if the users key is currently loaded */

 
View Full Code Here

   */
  public ActionForward launch(Map<String, String> parameters, ExtensionDescriptor descriptor, ApplicationShortcut shortcut, ActionMapping mapping, LaunchSession launchSession, String returnTo, HttpServletRequest request) throws ExtensionException {
    if (log.isInfoEnabled())
      log.info("Launching client application " + shortcut.getResourceName());

    SessionInfo session = launchSession.getSession();
    if (DefaultAgentManager.getInstance().hasActiveAgent(session)) {
      try {
        Request agentRequest = ((ApplicationService) DefaultAgentManager.getInstance().getService(ApplicationService.class)).launchApplication(launchSession);
        AgentTunnel agent = DefaultAgentManager.getInstance().getAgentBySession(launchSession.getSession());
        if (!agent.sendRequest(agentRequest, true, 60000)) {
View Full Code Here

    private SessionInfo getSessionInfo(User account) {
        return SessionInfo.nextSession(getSession(), "", account, getLocalHost(), SessionInfo.MANAGEMENT_CONSOLE_CONTEXT, "");
    }

    protected final void setNavigationContext(int context) {
        SessionInfo session = getSessionInfo();
        session.setNavigationContext(context);
        CoreUtil.resetMainNavigation(getSession());
    }
View Full Code Here

                    try {
                        // check to see if the user has a session, if so then logoff.
                        Iterator loggedOnUserSessions = LogonControllerFactory.getInstance().getActiveSessions().values()
                                        .iterator();
                        while (loggedOnUserSessions.hasNext()) {
                            SessionInfo element = (SessionInfo) loggedOnUserSessions.next();
                            if (element.getUser().equals(user)) {
                                element.invalidate();
                            }
                        }
                        // Revoke all polices from the user
                        PolicyDatabaseFactory.getInstance().revokeAllPoliciesFromPrincipal(user);
                        udb.deleteAccount(user);
View Full Code Here

        } else {
            UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
            for (int i = 0; accounts != null && i < accounts.length; i++) {
                User user = udb.getAccount(accounts[i]);
                boolean disabled = !PolicyUtil.isEnabled(user);
                SessionInfo session = this.getSessionInfo(request);
                if (disabled) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Re-enabling user " + user.getPrincipalName());
                    }
                    PolicyUtil.setEnabled(user, true, null, session);
View Full Code Here

            saveErrors(request, mesgs);
        } else {
            UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
            for (int i = 0; accounts != null && i < accounts.length; i++) {
                User user = udb.getAccount(accounts[i]);
                SessionInfo info = this.getSessionInfo(request);
                boolean disabled = !PolicyUtil.isEnabled(user);
                if (!disabled) {
                    if (LOG.isInfoEnabled()) {
                        LOG.info("Disabling user " + user.getPrincipalName());
                    }
View Full Code Here

TOP

Related Classes of com.adito.security.SessionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.