Search in sources :

Example 41 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class AccountPreferencesController method get.

@Override
public AccountPreferencesJson get() {
    IdentityUser user = authenticatedUserService.getCbUser();
    AccountPreferences preferences = service.getOneByAccount(user);
    return convert(preferences);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) AccountPreferences(com.sequenceiq.cloudbreak.domain.AccountPreferences)

Example 42 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class UserController method evictCurrentUserDetails.

@Override
public User evictCurrentUserDetails() {
    IdentityUser user = authenticatedUserService.getCbUser();
    userDetailsService.evictUserDetails(user.getUserId(), user.getUsername());
    return new User(user.getUsername());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) User(com.sequenceiq.cloudbreak.api.model.User)

Example 43 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class UserController method modifyProfile.

@Override
public void modifyProfile(UserProfileRequest userProfileRequest) {
    IdentityUser user = authenticatedUserService.getCbUser();
    userProfileService.put(userProfileRequest, user);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser)

Example 44 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class OwnerBasedPermissionEvaluatorTest method testWriteNotOwnerButAdmin.

@Test
public void testWriteNotOwnerButAdmin() {
    when(oauth.getUserAuthentication()).thenReturn(new TestingAuthenticationToken("principal", "credential"));
    IdentityUser user = new IdentityUser("admin", "", "account", Collections.singletonList(IdentityUserRole.ADMIN), "", "", null);
    when(userDetailsService.getDetails(anyString(), any(UserFilterField.class))).thenReturn(user);
    boolean result = underTest.hasPermission(oauth, stack, "write");
    Assert.assertTrue(result);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserFilterField(com.sequenceiq.cloudbreak.common.service.user.UserFilterField) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Example 45 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class OwnerBasedPermissionEvaluatorTest method testWriteNotOwnerNotAdminButPublicInAccount.

@Test
public void testWriteNotOwnerNotAdminButPublicInAccount() {
    when(oauth.getUserAuthentication()).thenReturn(new TestingAuthenticationToken("principal", "credential"));
    IdentityUser user = new IdentityUser("admin", "", "account", Collections.emptyList(), "", "", null);
    when(userDetailsService.getDetails(anyString(), any(UserFilterField.class))).thenReturn(user);
    stack.setPublicInAccount(true);
    boolean result = underTest.hasPermission(oauth, stack, "write");
    Assert.assertFalse(result);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserFilterField(com.sequenceiq.cloudbreak.common.service.user.UserFilterField) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Aggregations

IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)133 Test (org.junit.Test)14 Stack (com.sequenceiq.cloudbreak.domain.Stack)13 UserFilterField (com.sequenceiq.cloudbreak.common.service.user.UserFilterField)9 Async (org.springframework.scheduling.annotation.Async)9 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 Credential (com.sequenceiq.cloudbreak.domain.Credential)8 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)8 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)7 ProxyConfig (com.sequenceiq.cloudbreak.domain.ProxyConfig)7 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)6 Before (org.junit.Before)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)6 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)5 Template (com.sequenceiq.cloudbreak.domain.Template)5 ConstraintTemplate (com.sequenceiq.cloudbreak.domain.ConstraintTemplate)4 Network (com.sequenceiq.cloudbreak.domain.Network)4 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)4