use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class JpaFeedProviderTest method testFindFeedUsingGenericFilter.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testFindFeedUsingGenericFilter() {
// Create feed
final String name = "testCategory.testFeed";
final String id = metadataAccess.commit(() -> {
final OpsManagerFeed.ID feedId = feedProvider.resolveId(UUID.randomUUID().toString());
feedProvider.save(feedId, name, false, 1000L);
return feedId.toString();
});
// Add ACL entries
final BaseFeed.FeedId feedId = new BaseFeed.FeedId(id);
final JpaFeedOpsAclEntry userAcl = new JpaFeedOpsAclEntry(feedId, "dladmin", JpaFeedOpsAclEntry.PrincipalType.USER);
final JpaFeedOpsAclEntry adminAcl = new JpaFeedOpsAclEntry(feedId, "admin", JpaFeedOpsAclEntry.PrincipalType.GROUP);
aclProvider.grantAccess(feedId, new UsernamePrincipal("dladmin"), new GroupPrincipal("admin"));
// Verify access to feeds
metadataAccess.read(() -> {
List<OpsManagerFeed> feeds = feedProvider.findAll("name:" + name);
Assert.assertTrue(feeds != null && !feeds.isEmpty());
List<String> feedNames = feedProvider.getFeedNames();
Assert.assertTrue(feedNames != null && !feedNames.isEmpty());
return feeds;
});
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class Main method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(VaultDataSourceCredentialConfig.class);
context.start();
SecretStore ss = context.getBean(SecretStore.class);
System.out.println("ss.contains(\"oracle\")= " + ss.contains("oracle"));
ss.remove("oracle");
System.out.println("removed path 'oracle'");
System.out.println("ss.contains(\"oracle\")= " + ss.contains("oracle"));
AbstractDataSourceCredentialProvider.Credentials creds = new AbstractDataSourceCredentialProvider.Credentials();
creds.addUserCredential("dladmin", "user", "user-dladmin", true, true);
creds.addUserCredential("dladmin", "password", "pass-dladmin", true, true);
creds.addGroupCredential("admin", "user", "user-admins", true, true);
creds.addGroupCredential("admin", "password", "pass-admins", true, true);
creds.addGroupCredential("analysts", "user", "user-analysts", true, true);
creds.addGroupCredential("analysts", "password", "pass-analysts", true, true);
creds.addDefaultCredential("user", "root", true, true);
creds.addDefaultCredential("password", "thinkbig", true, true);
ss.write("oracle", creds);
System.out.println("ss.contains(\"oracle\")= " + ss.contains("oracle"));
Set<Principal> principals = new HashSet<>();
principals.add(new GroupPrincipal("analysts"));
principals.add(new GroupPrincipal("admin"));
// principals.add(new UsernamePrincipal("dladmin"));
AbstractDataSourceCredentialProvider.Credentials read = ss.read("oracle", principals);
System.out.println(read);
context.stop();
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class JwtRememberMeServicesTest method processAutoLoginCookie.
/**
* Verify building a user from tokens.
*/
@Test
public void processAutoLoginCookie() throws Exception {
final UserDetails user = service.processAutoLoginCookie(new String[] { "dladmin", groupPrincipalsJson("admin") }, Mockito.mock(HttpServletRequest.class), Mockito.mock(HttpServletResponse.class));
Assert.assertEquals("dladmin", user.getUsername());
Principal group = user.getAuthorities().stream().findAny().map(JaasGrantedAuthority.class::cast).map(ja -> ja.getPrincipal()).orElseThrow(() -> new AssertionError("No group principal found"));
Assert.assertEquals(new GroupPrincipal("admin"), group);
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class ActiveDirectoryLoginModuleTest method testLoginTest.
// @Test
public void testLoginTest() throws Exception {
Subject subject = login("test", "Th1nkb1g!");
assertThat(subject.getPrincipals()).hasSize(3).contains(new UsernamePrincipal("test"), new GroupPrincipal("Admin"), new GroupPrincipal("Developer"));
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class LdapLoginModuleTest method testLoginTest.
@Test
public void testLoginTest() throws Exception {
Subject subject = login("test", "user");
assertThat(subject.getPrincipals()).hasSize(3).contains(new UsernamePrincipal("test"), new GroupPrincipal("admin"), new GroupPrincipal("developer"));
}
Aggregations