Search in sources :

Example 1 with UserCreationException

use of nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException in project timbuctoo by HuygensING.

the class LocalUserCreator method create.

public void create(Map<String, String> userInfo) throws UserCreationException {
    String userPid = userInfo.get(USER_PID);
    String userName = userInfo.get(USER_NAME);
    String password = userInfo.get(PASSWORD);
    String givenName = userInfo.get(GIVEN_NAME);
    String surname = userInfo.get(SURNAME);
    String emailAddress = userInfo.get(EMAIL_ADDRESS);
    String organization = userInfo.get(ORGANIZATION);
    String vreId = userInfo.get(VRE_ID);
    String vreRole = userInfo.get(VRE_ROLE);
    try {
        loginCreator.createLogin(userPid, userName, password, givenName, surname, emailAddress, organization);
        User user = userCreator.createUser(userPid, emailAddress, givenName, surname, organization);
        authorizationCreator.createAuthorization(vreId, user, vreRole);
    } catch (LoginCreationException e) {
        throw new UserCreationException(e);
    } catch (AuthorizationCreationException e) {
        throw new UserCreationException(e);
    }
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) UserCreationException(nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException) LoginCreationException(nl.knaw.huygens.timbuctoo.security.exceptions.LoginCreationException) AuthorizationCreationException(nl.knaw.huygens.timbuctoo.v5.security.exceptions.AuthorizationCreationException)

Example 2 with UserCreationException

use of nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException in project timbuctoo by HuygensING.

the class LocalUserCreatorTest method createThrowsAUserCreationExceptionWhenTheUserCreatorDoes.

@Test(expected = UserCreationException.class)
public void createThrowsAUserCreationExceptionWhenTheUserCreatorDoes() throws Exception {
    doThrow(new UserCreationException("")).when(userCreator).createUser(anyString(), anyString(), anyString(), anyString(), anyString());
    instance.create(userInfo);
}
Also used : UserCreationException(nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException) Test(org.junit.Test)

Example 3 with UserCreationException

use of nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException in project timbuctoo by HuygensING.

the class UserCreationTaskTest method executeRethrowsTheExceptionsOfTheLocalUserCreator.

@Test(expected = UserCreationException.class)
public void executeRethrowsTheExceptionsOfTheLocalUserCreator() throws Exception {
    doThrow(new UserCreationException("")).when(localUserCreator).create(ArgumentMatchers.any());
    ImmutableMultimap<String, String> immutableMultimap = ImmutableMultimap.<String, String>builder().put(UserInfoKeys.USER_PID, PID).put(UserInfoKeys.USER_NAME, USER_NAME).put(UserInfoKeys.PASSWORD, PWD).put(UserInfoKeys.GIVEN_NAME, GIVEN_NAME).put(UserInfoKeys.SURNAME, SURNAME).put(UserInfoKeys.EMAIL_ADDRESS, EMAIL).put(UserInfoKeys.ORGANIZATION, ORGANIZATION).put(UserInfoKeys.VRE_ID, VRE_ID).put(UserInfoKeys.VRE_ROLE, VRE_ROLE).build();
    instance.execute(immutableMultimap, mock(PrintWriter.class));
}
Also used : UserCreationException(nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException) Matchers.containsString(org.hamcrest.Matchers.containsString) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

UserCreationException (nl.knaw.huygens.timbuctoo.security.exceptions.UserCreationException)3 Test (org.junit.Test)2 PrintWriter (java.io.PrintWriter)1 LoginCreationException (nl.knaw.huygens.timbuctoo.security.exceptions.LoginCreationException)1 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)1 AuthorizationCreationException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.AuthorizationCreationException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1