Package com.adito.security

Examples of com.adito.security.User


        //
        OutputStream responseOut = getOutputStream(type);

        //
        InputStream serverIn = responseProcessor.getProxiedInputStream();
        User user = launchSession.getSession().getUser();

        if (serverIn != null) {

            // Get just type mime type part of the content type

            String mimeType = type;
            int idx = mimeType == null ? -1 : mimeType.indexOf(";");
            if (idx != -1) {
                mimeType = mimeType.substring(0, idx);
            }

            // If there is no content type or are no replaces
            List replacements = WebForwardDatabaseFactory.getInstance().getReplacementsForContent(
                            user.getPrincipalName(), Replacement.REPLACEMENT_TYPE_RECEIVED_CONTENT, mimeType,
                            requestProcessor.getRequestParameters().getProxiedURIDetails().getProxiedURL().toExternalForm());
            if (replacements.size() > 0) {
                // The default replacer
              if (log.isDebugEnabled())
                log.debug("Found " + replacements.size() + ", processing");
View Full Code Here


                        ActionMessages msgs = new ActionMessages();
                        msgs.add(Globals.ERROR_KEY, new ActionMessage("login.invalidTicket"));
                        saveErrors(request, msgs);
                    } else if (logonStatus == LogonController.LOGGED_ON) {

                        User currentUser = LogonControllerFactory.getInstance().getUser(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

    if (evt.getId() == CoreEventConstants.LOGON) {
      SessionInfo sessionInfo = evt.getSessionInfo();
      if (sessionInfo != null && sessionInfo.getHttpSession() != null) {
        // Only add warnings to web sessions
        HttpSession session = sessionInfo.getHttpSession();
        User user = sessionInfo.getUser();
        List<GlobalWarning> globalWarnings = (List<GlobalWarning>) session.getServletContext()
                .getAttribute(Constants.CONTEXT_GLOBAL_WARNINGS);
        if (globalWarnings != null) {
          for (GlobalWarning gw : globalWarnings) {
            List<User> dismissedByUsers = dismissedWarnings.get(gw.getMessage().getKey());
View Full Code Here

     */
    public ActionForward setPassword(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
      UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
        User user = udb.getAccount(((UserAccountForm) form).getUsername());
    request.getSession().setAttribute("setPassword.user", user);
    return mapping.findForward("setPassword");   
  }
View Full Code Here

    public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.ACCOUNTS_AND_GROUPS_RESOURCE_TYPE, PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, request);
        String username = request.getParameter("username");
        UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(getSessionInfo(request).getUser().getRealm());
        User user = udb.getAccount(username);
        ((UserAccountForm) form).initialize(user, true, request);
        ((UserAccountForm) form).setReferer(CoreUtil.getReferer(request));
        return mapping.findForward("display");
    }
View Full Code Here

                    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
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void simpleCreateUser() throws Exception {
        User user = createAccount("jb", "qwqwqw", "james@localhost", "James Robinson");
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllUsers(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, 2);
        deleteAccount(user);
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllUsers(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, 1);
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void createNUsers() throws Exception {
        User user1 = createAccount("jb1", "qwqwqw", "james@localhost", "James Robinson1");
        User user2 = createAccount("jb2", "qwqwqw", "james@localhost", "James Robinson2");
        User user3 = createAccount("jb3", "qwqwqw", "james@localhost", "James Robinson3");
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllUsers(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, 4);
        deleteAccount(user1, user2, user3);
        assertEquals("There should only be the one user and he is the super user.", getDefaultUserDatabase().listAllUsers(
            UserDatabase.WILDCARD_SEARCH, Integer.MAX_VALUE).length, 1);
View Full Code Here

     */
    @Test
    public void loginSuccessfull() throws Exception {
        String username = "jb";
        String password = "qwqwqw";
        User user = createAccount(username, password, "james@localhost", "James Robinson");
        User adminUser = getDefaultUserDatabase().getAccount(USERNAME);
        getDefaultUserDatabase().setPassword(user.getPrincipalName(), password, false, adminUser, PASSWORD);
        User loggedONUser = getDefaultUserDatabase().logon(username, password);
        assertNotNull("There should be a valid user.", loggedONUser);
        deleteAccount(user);
    }
View Full Code Here

     */
    @Test
    public void checkPassword() throws Exception {
        String username = "jb";
        String password = "qwqwqw";
        User user = createAccount(username, password, "james@localhost", "James Robinson");
        User adminUser = getDefaultUserDatabase().getAccount(USERNAME);
        getDefaultUserDatabase().setPassword(user.getPrincipalName(), password, false, adminUser, PASSWORD);
        assertTrue("There password should be checked successfully.", getDefaultUserDatabase().checkPassword(username, password));
        deleteAccount(user);
    }
View Full Code Here

TOP

Related Classes of com.adito.security.User

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.