use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class ExampleLoginModule method doCommit.
/* (non-Javadoc)
* @see com.thinkbiganalytics.auth.jaas.AbstractLoginModule#doCommit()
*/
@Override
protected boolean doCommit() throws Exception {
// Associate the username and the admin group with the subject.
getSubject().getPrincipals().add(new UsernamePrincipal(this.username));
getSubject().getPrincipals().add(new GroupPrincipal("admin"));
return true;
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class ExampleLoginModule method doAbort.
/* (non-Javadoc)
* @see com.thinkbiganalytics.auth.jaas.AbstractLoginModule#doAbort()
*/
@Override
protected boolean doAbort() throws Exception {
// Since it is possible for login to still be aborted even after this module was told to commit,
// remove the principals we may have added to the subject.
getSubject().getPrincipals().remove(new UsernamePrincipal(this.username));
getSubject().getPrincipals().remove(new GroupPrincipal("admin"));
return true;
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class AclPrincipalTypeUpgradeAction method upgrade.
private void upgrade(JcrAllowedActions allowed, Set<String> groupNames) {
allowed.streamActions().forEach(action -> {
allowed.getPrincipalsAllowedAll(action).stream().filter(this::isUpgradable).forEach(principal -> {
// If the principal name does not match a group name then assume it is a user.
if (groupNames.contains(principal.getName())) {
GroupPrincipal group = new GroupPrincipal(principal.getName());
allowed.enable(group, action);
} else {
UsernamePrincipal newPrincipal = new UsernamePrincipal(principal.getName());
allowed.enable(newPrincipal, action);
}
});
});
allowed.streamActions().forEach(action -> {
allowed.getPrincipalsAllowedAll(action).stream().filter(this::isUpgradable).forEach(principal -> {
// If the principal name does not match a group name then assume it is a user.
if (!(principal instanceof UsernamePrincipal || principal instanceof Group)) {
allowed.disable(new RemovedPrincipal(principal), action);
}
});
});
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class AbstractLoginModule method addNewGroupPrincipal.
protected GroupPrincipal addNewGroupPrincipal(String name) {
GroupPrincipal group = new GroupPrincipal(name);
addPrincipal(group);
return group;
}
use of com.thinkbiganalytics.security.GroupPrincipal in project kylo by Teradata.
the class AclPrincipalTypeUpgradeAction method upgrade.
private void upgrade(JcrAllowedActions allowed, Set<String> userNames, Set<String> groupNames) {
allowed.streamActions().forEach(action -> {
allowed.getPrincipalsAllowedAll(action).stream().filter(this::isUpgradable).forEach(principal -> {
// Re-add known groups and users principals of the correct type.
if (groupNames.contains(principal.getName())) {
GroupPrincipal group = new GroupPrincipal(principal.getName());
allowed.enable(group, action);
} else if (userNames.contains(principal.getName())) {
UsernamePrincipal newPrincipal = new UsernamePrincipal(principal.getName());
allowed.enable(newPrincipal, action);
}
});
});
// Clean out any generic principals not upgraded to the correct type.
allowed.streamActions().forEach(action -> {
allowed.getPrincipalsAllowedAll(action).stream().filter(this::isUpgradable).forEach(principal -> {
if (!(principal instanceof UsernamePrincipal || principal instanceof Group)) {
allowed.disable(new RemovedPrincipal(principal), action);
}
});
});
}
Aggregations