Package org.candlepin.common.exceptions

Examples of org.candlepin.common.exceptions.ForbiddenException


        ghost.setId("ghost-pool");
        key1.addPool(ghost, 10L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(ghost.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here


        pool3.setId("pool3");
        key1.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

        pool3.setId("pool3");
        key2.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

        String pool = "pool10";
        JobDetail detail = EntitlerJob.bindByPool(pool, consumerUuid, 1);
        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
        when(e.bindByPool(eq(pool), eq(consumerUuid), eq(1))).thenThrow(
            new ForbiddenException("job should fail"));

        EntitlerJob job = new EntitlerJob(e, null);
        job.execute(ctx);
    }
View Full Code Here

                throw new BadRequestException(
                    "Consumer specified does not belong to owner on path");
            }

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

        ActivationKey key = null;
View Full Code Here

    protected void denyAccess(Principal principal, Method method) {
        log.warn("Refusing principal: {} access to: {} ", principal,
                    method.getName());

        String error = "Insufficient permissions";
        throw new ForbiddenException(i18n.tr(error));
    }
View Full Code Here

        // Throws exception if criteria block the id
        Parent result = this.findParentById(parentId);
        // Now that we know it exists, verify access level
        if (!principal.canAccess(result, SubResource.NONE, access)) {
            String error = "Insufficient permissions";
            throw new ForbiddenException(i18n.tr(error));
        }
        return result;
    }
View Full Code Here

            log.debug("Created entitlement: " + e);
            return e;
        }
        catch (EntitlementRefusedException e) {
            // TODO: Could be multiple errors, but we'll just report the first one for now
            throw new ForbiddenException(messageTranslator.poolErrorToMessage(pool,
                    e.getResult().getErrors().get(0)));
        }
    }
View Full Code Here

        try {
            poolManager.adjustEntitlementQuantity(consumer, ent, quantity);
        }
        catch (EntitlementRefusedException e) {
            // TODO: Could be multiple errors, but we'll just report the first one for now:
            throw new ForbiddenException(messageTranslator.entitlementErrorToMessage(ent,
                    e.getResult().getErrors().get(0)));
        }
    }
View Full Code Here

            // TODO: Could be multiple errors, but we'll just report the first one for now
            String productId = "Unknown Product";
            if (data.getProductIds().length > 0) {
                productId = data.getProductIds()[0];
            }
            throw new ForbiddenException(messageTranslator.productErrorToMessage(productId,
                    e.getResult().getErrors().get(0)));
        }
    }
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.