Skip to content

Instantly share code, notes, and snippets.

@thinkmicroservices
thinkmicroservices / AuthenticationService: changePassword().java
Created March 19, 2020 20:19
AuthenticationService: changePassword().java
/**
*
* @param changePasswordRequest
* @return
* @throws ChangePasswordException
*/
public void changePassword(String accountId, String currentPassword, String newPassword, String confirmPassword) throws ChangePasswordException {
User userModel = null;
log.debug("change password accountID:{}", accountId);
// lookup the user by email address
@thinkmicroservices
thinkmicroservices / AuthenticationService: authenticate().java
Created March 19, 2020 20:17
AuthenticationService: authenticate().java
/**
*
* @param username
* @param password
* @return
* @throws AuthenticationException
*/
public AuthenticationToken authenticate(String username, String password) throws
AuthenticationException {
@thinkmicroservices
thinkmicroservices / AuthenticationService: registerUser().java
Created March 19, 2020 20:16
AuthenticationService: registerUser()
/**
*
* @param email
* @param firstName
* @param middleName
* @param lastName
* @param password
* @param confirmPassword
* @return
* @throws RegistrationException
@thinkmicroservices
thinkmicroservices / AuthenticationService: JWTProvider.java
Created March 19, 2020 19:52
AuthenticationService: JWTProvider.java
package com.thinkmicroservices.ri.spring.auth.jwt;
import com.thinkmicroservices.ri.spring.auth.repository.model.User;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import org.springframework.beans.factory.annotation.Value;
// create the event
AccountRegisteredEvent accountRegisteredEvent = new AccountRegisteredEvent(user.getAccountId(), email, firstName, middleName, lastName);
// set the message type and publish the AccountRegisteredEvent
this.accountEventSource.accountEvents()
.send(MessageBuilder.withPayload(accountRegisteredEvent)
.setHeader("type", "ACCOUNT_REGISTERED_EVENT").build());
@thinkmicroservices
thinkmicroservices / AuthenticationService: AccountEventPublisher.java
Created March 19, 2020 19:36
AuthenticationService: AccountEventPublisher.java
package com.thinkmicroservices.ri.spring.auth.messaging;
import org.springframework.cloud.stream.annotation.EnableBinding;
/**
*
* @author cwoodward
*/
@EnableBinding(AccountEventSource.class)
public class AccountEventPublisher {
@thinkmicroservices
thinkmicroservices / AuthenticationService:AccountEventSource.java
Created March 19, 2020 19:35
AuthenticationService:AccountEventSource.java
package com.thinkmicroservices.ri.spring.auth.messaging;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;
/**
*
* @author cwoodward
*/
public interface AccountEventSource {
@thinkmicroservices
thinkmicroservices / NotificationService: dc-07-notification.yml
Created March 12, 2020 22:24
NotificationService: dc-07-notification.yml
## docker-compose -f ./dc-06-outbound-sms.yml up -d
version: "3.7"
services:
##############################################################
# INFRASTRUCTURE SERVICES
################
@thinkmicroservices
thinkmicroservices / NotificationService: NotificationController.java
Created March 12, 2020 22:18
NotificationService: NotificationController.java
package com.thinkmicroservices.ri.spring.notification.controller;
import com.thinkmicroservices.ri.spring.notification.model.EmailRequest;
import com.thinkmicroservices.ri.spring.notification.model.MmsRequest;
import com.thinkmicroservices.ri.spring.notification.model.SmsRequest;
import com.thinkmicroservices.ri.spring.notification.service.EmailQueueException;
import com.thinkmicroservices.ri.spring.notification.service.NotificationService;
import com.thinkmicroservices.ri.spring.notification.service.SmsQueueException;
@thinkmicroservices
thinkmicroservices / NotificationService: NotificationService.java
Created March 12, 2020 21:16
NotificationService: NotificationService.java
package com.thinkmicroservices.ri.spring.notification.service;
import java.util.List;
/**
*
* @author cwoodward
*/
public interface NotificationService {