use of com.thinkbiganalytics.security.UsernamePrincipal 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.UsernamePrincipal 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.UsernamePrincipal in project kylo by Teradata.
the class ActiveDirectoryLoginModule method doLogin.
/* (non-Javadoc)
* @see com.thinkbiganalytics.auth.jaas.AbstractLoginModule#doLogin()
*/
@Override
protected boolean doLogin() throws Exception {
final NameCallback nameCallback = new NameCallback("Username: ");
final PasswordCallback passwordCallback = new PasswordCallback("Password: ", false);
if (this.authProvider.isUsingServiceCredentials()) {
handle(nameCallback);
passwordCallback.setPassword("".toCharArray());
} else {
handle(nameCallback, passwordCallback);
}
if (nameCallback.getName() == null) {
throw new AccountException("No username provided for authentication");
}
Principal userPrincipal = new UsernamePrincipal(nameCallback.getName());
char[] password = passwordCallback.getPassword();
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userPrincipal, password);
log.debug("Authenticating: {}", userPrincipal);
Authentication authenticated = this.authProvider.authenticate(authentication);
log.debug("Successfully Authenticated: {}", userPrincipal);
setUserPrincipal(userPrincipal);
for (GrantedAuthority grant : authenticated.getAuthorities()) {
String groupName = grant.getAuthority();
log.debug("Found group for {}: {}", userPrincipal, groupName);
if (groupName != null) {
addNewGroupPrincipal(groupName);
}
}
return true;
}
use of com.thinkbiganalytics.security.UsernamePrincipal 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.UsernamePrincipal 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