InlineSecuredHelper implements Helper<Object> { protected static Permission getPermission(Object context, Options options) { Permission permission; if (context instanceof String) { String resourceURI = context.toString(); String action = options.param(0).toString(); permission = new Permission(resourceURI, action); } else { permission = Permission.ANY_PERMISSION; } return permission; }  @Override CharSequence apply(Object context, Options options); static final String HELPER_NAME; }
@Test public void testWithoutPermission() { String templateContent = "foo\nbar\n{{secured}}bla bla\nfoobar"; Permission permission = createHbsPagePreprocessor(templateContent).getPermission(); Assert.assertEquals(permission, Permission.ANY_PERMISSION); }
@Test public void testWithPermission() { String templateContent = "{{secured \"resourceUri\" \"action\"}}"; Permission permission = createHbsPagePreprocessor(templateContent).getPermission(); Assert.assertEquals(permission, new Permission("resourceUri", "action")); }