Package com.adito.core

Examples of com.adito.core.CoreEvent


            accessRights = PolicyDatabaseFactory.getInstance().createAccessRights(defaultAccessRights);         
           
            actionStatus.add(new WizardActionStatus(WizardActionStatus.COMPLETED_OK,
                            "accessRightsWizard.resourceFinish.status.resourceCreated"));
           
            CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.CREATE_ACCESS_RIGHT, accessRights, info, CoreEvent.STATE_SUCCESSFUL)
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_NAME, accessRights.getResourceName())
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_DESCRIPTION, accessRights.getResourceDescription())
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_ACCESS_RIGHT, getAccessRightType(request.getSession(), permissionClass));
           List permissionsList = accessRights.getAccessRights();
            if (permissionsList != null) {
                int j =0;
                for (Iterator i = permissionsList.iterator(); i.hasNext();) {
                    j++;
                    AccessRight permission = (AccessRight)i.next();

                    MessageResources mrPermission = CoreUtil.getMessageResources(request.getSession(), permission.getPermission().getBundle());
                    String permissionName = mrPermission.getMessage("permission."+permission.getPermission().getId()+".title").trim();

                    MessageResources mrResourceType = CoreUtil.getMessageResources(request.getSession(), permission.getResourceType().getBundle());
                    String resourceTypeName = mrResourceType.getMessage("resourceType."+permission.getResourceType().getResourceTypeId()+".title").trim();
                    coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_PERMISSION + Integer.toString(j), permissionName + " " + resourceTypeName);
                }
            }
            CoreServlet.getServlet().fireCoreEvent(coreEvent);
           
        } catch (Exception e) {
            log.error("Failed to create delegation resource.", e);
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, CoreEventConstants.CREATE_ACCESS_RIGHT, accessRights, info, CoreEvent.STATE_UNSUCCESSFUL)
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_NAME, accessRights.getResourceName())
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_DESCRIPTION, accessRights.getResourceDescription())
                                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_ACCESS_RIGHT, getAccessRightType(request.getSession(), permissionClass)));
            actionStatus.add(new WizardActionStatus(WizardActionStatus.COMPLETED_WITH_ERRORS,
                            "accessRightsWizard.resourceFinish.status.failedToCreateResource", e.getMessage()));
View Full Code Here


        }
        return null;
    }

    private void fireCoreEvent(HttpServletRequest request, int eventID, String ipAddress, String ipPermission, int state) {
        CoreEvent coreEvent = new CoreEvent(this, eventID, null, getSessionInfo(request), state);
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_ADDRESS, ipAddress);
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_IS_AUTHORIZED, ipPermission);
        CoreServlet.getServlet().fireCoreEvent(coreEvent);
    }
View Full Code Here

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

            return new RedirectWithMessages(mapping.findForward("success"), request);
        }
    }

    private void handleException(int eventId, UserAccountForm account, SessionInfo info, Role[] roles, Exception e) {
        CoreEvent coreEvent = new CoreEvent(this, eventId, null, info, e)
            .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);
    }
View Full Code Here

   
    public boolean matches(Object arg) {
        if (!expected.getClass().equals(arg.getClass())) {
            return false;
        }
        CoreEvent foundEvent = (CoreEvent) arg;
        boolean idEqual = expected.getId() == foundEvent.getId();
        boolean stateEqual = expected.getState() == foundEvent.getState();
        return idEqual && stateEqual;
    }
View Full Code Here

            // Force the forward back to /showHome.do so that the intercerpt functions correctly
            return new ActionForward("/showHome.do");
        }
       
    CoreUtil.removePageInterceptListener(request.getSession(), "promptForPrivateKeyPassphrase");           
        CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, CoreEventConstants.LOGON, getSessionInfo(request).getCredentials(), getSessionInfo(request)).addAttribute(
            CoreAttributeConstants.EVENT_ATTR_IP_ADDRESS, request.getRemoteAddr()).addAttribute(
                CoreAttributeConstants.EVENT_ATTR_HOST, request.getRemoteHost()));
       
        return mapping.findForward("success");
    }
View Full Code Here

    }
   
    private void fireCoreEvent(HttpServletRequest request, IpRestrictionForm ipRestrictionForm, int state) {
        IpRestriction restriction = ipRestrictionForm.getRestriction();
        int eventType = ipRestrictionForm.isEditing() ? CoreEventConstants.EDIT_IP_RESTRICTION : CoreEventConstants.CREATE_IP_RESTRICTION;
        CoreEvent coreEvent = new CoreEvent(this, eventType, null, getSessionInfo(request), state);
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_ADDRESS, restriction.getAddress());
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_IS_AUTHORIZED, String.valueOf(restriction.getAllowed()));
        CoreServlet.getServlet().fireCoreEvent(coreEvent);

    }
View Full Code Here

            // Revoke all polices from the user
            PolicyDatabaseFactory.getInstance().revokeAllPoliciesFromPrincipal(role);
           
        udb.deleteRole(rolename);
        CoreServlet.getServlet().fireCoreEvent(
                new CoreEvent(this, CoreEventConstants.GROUP_REMOVED, role, info)
                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, rolename));
        return mapping.findForward("refresh");
      } catch (Exception e) {
        CoreServlet.getServlet().fireCoreEvent(
                new CoreEvent(this, CoreEventConstants.GROUP_REMOVED, role, info, CoreEvent.STATE_UNSUCCESSFUL)
                    .addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID, rolename));
        throw e;
      }
        finally{
            // we need to reset the menu items as they could have changed here.
View Full Code Here

      }
      else {
                PublicKeyStore.getInstance().removeCachedKeys(user.getPrincipalName());
      }

      CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this,
              CoreEventConstants.CHANGE_PASSWORD,
              null,
              info,
              CoreEvent.STATE_SUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID,
        user.getPrincipalName()));
      return mapping.findForward("success");
    } catch (PasswordPolicyViolationException e) {
      saveError(request, "setPassword.error.doesNotMatchPolicy");
      return mapping.findForward("display");
    } catch (Exception e) {
      CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this,
              CoreEventConstants.CHANGE_PASSWORD,
              null,
              info,
              CoreEvent.STATE_UNSUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_PRINCIPAL_ID,
        user.getPrincipalName()));
View Full Code Here

    public void createResource() throws DuplicateResourceNameException {
        Resource resource = getDefaultResource();

        expect(resourceDatabase.isResourceNameInUse(resource.getResourceName(), 1)).andReturn(false);
        expect(resourceDatabase.insertResource(resource)).andReturn(1);
        CoreEvent changeEvent = getChangeEvent(resourceService.getCreateEventId(), CoreEvent.STATE_SUCCESSFUL);
        coreEventService.fireCoreEvent(eqCoreEvent(changeEvent));
        expect(resourceDatabase.getResourceById(1)).andReturn(resource);
        mocksControl.replay();

        resourceService.createResource(resource, null);
View Full Code Here

TOP

Related Classes of com.adito.core.CoreEvent

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.