Skip to content

Commit

Permalink
Move EmailAccountCreationService and EmailChangeEmailService to javac…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
Kehrlann committed Dec 20, 2024
1 parent 6e01853 commit fcb78f7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
package org.cloudfoundry.identity.uaa.account;

import com.fasterxml.jackson.core.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.cloudfoundry.identity.uaa.codestore.ExpiringCode;
import org.cloudfoundry.identity.uaa.codestore.ExpiringCodeStore;
import org.cloudfoundry.identity.uaa.constants.OriginKeys;
import org.cloudfoundry.identity.uaa.error.UaaException;
import org.cloudfoundry.identity.uaa.message.MessageService;
import org.cloudfoundry.identity.uaa.message.MessageType;
import org.cloudfoundry.identity.uaa.oauth.provider.ClientDetails;
import org.cloudfoundry.identity.uaa.provider.NoSuchClientException;
import org.cloudfoundry.identity.uaa.scim.ScimUser;
import org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning;
import org.cloudfoundry.identity.uaa.scim.exception.ScimResourceAlreadyExistsException;
import org.cloudfoundry.identity.uaa.scim.util.ScimUtils;
import org.cloudfoundry.identity.uaa.scim.validate.PasswordValidator;
import org.cloudfoundry.identity.uaa.util.JsonUtils;
import org.cloudfoundry.identity.uaa.provider.NoSuchClientException;
import org.cloudfoundry.identity.uaa.zone.MultitenantClientServices;
import org.cloudfoundry.identity.uaa.zone.IdentityZone;
import org.cloudfoundry.identity.uaa.zone.MergedZoneBrandingInformation;
import org.cloudfoundry.identity.uaa.zone.MultitenantClientServices;
import org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.cloudfoundry.identity.uaa.oauth.provider.ClientDetails;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;

import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import static org.cloudfoundry.identity.uaa.codestore.ExpiringCodeType.REGISTRATION;
import static org.cloudfoundry.identity.uaa.util.UaaUrlUtils.findMatchingRedirectUri;
import static org.springframework.http.HttpStatus.BAD_REQUEST;

@Service
public class EmailAccountCreationService implements AccountCreationService {

private final Logger logger = LoggerFactory.getLogger(getClass());
Expand All @@ -48,7 +55,7 @@ public class EmailAccountCreationService implements AccountCreationService {
private final IdentityZoneManager identityZoneManager;

public EmailAccountCreationService(
SpringTemplateEngine templateEngine,
@Qualifier("mailTemplateEngine") SpringTemplateEngine templateEngine,
MessageService messageService,
ExpiringCodeStore codeStore,
ScimUserProvisioning scimUserProvisioning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,32 @@
import org.cloudfoundry.identity.uaa.error.UaaException;
import org.cloudfoundry.identity.uaa.message.MessageService;
import org.cloudfoundry.identity.uaa.message.MessageType;
import org.cloudfoundry.identity.uaa.oauth.provider.ClientDetails;
import org.cloudfoundry.identity.uaa.provider.NoSuchClientException;
import org.cloudfoundry.identity.uaa.scim.ScimUser;
import org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning;
import org.cloudfoundry.identity.uaa.util.JsonUtils;
import org.cloudfoundry.identity.uaa.util.UaaUrlUtils;
import org.cloudfoundry.identity.uaa.provider.NoSuchClientException;
import org.cloudfoundry.identity.uaa.zone.MergedZoneBrandingInformation;
import org.cloudfoundry.identity.uaa.zone.MultitenantClientServices;
import org.cloudfoundry.identity.uaa.zone.beans.IdentityZoneManager;
import org.cloudfoundry.identity.uaa.oauth.provider.ClientDetails;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import java.sql.Timestamp;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.cloudfoundry.identity.uaa.codestore.ExpiringCodeType.EMAIL;
import static org.cloudfoundry.identity.uaa.util.UaaUrlUtils.findMatchingRedirectUri;

@Service
public class EmailChangeEmailService implements ChangeEmailService {

static final String CHANGE_EMAIL_REDIRECT_URL = "change_email_redirect_url";
Expand All @@ -38,7 +45,8 @@ public class EmailChangeEmailService implements ChangeEmailService {
private final MultitenantClientServices clientDetailsService;
private final IdentityZoneManager identityZoneManager;

EmailChangeEmailService(final TemplateEngine templateEngine,
EmailChangeEmailService(
@Qualifier("mailTemplateEngine") final TemplateEngine templateEngine,
final MessageService messageService,
final ScimUserProvisioning scimUserProvisioning,
final ExpiringCodeStore codeStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class LoginServerConfig {
*
* @return -
*/
@Bean(name = "messageService")
@Bean
public MessageService emailMessageService(
// dgarnier: use DEFAULT_UAA_URL
@Value("${login.url:http://localhost:8080/uaa}") String loginUrl,
Expand Down Expand Up @@ -100,7 +100,7 @@ static class NotificationConfiguration {
* @param notificationsProperties -
* @return -
*/
@Bean(name = "messageService")
@Bean
@Primary
public MessageService notificationMessageService(
LocalUaaRestTemplate notificationsTemplate,
Expand Down
17 changes: 0 additions & 17 deletions server/src/main/resources/spring/login-ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,6 @@

<bean id="thymeleafConfig" class="org.cloudfoundry.identity.uaa.login.ThymeleafConfig"/>

<bean id="accountCreationService" class="org.cloudfoundry.identity.uaa.account.EmailAccountCreationService">
<constructor-arg ref="mailTemplateEngine"/>
<constructor-arg ref="messageService"/>
<constructor-arg ref="codeStore"/>
<constructor-arg ref="scimUserProvisioning"/>
<constructor-arg ref="jdbcClientDetailsService"/>
<constructor-arg ref="uaaPasswordValidator"/>
</bean>

<bean id="uaaPasswordValidator" class="org.cloudfoundry.identity.uaa.scim.validate.UaaPasswordPolicyValidator">
<constructor-arg ref="globalPasswordPolicy"/>
</bean>
Expand All @@ -382,14 +373,6 @@
<constructor-arg ref="uaaPasswordValidator"/>
</bean>

<bean id="changeEmailService" class="org.cloudfoundry.identity.uaa.account.EmailChangeEmailService">
<constructor-arg ref="mailTemplateEngine"/>
<constructor-arg ref="messageService"/>
<constructor-arg ref="jdbcClientDetailsService"/>
<constructor-arg ref="scimUserProvisioning"/>
<constructor-arg ref="codeStore"/>
</bean>

<bean id="messagePropertiesSource" class="org.springframework.core.io.support.ResourcePropertySource">
<constructor-arg value="messages.properties"/>
</bean>
Expand Down

0 comments on commit fcb78f7

Please sign in to comment.