Search in sources :

Example 11 with UserGroup

use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.

the class CreateDefaultUsersGroupsAction method createDefaultGroup.

protected UserGroup createDefaultGroup(String groupName, String title) {
    UserGroup newGroup = userProvider.ensureGroup(groupName);
    newGroup.setTitle(title);
    return newGroup;
}
Also used : UserGroup(com.thinkbiganalytics.metadata.api.user.UserGroup)

Example 12 with UserGroup

use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.

the class CreateDefaultUsersGroupsAction method upgradeTo.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.metadata.upgrade.UpgradeState#upgradeFrom(com.thinkbiganalytics.metadata.api.app.KyloVersion)
     */
@Override
public void upgradeTo(KyloVersion startingVersion) {
    log.info("Creating default users/groups for version: " + startingVersion);
    User dladmin = createDefaultUser("dladmin", "Data Lake Administrator", null);
    User analyst = createDefaultUser("analyst", "Analyst", null);
    User designer = createDefaultUser("designer", "Designer", null);
    User operator = createDefaultUser("operator", "Operator", null);
    // Create default groups if they don't exist.
    UserGroup adminsGroup = createDefaultGroup("admin", "Administrators");
    UserGroup opsGroup = createDefaultGroup("operations", "Operations");
    UserGroup designersGroup = createDefaultGroup("designers", "Designers");
    UserGroup analystsGroup = createDefaultGroup("analysts", "Analysts");
    UserGroup usersGroup = createDefaultGroup("user", "Users");
    // Add default users to their respective groups
    adminsGroup.addUser(dladmin);
    designersGroup.addUser(designer);
    analystsGroup.addUser(analyst);
    opsGroup.addUser(operator);
    usersGroup.addUser(dladmin);
    usersGroup.addUser(analyst);
    usersGroup.addUser(designer);
    usersGroup.addUser(operator);
    // Setup initial group access control.  Administrators group already has all rights.
    actionsProvider.getAllowedActions(AllowedActions.SERVICES).ifPresent((allowed) -> {
        allowed.enable(opsGroup.getRootPrincial(), OperationsAccessControl.ADMIN_OPS, FeedServicesAccessControl.ACCESS_CATEGORIES, FeedServicesAccessControl.ACCESS_FEEDS, FeedServicesAccessControl.ACCESS_TEMPLATES, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS);
        allowed.enable(designersGroup.getRootPrincial(), OperationsAccessControl.ACCESS_OPS, FeedServicesAccessControl.EDIT_FEEDS, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.IMPORT_FEEDS, FeedServicesAccessControl.EXPORT_FEEDS, FeedServicesAccessControl.EDIT_CATEGORIES, FeedServicesAccessControl.EDIT_DATASOURCES, FeedServicesAccessControl.EDIT_TEMPLATES, FeedServicesAccessControl.IMPORT_TEMPLATES, FeedServicesAccessControl.EXPORT_TEMPLATES, FeedServicesAccessControl.ADMIN_TEMPLATES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.ACCESS_GLOBAL_SEARCH);
        allowed.enable(analystsGroup.getRootPrincial(), OperationsAccessControl.ACCESS_OPS, FeedServicesAccessControl.EDIT_FEEDS, FeedServicesAccessControl.ACCESS_TABLES, FeedServicesAccessControl.IMPORT_FEEDS, FeedServicesAccessControl.EXPORT_FEEDS, FeedServicesAccessControl.EDIT_CATEGORIES, FeedServicesAccessControl.ACCESS_TEMPLATES, FeedServicesAccessControl.ACCESS_DATASOURCES, FeedServicesAccessControl.ACCESS_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS, FeedServicesAccessControl.ACCESS_GLOBAL_SEARCH);
    });
    try {
        Workspace workspace = (Workspace) JcrMetadataAccess.getActiveSession().getWorkspace();
        workspace.reindex("/users");
        workspace.reindex("/groups");
    } catch (RepositoryException e) {
        log.error("Failed to re-index metadata", e);
        throw new UpgradeException("Failed to re-index metadata", e);
    }
}
Also used : UpgradeException(com.thinkbiganalytics.server.upgrade.UpgradeException) User(com.thinkbiganalytics.metadata.api.user.User) RepositoryException(javax.jcr.RepositoryException) UserGroup(com.thinkbiganalytics.metadata.api.user.UserGroup) Workspace(org.modeshape.jcr.api.Workspace)

Example 13 with UserGroup

use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.

the class GroupNamesUpgradeAction method createDefaultGroup.

protected UserGroup createDefaultGroup(String groupName, String title) {
    UserGroup newGroup = userProvider.ensureGroup(groupName);
    newGroup.setTitle(title);
    return newGroup;
}
Also used : UserGroup(com.thinkbiganalytics.metadata.api.user.UserGroup)

Aggregations

UserGroup (com.thinkbiganalytics.metadata.api.user.UserGroup)13 Test (org.testng.annotations.Test)8 User (com.thinkbiganalytics.metadata.api.user.User)5 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)3 UserProvider (com.thinkbiganalytics.metadata.api.user.UserProvider)3 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)3 JcrTestConfig (com.thinkbiganalytics.metadata.modeshape.JcrTestConfig)3 ModeShapeEngineConfig (com.thinkbiganalytics.metadata.modeshape.ModeShapeEngineConfig)3 GroupPrincipal (com.thinkbiganalytics.security.GroupPrincipal)3 UsernamePrincipal (com.thinkbiganalytics.security.UsernamePrincipal)3 List (java.util.List)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 StreamSupport (java.util.stream.StreamSupport)3 Inject (javax.inject.Inject)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 SpringApplicationConfiguration (org.springframework.boot.test.SpringApplicationConfiguration)3 AbstractTestNGSpringContextTests (org.springframework.test.context.testng.AbstractTestNGSpringContextTests)3 UpgradeException (com.thinkbiganalytics.server.upgrade.UpgradeException)1 RepositoryException (javax.jcr.RepositoryException)1