}
@Override
public InitiateRegistrationResult execImpl(InitiateRegistration a,
ExecutionContext ec) {
InitiateRegistrationResult result = new InitiateRegistrationResult();
String emailAddress = a.getEmailAddress();
String authResourceName = a.getAuthResourceName();
//Check that the user is not already logged in
AuthSession session = sessionProviderProvider.get().get();
if (session != null) {
throw new AlreadyAuthenticatedException();
}
//Doublecheck that no users already have the given email address
AuthUser user = userServices.getUserFromEmailAddress(emailAddress);
if (user != null) {
throw new EmailAddressTakenException();
}
AuthInitializationService authInitService =
this.initProviderProvider.get();
AuthInitialization authInit = authInitService.get();
IAuthService authService =
authSourceProvider.getAuthServices().get(authResourceName);
if (authService == null) {
throw new AuthException("No auth service could be found matching: "
+ authResourceName);
}
HttpServletResponse response = responseProvider.get();
if (response == null) {
throw new OrgamaCoreException("Failed to get HttpResponse");
}
String signInUrl = authService.getSignInUrl();
result.setRedirectUrl(signInUrl);
authInit.setEmailAddress(emailAddress);
authInit.setState(AuthInitializationState.registering);
authInit.setAuthServiceName(authResourceName);