Search in sources :

Example 11 with GroupPrincipal

use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.

the class JcrUserProviderTest method testUserGetGroupPrincipals.

@Test(dependsOnMethods = "testAddUsersMembers")
public void testUserGetGroupPrincipals() {
    metadata.read(() -> {
        User user1 = this.provider.findUserBySystemName("user1").get();
        User user2 = this.provider.findUserBySystemName("user2").get();
        User user3 = this.provider.findUserBySystemName("user3").get();
        assertThat(user1.getAllGroupPrincipals()).hasSize(1).contains(new GroupPrincipal("groupA"));
        assertThat(user2.getAllGroupPrincipals()).hasSize(2).contains(new GroupPrincipal("groupA"), new GroupPrincipal("groupB"));
        assertThat(user3.getAllGroupPrincipals()).hasSize(3).contains(new GroupPrincipal("groupA"), new GroupPrincipal("groupC"), new GroupPrincipal("groupD"));
    });
}
Also used : User(com.thinkbiganalytics.metadata.api.user.User) GroupPrincipal(com.thinkbiganalytics.security.GroupPrincipal) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with GroupPrincipal

use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.

the class ActiveDirectoryLoginModuleTest method testLoginAdmin.

// @Test
public void testLoginAdmin() throws Exception {
    Subject subject = login("dladmin", "Th1nkb1g!");
    assertThat(subject.getPrincipals()).contains(new UsernamePrincipal("dladmin"), new GroupPrincipal("Admin"));
}
Also used : UsernamePrincipal(com.thinkbiganalytics.security.UsernamePrincipal) GroupPrincipal(com.thinkbiganalytics.security.GroupPrincipal) Subject(javax.security.auth.Subject)

Example 13 with GroupPrincipal

use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.

the class LdapLoginModuleTest method testLoginAdmin.

@Test
public void testLoginAdmin() throws Exception {
    Subject subject = login("dladmin", "thinkbig");
    assertThat(subject.getPrincipals()).hasSize(2).contains(new UsernamePrincipal("dladmin"), new GroupPrincipal("admin"));
}
Also used : UsernamePrincipal(com.thinkbiganalytics.security.UsernamePrincipal) GroupPrincipal(com.thinkbiganalytics.security.GroupPrincipal) Subject(javax.security.auth.Subject) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with GroupPrincipal

use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.

the class UserMetadataService method deleteGroup.

@Override
public boolean deleteGroup(@Nonnull final String groupId) {
    Optional<GroupPrincipal> principal = metadataAccess.commit(() -> {
        accessController.checkPermission(AccessController.SERVICES, UsersGroupsAccessContol.ADMIN_GROUPS);
        return userProvider.findGroupByName(groupId).map(group -> {
            GroupPrincipal princ = group.getPrincipal();
            userProvider.deleteGroup(group);
            return princ;
        });
    });
    // privileged service principal to allow access control changes on all service actions.
    if (principal.isPresent()) {
        return metadataAccess.commit(() -> {
            actionsProvider.getAllowedActions(AllowedActions.SERVICES).ifPresent(allowed -> allowed.disableAll(principal.get()));
            return true;
        }, MetadataAccess.SERVICE);
    } else {
        return false;
    }
}
Also used : GroupPrincipal(com.thinkbiganalytics.security.GroupPrincipal)

Aggregations

GroupPrincipal (com.thinkbiganalytics.security.GroupPrincipal)14 UsernamePrincipal (com.thinkbiganalytics.security.UsernamePrincipal)10 Subject (javax.security.auth.Subject)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Test (org.testng.annotations.Test)3 UserGroup (com.thinkbiganalytics.metadata.api.user.UserGroup)2 Principal (java.security.Principal)2 Group (java.security.acl.Group)2 Test (org.junit.Test)2 JwtProperties (com.thinkbiganalytics.auth.config.JwtProperties)1 AbstractDataSourceCredentialProvider (com.thinkbiganalytics.kylo.catalog.credential.spi.AbstractDataSourceCredentialProvider)1 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)1 User (com.thinkbiganalytics.metadata.api.user.User)1 BaseFeed (com.thinkbiganalytics.metadata.core.feed.BaseFeed)1 JpaFeedOpsAclEntry (com.thinkbiganalytics.metadata.jpa.feed.security.JpaFeedOpsAclEntry)1 WithMockJaasUser (com.thinkbiganalytics.test.security.WithMockJaasUser)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1