use of org.ff4j.web.ApiConfigBuilder in project ff4j by ff4j.
the class ApiConfigTest method testApiConfig.
@Test
public void testApiConfig() {
ApiConfig apc1 = new ApiConfig();
apc1.setVersion("1");
apc1.getVersion();
apc1.isAuthenticate();
apc1.isAutorize();
apc1.isDocumentation();
apc1.isLog();
apc1.setFF4j(new FF4j());
apc1.getFF4j();
apc1.setApiKeys(Util.set("1", "2"));
apc1.getApiKeys();
apc1.setAuthenticate(false);
apc1.setAutorize(false);
apc1.setHost("localhost");
apc1.getHost();
apc1.setPort(8080);
apc1.getPort();
apc1.setPermissions(new HashMap<String, Set<String>>());
apc1.getPermissions();
apc1.setLog(false);
apc1.setUsers(new HashMap<String, String>());
apc1.getUsers();
apc1.getWebContext();
apc1.getContextPath();
apc1.createApiKey("key", true, true, Util.set("USER", "ADMIN"));
apc1.createUser("john", "tiger", true, true, Util.set("USER", "ADMIN"));
apc1.setFF4j(new FF4j());
new ApiConfigBuilder(apc1);
}
use of org.ff4j.web.ApiConfigBuilder in project ff4j by ff4j.
the class ApiConfigTest method tesApiConfigBuilder.
@Test
public void tesApiConfigBuilder() {
ApiConfigBuilder b = new ApiConfigBuilder();
b.addApiKey("123").addUser("", "").authenticate(false).documentation(false).host("localhost").port(12).webContext("/ok").withAuthentication().withAutorization().withDocumentation().withoutAuthentication().withoutAutorization().withoutDocumentation();
ApiConfig conf = b.build();
Assert.assertNotNull(conf);
new ApiConfigBuilder(new FF4j());
}
use of org.ff4j.web.ApiConfigBuilder in project ff4j by ff4j.
the class SecuredJersey2Application method getWebApiConfiguration.
/**
* {@inheritDoc}
*/
@Override
public ApiConfig getWebApiConfiguration() {
ApiConfig secured = //
new ApiConfigBuilder(ff4j).withAuthentication().withAutorization().build();
// Create 2 valid apiKeys
secured.createApiKey("123", true, false, Util.set("ROLE_USER", "ROLE_ADMIN"));
secured.createApiKey("456", true, true, Util.set("ROLE_USER", "ROLE_ADMIN"));
secured.createUser("user", "user", true, false, Util.set("ROLE_USER", "ROLE_ADMIN"));
secured.createUser("admin", "admin", true, true, Util.set("ADMINISTRATOR", "USER"));
return secured;
}
Aggregations