Package org.candlepin.common.exceptions

Examples of org.candlepin.common.exceptions.ForbiddenException


        // API:registerConsumer
        Set<String> keyStrings = splitKeys(activationKeys);

        // Only let NoAuth principals through if there are activation keys to consider:
        if ((principal instanceof NoAuthPrincipal) && keyStrings.isEmpty()) {
            throw new ForbiddenException(i18n.tr("Insufficient permissions"));
        }

        if (!keyStrings.isEmpty()) {
            if (ownerKey == null) {
                throw new BadRequestException(i18n.tr(
View Full Code Here


        // When registering person consumers we need to be sure the username
        // has some association with the owner the consumer is destined for:
        if (!principal.canAccess(owner, SubResource.NONE, Access.ALL) &&
            !principal.hasFullAccess()) {
            throw new ForbiddenException(i18n.tr(
                "User ''{0}'' has no roles for organization ''{1}''",
                user.getUsername(), owner.getKey()));
        }

        // TODO: Refactor out type specific checks?
View Full Code Here

        try {
            this.poolManager.revokeAllEntitlements(toDelete);
        }
        catch (ForbiddenException e) {
            String msg = e.message().getDisplayMessage();
            throw new ForbiddenException(i18n.tr(
                "Cannot unregister {0} {1} because: {2}", toDelete
                    .getType().getLabel(), toDelete.getName(), msg), e);

        }
        consumerRules.onConsumerDelete(toDelete);
View Full Code Here

        @QueryParam("api_url") String apiUrl) {

        Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid);
        if (consumer.getType() == null ||
            !consumer.getType().isManifest()) {
            throw new ForbiddenException(
                i18n.tr(
                    "Unit {0} cannot be exported. " +
                    "A manifest cannot be made for units of type ''{1}''.",
                    consumerUuid, consumer.getType().getLabel()));
        }

        if (!StringUtils.isBlank(cdnLabel) &&
            cdnCurator.lookupByLabel(cdnLabel) == null) {
            throw new ForbiddenException(
                i18n.tr("A CDN with label {0} does not exist on this system.", cdnLabel));
        }

        poolManager.regenerateDirtyEntitlements(
            entitlementCurator.listByConsumer(consumer));
View Full Code Here

                    consumerUuid));
            }

            // Now that we have a consumer, check that this principal can access it:
            if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access unit {1}",
                    principal.getPrincipalName(), consumerUuid));
            }

            if (listAll) {
                o = c.getOwner();
            }
        }
        if (ownerId != null) {
            o = ownerCurator.secureFind(ownerId);
            if (o == null) {
                throw new NotFoundException(i18n.tr("owner: {0}", ownerId));
            }
            // Now that we have an owner, check that this principal can access it:
            if (!principal.canAccess(o, SubResource.POOLS, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access owner {1}",
                    principal.getPrincipalName(), o.getKey()));
            }
        }

        // If we have no consumer, and no owner specified, kick 'em out unless they
        // have full system access (this is the same as requesting all pools in
        // the system).
        if (consumerUuid == null && ownerId == null && !principal.hasFullAccess()) {
            throw new ForbiddenException(i18n.tr("User {0} cannot access all pools.",
                    principal.getPrincipalName()));
        }

        Page<List<Pool>> page = poolManager.listAvailableEntitlementPools(c, null, o,
            productId, activeOnDate, true, listAll, new PoolFilterBuilder(), pageRequest);
View Full Code Here

                throw new NotFoundException(i18n.tr("consumer: {0} not found",
                    consumerUuid));
            }

            if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access consumer {1}",
                    principal.getPrincipalName(), c.getUuid()));
            }
        }

        if (toReturn != null) {
View Full Code Here

            if ((principal == null) ||
                    principal.canAccess(guestConsumer, SubResource.NONE, Access.ALL)) {
                consumerResource.deleteConsumer(guestConsumer.getUuid(), principal);
            }
            else {
                throw new ForbiddenException(i18n.tr(
                    "Cannot unregister {0} {1} because: {2}",
                    guestConsumer.getType().getLabel(), guestConsumer.getName(),
                    i18n.tr("Invalid Credentials")));
            }
        }
View Full Code Here

TOP

Related Classes of org.candlepin.common.exceptions.ForbiddenException

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.