Examples of Authority


Examples of org.beangle.ems.security.Authority

      }
    }
    group.getAuthorities().removeAll(removed);

    for (Resource resource : resources) {
      Authority authority = Model.newInstance(Authority.class);
      authority.setGroup(group);
      authority.setResource(resource);
      group.getAuthorities().add(authority);
    }
    entityDao.remove(removed);
    entityDao.saveOrUpdate(group);
    publish(new GroupAuthorityEvent(group));
View Full Code Here

Examples of org.beangle.security.blueprint.Authority

    }
    String forEdit = Params.get("forEdit");
    if (StringUtils.isNotEmpty(forEdit)) {
      List<RestrictObject> restrictObjects = CollectUtils.newArrayList();
      if (holder instanceof Authority) {
        Authority au = (Authority) holder;
        restrictObjects.addAll(au.getResource().getObjects());
      } else {
        restrictObjects = entityDao.getAll(RestrictObject.class);
      }
      ContextHelper.put("restrictObjects", restrictObjects);
    }
View Full Code Here

Examples of org.internna.ossmoney.model.security.Authority

    createUser(username, password, name, email, createDashBoDashboard());
    logger.info("Registered new user[" + username + "]");
  }

  protected UserDetails createUser(String username, String password, String name, String email, Dashboard dashboard) {
    Authority authority = Authority.findByName(Authority.ROLE_USER);
    UserDetails user = new UserDetails();
    user.setSalt(salt);
    user.setName(name);
    user.setEmail(email);
    user.setUsername(username);
    user.setPassword(password);
    user.setDashboard(dashboard);
    user.setEnabled(Boolean.TRUE);
    user.getRoles().add(authority);
    authority.getUsers().add(user);
    user.persist();
    adminService.createPayee(user, user.getName());
    createSubcategories(user);
    user.setBudget(createBudget(user));
    if (createBasicSpanishFinancialInstitutions) {
      createBasicSpanishInstitutions(user);
    }
    authority.merge();
    user.merge();
    return user;
  }
View Full Code Here

Examples of org.nightlabs.jfire.security.Authority

    if (!JbpmConstantsRecurringOffer.Vendor.NODE_NAME_RECURRENCE_STARTED.equals(nodeName))
    {
      recurringOffer.getRecurringOfferConfiguration().getCreatorTask().setEnabled(false);
      return null;
    }
    Authority organisationAuthority = Authority.getOrganisationAuthority(getPersistenceManager());
    // userID references the principal, i.e. the currently logged-in user.
    UserID userID = SecurityReflector.getUserDescriptor().getUserObjectID();

    // TODO set problem key instead of assert (which throws an exception and thus rolls the whole transaction back).
    organisationAuthority.assertContainsRoleRef(userID, org.nightlabs.jfire.trade.RoleConstants.editOrder);
    organisationAuthority.assertContainsRoleRef(userID, org.nightlabs.jfire.trade.RoleConstants.editOffer);

    if (!JbpmConstantsRecurringOffer.Vendor.NODE_NAME_RECURRENCE_STARTED.equals(nodeName)) {
      throw new IllegalStateException("The recurrence for RecurringOffer " + JDOHelper.getObjectId(recurringOffer) + " is not started, it is in the state '" + nodeName + "'.");
    }
    logger.debug("Starting creation of RecurredOffer (with new Order) for RecurringOffer: " + JDOHelper.getObjectId(recurringOffer));
    PersistenceManager pm = getPersistenceManager();
    Trader trader = Trader.getTrader(pm);

    Order order = trader.createOrder(recurringOffer.getVendor(),
        recurringOffer.getCustomer(), null, recurringOffer.getCurrency());
    logger.debug("Created Order: " + JDOHelper.getObjectId(order));

    User user = SecurityReflector.getUserDescriptor().getUser(pm);

    String offerIDPrefix = recurringOffer.getOfferIDPrefix();

    Collection<Segment> recurringSegments = new HashSet<Segment>();
    for (Article article : recurringOffer.getArticles()) {
      recurringSegments.add(article.getSegment());
    }

    // create the new segment for the order
    for (Segment segment : recurringSegments) {
      trader.createSegment(order, segment.getSegmentType());
    }

    RecurredOffer recurredOffer = createRecurredOffer(recurringOffer,user, order, offerIDPrefix);

    logger.debug("Created RecurredOffer: " + JDOHelper.getObjectId(recurredOffer));

    // Loop over all articles in the given offer and group
    // them by SegmentType and ProductType-class
    Map<SegmentType, Map<Class<? extends ProductType>, Set<Article>>> segmentTypes2PTClass2Articles =  new HashMap<SegmentType, Map<Class<? extends ProductType>, Set<Article>>>();
    Set<Article> articles = new HashSet<Article>();

    for (Article recurringArticle : recurringOffer.getArticles()) {
      SegmentType segmentType = recurringArticle.getSegment().getSegmentType();
      Map<Class<? extends ProductType>, Set<Article>> ptClass2Articles = segmentTypes2PTClass2Articles.get(segmentType);
      if (ptClass2Articles == null) {
        ptClass2Articles = new HashMap<Class<? extends ProductType>, Set<Article>>();
        segmentTypes2PTClass2Articles.put(segmentType, ptClass2Articles);
      }
      Class<? extends ProductType> productTypeClass = recurringArticle.getProductType().getClass();
      articles = ptClass2Articles.get(productTypeClass);
      if (articles == null) {
        articles = new HashSet<Article>();
        ptClass2Articles.put(productTypeClass, articles);
      }
      articles.add(recurringArticle);
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Grouped articles in RecurringOffer:");
      for (Map.Entry<SegmentType, Map<Class<? extends ProductType>, Set<Article>>> segmentTypeEntry : segmentTypes2PTClass2Articles.entrySet()) {
        logger.debug("  SegmentType: " + JDOHelper.getObjectId(segmentTypeEntry.getKey()));
        for (Map.Entry<Class<? extends ProductType>, Set<Article>> productTypeEntry : segmentTypeEntry.getValue().entrySet()) {
          logger.debug("    ProductType class: " + productTypeEntry.getKey());
          for (Article article : productTypeEntry.getValue()) {
            logger.debug("      Article: " + JDOHelper.getObjectId(article));
          }
        }
      }
    }

    // loop over the segments added to the order
    for (Segment segment : order.getSegments()) {
      logger.debug("Creating articles for RecurredOffer for SegmentType " + JDOHelper.getObjectId(segment.getSegmentType()));
      Map<Class<? extends ProductType>, Set<Article>> collected = segmentTypes2PTClass2Articles.get(segment.getSegmentType());
      if (collected != null) { // it is possible that there are segments with no articles in the RecurringOffer
        // add each segment to the RecurredOffer
        recurredOffer.addSegment(segment);
        for (Iterator< Class<? extends ProductType>> it = collected.keySet().iterator(); it.hasNext();)
        {
          // now for each ProductType class find the handler and let him create the articles
          Class<? extends ProductType> pt = it.next();
          logger.debug("  Creating articles for RecurredOffer for ProductType class " + pt);

          articles = collected.get(pt);

          RecurringTradeProductTypeActionHandler handler = RecurringTradeProductTypeActionHandler.getRecurringTradeProductTypeActionHandler(pm, pt);
          if (handler == null)
            throw new IllegalStateException("Could not find a " + RecurringTradeProductTypeActionHandler.class.getName() +
                " for the ProductType class " + pt);
          logger.debug("  Found handler " + handler.getClass().getName() + " ProductType class " + pt);

          Map<Article, Article> recurredArticles = handler.createArticles(recurredOffer, articles, segment);

          if(recurredArticles.size() != articles.size())
            throw new IllegalStateException(
                "RecurringTradeProductTypeActionHandler " + handler.getClass().getName() +
                " created " + recurredArticles.size() + " recurred articles for " + articles.size() +
                " template/recurring articles");

          for (Map.Entry<Article, Article> articleEntry : recurredArticles.entrySet()) {
            //  Compare Prices to check if they the Differ
            Price recurringPrice = articleEntry.getValue().getPrice();
            Price recurredPrice = articleEntry.getKey().getPrice();
            // if amount or currency differs
            if (recurredPrice.getAmount() != recurringPrice.getAmount() || !recurredPrice.getCurrency().equals(recurringPrice.getCurrency()))
              priceDiffer = true;

            if (logger.isDebugEnabled()) {
              if (!articleEntry.getValue().isAllocated()) {
                logger.debug("    An Article was created which was NOT allocated: " + JDOHelper.getObjectId(articleEntry.getValue()));
              } else {
                logger.debug("    An allocated Article was created: " + JDOHelper.getObjectId(articleEntry.getValue()));
              }

              logger.debug("  Finished creatingArticles");
            }

          }
        }
      }
    }
    // TODO: Check/Compare article prices from RecurringOffer and crated RecurredOffer
    /* Depending on the configuration of the RecurringOffer the following strageties should be supported:
     * * Always use offered prices (Meaning that the process will enforce the
     *   old prices for the newly created RecurredOffer)
     * * Use offered prices but don't finalize (Meaning that the old prices will
     *   be used, but the new offer will not be finalized, it would be best if this
     *   could somehow notify the user then, but this for later)
     * * Use current prices (Meaning that the process will always take the
     *   current prices for the new offers, this is what currently happens)
     * * Use current prices but don't finalize (Meaning that the new prices will
     *   be used, but the new offer will not be finalized)
     *   How to enforce old prices is not absolutely clear to me now, but I know
     *   that it's possible somehow
     *
     * Alex
     */
    // finished creating articles

    if(!priceDiffer)
    {
      // For now, as long as the different strategies are not present, we directly accept the offer.
      trader.acceptOfferImplicitely(recurredOffer);

      if(recurringOffer.getRecurringOfferConfiguration().isCreateInvoice()) {
        // If the configuration says so, automatically create an invoice
        logger.debug("Creating invoice for new RecurredOffer");

        // TODO set problem key instead of assert (which throws an exception and thus rolls the whole transaction back).
        organisationAuthority.assertContainsRoleRef(userID, org.nightlabs.jfire.accounting.RoleConstants.editInvoice);

        Accounting accounting = Accounting.getAccounting(pm);
        Invoice invoice = accounting.createInvoice(user, recurredOffer.getArticles(), null);

        logger.debug("Successfully created Invoice " + JDOHelper.getObjectId(invoice));
View Full Code Here

Examples of org.openxri.store.Authority

      final Store openXRIStore = ((OpenXRIAdminApplication) this.getApplication()).getOpenXRIStore();

      // find the authority

      Authority authority;

      try {

        XRI xri = new XRI(this.xri);
        XRIAuthority xriAuthority = ((XRIAuthority) xri.getAuthorityPath());
View Full Code Here

Examples of org.openxri.store.Authority

      try {

        SubSegment rootSubSegment = openXRIStore.createRootSubSegment(this.namespace, new XRD());

        CanonicalID canonicalID;
        Authority authority;

        try {

          authority = openXRIStore.getSubSegmentAuthority(rootSubSegment);

          XRDS xrds = resolver.resolveAuthority(new XRI(this.namespace), new ResolverFlags(), new ResolverState());
          XRD xrd = (xrds != null) ? xrds.getFinalXRD() : null;
          canonicalID = (xrd != null) ? xrd.getCanonicalID() : null;
        } catch (Exception ex) {

          log.warn("Cannot find corresponding i-number");
          canonicalID = null;
          authority = null;
        }

        if (canonicalID != null && authority != null && ! canonicalID.getValue().equals(this.namespace)) {

          XRD xrd = authority.getXrd();
          xrd.setCanonicalID(new CanonicalID(canonicalID.getValue()));

          ((StoreEditable) openXRIStore).setXrd(authority, xrd);
          openXRIStore.registerSubsegment(null, canonicalID.getValue(), authority);
        }
View Full Code Here

Examples of org.openxri.store.Authority

    try {

      if (store instanceof StoreResettable) ((StoreResettable) store).resetStore();

      SubSegment rootSubSegment1 = store.createRootSubSegment("=example", new XRD());
      Authority rootAuthority1 = store.getSubSegmentAuthority(rootSubSegment1);
      SubSegment subSegment1 = store.registerSubsegment(rootAuthority1, "*name1", makeSampleXRD());
      SubSegment subSegment2 = store.registerSubsegment(rootAuthority1, "*name2", makeSampleXRD());

      SubSegment rootSubSegment2 = store.createRootSubSegment("@example", new XRD());
      Authority rootAuthority2 = store.getSubSegmentAuthority(rootSubSegment2);
      SubSegment subSegment3 = store.registerSubsegment(rootAuthority2, "*name3", makeSampleXRD());
      Authority authority3 = store.getSubSegmentAuthority(subSegment3);
      SubSegment subSegment4 = store.registerSubsegment(authority3, "*name4", makeSampleXRD());

    } catch (StoreException ex) {

      ex.printStackTrace();
View Full Code Here

Examples of org.openxri.store.Authority

  {
    if (soLog.isDebugEnabled()) soLog.debug("lookupById(" + authorityId + "," + segment.toString() + ")");

    // find the authority object for this id

    Authority parent;
    try {

      parent = moStore.findAuthority(authorityId);
    } catch (StoreNotFoundException ex) {
View Full Code Here

Examples of org.openxri.store.Authority

  {
    if (soLog.isDebugEnabled()) soLog.debug("lookupByNamespace(" + namespace + "," + segment.toString() + ")");

    // find the authority object for this namespace

    Authority parent;

    try {

      parent = moStore.findRootAuthority(namespace);
    } catch (StoreNotFoundException ex) {
View Full Code Here

Examples of org.openxri.store.Authority

          ServerNotFoundException ex2 = new ServerNotFoundException("Cannot find subsegment: " + subSegmentName, ex);
          soLog.warn(ex2);
          throw ex2;
        }

        Authority authority = moStore.getSubSegmentAuthority(subSegment);

        // look up Refs and Services from the store, as well as LocalIDs if the store supports it

        Ref[] refs = moStore.getAuthorityRefs(authority);
        Service[] services = moStore.getAuthorityServices(authority);
        LocalID[] localIds;

        if (moStore instanceof StoreBetterLookup) {

          localIds = ((StoreBetterLookup) moStore).getSubSegmentLocalIds(subSegment);
        } else {

          localIds = new LocalID[0];
        }

        // fill it with information we got from the store

        for (int ii=0; ii<refs.length; ii++) xrd.addRef(refs[ii]);
        for (int ii=0; ii<services.length; ii++) xrd.addService(services[ii]);
        for (int ii=0; ii<localIds.length; ii++) xrd.addLocalID(localIds[ii]);

        // do we want a local authority resolution service for this authority?
        // this piece of information comes from the store, but we actually create
        // the service, since this requires knowledge of the server configuration

        if (authority.getLocalAuthService().equals(Boolean.TRUE)) {

          URI[] uris;

          try {

            uris = new URI[2];
            uris[0] = fillURI(authority.getAuthorityId(), "http");
            uris[1] = fillURI(authority.getAuthorityId(), "https");
          } catch(URISyntaxException ex) {

            throw new ServerInternalException("Invalid URI for authority resolution service.", ex);
          }

          xrd.addService(new AuthorityResolutionService(uris, authority.getAuthorityId()));
        }

        // let our subclasses finish the XRD before we append it to the XRDS

        this.finishXRD(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.