Package com.getperka.flatpack

Examples of com.getperka.flatpack.FlatPack


   */
  @GET
  @Path("describe")
  @FlatPackResponse(ApiDescription.class)
  public ApiDescription describeGet() throws IOException {
    FlatPack flatpack = providers.getContextResolver(FlatPack.class, MediaType.WILDCARD_TYPE)
        .getContext(FlatPack.class);
    ApiDescriber api = new ApiDescriber(flatpack, Arrays.asList(DemoResource.class.getMethods()));
    ApiDescription description = api.describe();
    description.setApiName("Demo");
    return description;
View Full Code Here


    doTest(contents, Merchant.class);
    doTest(contents, ExtendsMerchant.class);
  }

  void doTest(String contents, Class<? extends Merchant> clazz) {
    FlatPack fp = flatpack(contents);
    GroupPermissions p = fp.getTypeContext().describe(clazz).getGroupPermissions();
    assertNotNull(p);

    // Check various type-level permissions
    checkMerchantPermissions(p);

    // Check property-level permissions, especially type- and global-overrides
    Property name = getProperty(fp.getTypeContext(), clazz, "name");
    p = name.getGroupPermissions();
    assertNotNull(p);
    // Just replacing a previous declaration
    assertEquals(5, p.getOperations().size());
    checkPermissions(p, "*", "crudOperation.read");

    // Test the "allow only" construct
    Property note = getProperty(fp.getTypeContext(), clazz, "note");
    p = note.getGroupPermissions();
    assertNotNull(p);
    assertEquals(1, p.getOperations().size());
    checkPermissions(p, "internalUser", "*.*");

    // Verify that unreferenced properties inherit the type's allow
    Property other = getProperty(fp.getTypeContext(), clazz, "other");
    p = other.getGroupPermissions();
    assertNotNull(p);
    checkMerchantPermissions(p);
  }
View Full Code Here

public class PolicyTestBase {

  protected FlatPack flatpack(String policyContents) {
    StaticPolicy securityPolicy = new StaticPolicy(policyContents);
    FlatPack flatpack = FlatPack.create(
        new Configuration()
            .addTypeSource(new TypeSource() {
              @Override
              public Set<Class<?>> getTypes() {
                Set<Class<?>> toReturn = setForIteration();
View Full Code Here

   */
  @Test
  public void test() throws Exception {
    Method method = ApiDescriberTest.class.getDeclaredMethod("sampleMethod");

    FlatPack flatpack = FlatPack.create(new Configuration()
        .addTypeSource(new SearchTypeSource("com.getperka.flatpack")));
    ApiDescription description = new ApiDescriber(flatpack, Collections.singletonList(method))
        .describe();

    EntityDescription toCheck = null;
View Full Code Here

  @Before
  public void before() {
    String policy = loadTestPolicyContents("PrincipalSecurityTest.policy");
    assertNotNull(policy);
    FlatPack flatpack = FlatPack.create(new Configuration()
        .addTypeSource(new TypeSource() {
          @Override
          public Set<Class<?>> getTypes() {
            return Collections.<Class<?>> singleton(Person.class);
          }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.FlatPack

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.