Showing preview only (321K chars total). Download the full file or copy to clipboard to get everything.
Repository: tlandeka/authentication-microservice-with-domain-driven-design
Branch: main
Commit: a7cfd82824d9
Files: 209
Total size: 254.6 KB
Directory structure:
gitextract_3sq3ne0n/
├── .github/
│ └── workflows/
│ └── maven.yml
├── .gitignore
├── .mvn/
│ └── wrapper/
│ ├── MavenWrapperDownloader.java
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── 1-init.sql
├── Dockerfile
├── LICENSE
├── README.md
├── ddd_common-v1.0.0.jar
├── docker-compose-ci.yml
├── docker-compose.yml
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── tomo/
│ │ └── mcauthentication/
│ │ ├── McAuthenticationApplication.java
│ │ ├── application/
│ │ │ ├── BaseMapper.java
│ │ │ ├── McAuthenticationEventHandler.java
│ │ │ ├── authentication/
│ │ │ │ ├── BaseLoginCommandHandler.java
│ │ │ │ ├── EmailLoginCommandHandler.java
│ │ │ │ ├── FacebookLoginCommandHandler.java
│ │ │ │ ├── GoogleLoginCommandHandler.java
│ │ │ │ ├── LogoutCommandHandler.java
│ │ │ │ ├── SessionAuthenticationCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── BaseLoginCommand.java
│ │ │ │ │ ├── EmailLoginCommand.java
│ │ │ │ │ ├── FacebookLoginCommand.java
│ │ │ │ │ ├── GoogleLoginCommand.java
│ │ │ │ │ ├── LogoutCommand.java
│ │ │ │ │ └── SessionAuthenticationCommand.java
│ │ │ │ └── dto/
│ │ │ │ ├── RecoveryPasswordDto.java
│ │ │ │ └── SessionDto.java
│ │ │ ├── configuration/
│ │ │ │ ├── AbstractVoidyCommandHandler.java
│ │ │ │ ├── CommandHandler.java
│ │ │ │ ├── QueryHandler.java
│ │ │ │ └── RequestHandler.java
│ │ │ ├── contracts/
│ │ │ │ ├── BaseCommand.java
│ │ │ │ ├── BaseQuery.java
│ │ │ │ ├── BaseRequest.java
│ │ │ │ ├── Command.java
│ │ │ │ ├── Identifiable.java
│ │ │ │ ├── McAuthenticationModule.java
│ │ │ │ ├── Query.java
│ │ │ │ ├── Request.java
│ │ │ │ ├── Response.java
│ │ │ │ ├── Voidy.java
│ │ │ │ └── security/
│ │ │ │ ├── AbstractAuthenticateCommand.java
│ │ │ │ ├── AbstractAuthenticateQuery.java
│ │ │ │ ├── AbstractAuthenticateRequest.java
│ │ │ │ ├── AbstractAuthorizeCommand.java
│ │ │ │ ├── AbstractAuthorizeQuery.java
│ │ │ │ ├── AbstractAuthorizeRequest.java
│ │ │ │ ├── Authenticate.java
│ │ │ │ └── Authorize.java
│ │ │ ├── recovery/
│ │ │ │ ├── CreatePasswordRecoveryCodeCommandHandler.java
│ │ │ │ ├── GetUserRegistrationWithRecoveryCodeQueryHandler.java
│ │ │ │ ├── PasswordRecoveryCodeCreatedEventHandler.java
│ │ │ │ ├── SendPasswordRecoveryEmailCommandHandler.java
│ │ │ │ ├── UpdatePasswordWithRecoveryCodeCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── CreatePasswordRecoveryCodeCommand.java
│ │ │ │ │ ├── SendPasswordRecoveryEmailCommand.java
│ │ │ │ │ └── UpdatePasswordWithRecoveryCodeCommand.java
│ │ │ │ └── dto/
│ │ │ │ └── GetUserRegistrationWithRecoveryCodeQuery.java
│ │ │ ├── registration/
│ │ │ │ ├── ChangePasswordCommandHandler.java
│ │ │ │ ├── ConfirmUserRegistrationCommandHandler.java
│ │ │ │ ├── GetUserRegistrationQueryHandler.java
│ │ │ │ ├── NewUserRegisteredEventHandler.java
│ │ │ │ ├── RegisterNewUserCommandHandler.java
│ │ │ │ ├── SendRegistrationConfirmationEmailCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── ChangePasswordCommand.java
│ │ │ │ │ ├── ConfirmUserRegistrationCommand.java
│ │ │ │ │ ├── RegisterNewUserCommand.java
│ │ │ │ │ └── SendRegistrationConfirmationEmailCommand.java
│ │ │ │ ├── dto/
│ │ │ │ │ └── UserRegistrationDto.java
│ │ │ │ └── query/
│ │ │ │ └── GetUserRegistrationQuery.java
│ │ │ └── users/
│ │ │ ├── ChangeUserDetailsCommandHandler.java
│ │ │ ├── GetUserQueryHandler.java
│ │ │ ├── command/
│ │ │ │ └── ChangeUserDetailsCommand.java
│ │ │ ├── dto/
│ │ │ │ └── BaseUserDto.java
│ │ │ └── query/
│ │ │ └── GetUserQuery.java
│ │ ├── domain/
│ │ │ ├── DomainRegistry.java
│ │ │ ├── EncryptionService.java
│ │ │ ├── oauth2/
│ │ │ │ ├── OAuth2Authentication.java
│ │ │ │ ├── OAuth2Principal.java
│ │ │ │ └── OAuth2Service.java
│ │ │ ├── registration/
│ │ │ │ ├── EmailAuthenticationService.java
│ │ │ │ ├── PasswordService.java
│ │ │ │ ├── UserRegistration.java
│ │ │ │ ├── UserRegistrationId.java
│ │ │ │ ├── UserRegistrationRepository.java
│ │ │ │ ├── UserRegistrationStatus.java
│ │ │ │ ├── UsersCounter.java
│ │ │ │ ├── events/
│ │ │ │ │ ├── PasswordChanged.java
│ │ │ │ │ ├── PasswordRecovered.java
│ │ │ │ │ ├── PasswordRecoveryCodeCreated.java
│ │ │ │ │ ├── UserRegistrationConfirmed.java
│ │ │ │ │ └── UserRegistrationRequested.java
│ │ │ │ └── rules/
│ │ │ │ ├── PasswordRecoveryCodeShouldBeExpiredOrNull.java
│ │ │ │ ├── PasswordRecoveryCodeShouldNotExpired.java
│ │ │ │ ├── PasswordsMustMatch.java
│ │ │ │ ├── RecoveryCodeMustMatch.java
│ │ │ │ ├── UserRegistrationCannotBeConfirmedAfterExpiration.java
│ │ │ │ ├── UserRegistrationCannotBeConfirmedMoreThanOnce.java
│ │ │ │ ├── UserRegistrationMustBeConfirmed.java
│ │ │ │ └── UserRegistrationMustBeUnique.java
│ │ │ ├── session/
│ │ │ │ ├── JwtTokenProvider.java
│ │ │ │ ├── Session.java
│ │ │ │ ├── SessionAuthenticationService.java
│ │ │ │ ├── SessionId.java
│ │ │ │ ├── SessionRepository.java
│ │ │ │ ├── TokenProvider.java
│ │ │ │ ├── events/
│ │ │ │ │ └── SessionCreated.java
│ │ │ │ └── rule/
│ │ │ │ └── SessionCannotBeExpiredWhenRefreshTokenIsMissing.java
│ │ │ └── users/
│ │ │ ├── EmailLogin.java
│ │ │ ├── User.java
│ │ │ ├── UserId.java
│ │ │ ├── UserRepository.java
│ │ │ ├── events/
│ │ │ │ ├── UserCreated.java
│ │ │ │ └── UserNameChanged.java
│ │ │ └── rules/
│ │ │ └── UserEmailMustBeUnique.java
│ │ └── infrastructure/
│ │ ├── McAuthenticationModuleExecutor.java
│ │ ├── http/
│ │ │ └── oauth2/
│ │ │ ├── AbstractOAuth2Authentication.java
│ │ │ ├── CustomOAuth2UserService.java
│ │ │ ├── FacebookOAuth2Authentication.java
│ │ │ ├── GoogleOAuth2Authentication.java
│ │ │ └── user/
│ │ │ ├── FacebookOAuth2UserInfo.java
│ │ │ ├── GoogleOAuth2UserInfo.java
│ │ │ ├── OAuth2UserInfo.java
│ │ │ └── OAuth2UserInfoFactory.java
│ │ ├── persistence/
│ │ │ ├── BaseJpaAdapter.java
│ │ │ ├── SessionJpaRepository.java
│ │ │ ├── SessionRepositoryJpaAdapter.java
│ │ │ ├── UserJpaRepository.java
│ │ │ ├── UserRegistrationJpaRepository.java
│ │ │ ├── UserRegistrationJpaRepositoryAdapter.java
│ │ │ └── UserRepositoryJpaAdapter.java
│ │ ├── processing/
│ │ │ ├── ErrorCommandHandlerDecorator.java
│ │ │ ├── LoggingCommandHandlerDecorator.java
│ │ │ ├── LoggingQueryHandlerDecorator.java
│ │ │ ├── PipelineBuilder.java
│ │ │ └── builder/
│ │ │ ├── AbstractPipelineBuilder.java
│ │ │ ├── CommandHandlerPipelineBuilder.java
│ │ │ └── QueryHandlerPipelineBuilder.java
│ │ ├── service/
│ │ │ └── MD5EncryptionService.java
│ │ ├── springboot/
│ │ │ ├── configuration/
│ │ │ │ ├── AppConfig.java
│ │ │ │ ├── AppProperties.java
│ │ │ │ ├── GUIProperties.java
│ │ │ │ ├── MessageProperties.java
│ │ │ │ ├── SecurityConfig.java
│ │ │ │ ├── SwaggerConfig.java
│ │ │ │ └── SwaggerUiWebMvcConfigurer.java
│ │ │ ├── controller/
│ │ │ │ ├── AbstractController.java
│ │ │ │ ├── AuthenticationController.java
│ │ │ │ ├── RegistrationController.java
│ │ │ │ ├── RestApiRoutes.java
│ │ │ │ └── UserController.java
│ │ │ ├── filter/
│ │ │ │ └── TokenAuthenticationFilter.java
│ │ │ └── security/
│ │ │ ├── CurrentUser.java
│ │ │ ├── OAuth2AuthenticationFailureHandler.java
│ │ │ ├── OAuth2AuthenticationSuccessHandler.java
│ │ │ ├── UserAuthPrincipal.java
│ │ │ └── UserAuthToken.java
│ │ └── util/
│ │ └── CookieUtils.java
│ └── resources/
│ ├── application.yml
│ ├── db/
│ │ └── migration/
│ │ └── V2022_02_02_1124__initial_structure.sql
│ └── repo/
│ └── org/
│ └── tomo/
│ └── ddd_common/
│ ├── 1.0.0/
│ │ ├── ddd_common-1.0.0.jar
│ │ ├── ddd_common-1.0.0.jar.md5
│ │ ├── ddd_common-1.0.0.jar.sha1
│ │ ├── ddd_common-1.0.0.pom
│ │ ├── ddd_common-1.0.0.pom.md5
│ │ └── ddd_common-1.0.0.pom.sha1
│ ├── maven-metadata.xml
│ ├── maven-metadata.xml.md5
│ └── maven-metadata.xml.sha1
└── test/
├── java/
│ └── com/
│ └── tomo/
│ └── mcauthentication/
│ ├── integration/
│ │ ├── BaseIntegrationTest.java
│ │ └── application/
│ │ ├── AbstractApplicationServiceTest.java
│ │ ├── authentication/
│ │ │ ├── EmailLoginCommandHandlerTest.java
│ │ │ ├── FacebookLoginCommandHandlerTest.java
│ │ │ ├── GoogleLoginCommandHandlerTest.java
│ │ │ ├── LogoutCommandHandlerTest.java
│ │ │ └── SessionAuthenticationCommandHandlerTest.java
│ │ ├── recovery/
│ │ │ ├── CreatePasswordRecoveryCodeCommandHandlerTest.java
│ │ │ ├── GetUserRegistrationWithRecoveryCodeQueryHandlerTest.java
│ │ │ └── UpdatePasswordWithRecoveryCodeCommandHandlerTest.java
│ │ ├── registration/
│ │ │ ├── ChangePasswordCommandHandlerTest.java
│ │ │ ├── ConfirmUserRegistrationCommandHandlerTest.java
│ │ │ └── RegisterNewUserCommandHandlerTest.java
│ │ └── users/
│ │ ├── ChangeUserDetailsCommandHandlerTest.java
│ │ └── GetUserQueryHandlerTest.java
│ ├── smoke/
│ │ └── McAuthenticationApplicationSmokeTest.java
│ ├── testdata/
│ │ ├── CommandObjectMother.java
│ │ └── StaticFields.java
│ ├── unit/
│ │ ├── application/
│ │ │ └── registration/
│ │ │ └── UserRegistrationCommandHandlerTest.java
│ │ └── domain/
│ │ ├── AbstractUnitTest.java
│ │ ├── registration/
│ │ │ ├── UserRegistrationTest.java
│ │ │ └── rules/
│ │ │ ├── PasswordRecoveryCodeShouldBeExpiredOrNullTest.java
│ │ │ ├── PasswordRecoveryCodeShouldNotExpiredTest.java
│ │ │ ├── PasswordsMustMatchTest.java
│ │ │ ├── RecoveryCodeMustMatchTest.java
│ │ │ ├── UserRegistrationCannotBeConfirmedAfterExpirationTest.java
│ │ │ ├── UserRegistrationCannotBeConfirmedMoreThanOnceTest.java
│ │ │ ├── UserRegistrationMustBeConfirmedTest.java
│ │ │ └── UserRegistrationMustBeUniqueTest.java
│ │ ├── session/
│ │ │ └── rules/
│ │ │ └── SessionCannotBeExpiredWhenRefreshTokenIsMissingTest.java
│ │ └── user/
│ │ └── rules/
│ │ └── UserEmailMustBeUniqueTest.java
│ └── weblayer/
│ ├── BaseWebLayerTest.java
│ └── springboot/
│ └── controller/
│ ├── AbstractControllerTest.java
│ └── RegistrationControllerTest.java
└── resources/
└── application-ci.yml
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/maven.yml
================================================
name: Run tests
on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Start docker containers
run: |
docker-compose -f docker-compose-ci.yml up --build --detach
sleep 10 # wait for database to be ready
- name: Run unit tests
run: docker-compose -f docker-compose-ci.yml run mc-authentication-service-test ./mvnw test -Punittest -Dspring.profiles.active=ci
- name: Run integration tests
run: docker-compose -f docker-compose-ci.yml run mc-authentication-service-test ./mvnw test -Pintegrationtest -Dspring.profiles.active=ci
================================================
FILE: .gitignore
================================================
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
.DS_Store
================================================
FILE: .mvn/wrapper/MavenWrapperDownloader.java
================================================
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
================================================
FILE: .mvn/wrapper/maven-wrapper.properties
================================================
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
================================================
FILE: 1-init.sql
================================================
create user mcuser with superuser;
alter user mcuser with password 'mcuser';
create database mc_authentication with owner mcuser;
create extension "uuid-ossp";
================================================
FILE: Dockerfile
================================================
FROM amazoncorretto:11 as base
WORKDIR /app
COPY .mvn/ .mvn
COPY mvnw pom.xml ddd_common-v1.0.0.jar ./
RUN ./mvnw deploy:deploy-file -Durl=file:./src/main/resources/repo -Dfile=ddd_common-v1.0.0.jar -DgroupId=org.tomo -DartifactId=ddd_common -Dpackaging=jar -Dversion=1.0.0
RUN ./mvnw dependency:resolve
FROM base as test
RUN ./mvnw dependency:resolve-plugins -Punittest,integrationtest
COPY src ./src
ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
CMD tail -f /dev/null
FROM base as build
COPY src ./src
RUN ./mvnw package
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021 Tomislav Landeka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Microservice for authentication with Domain-Driven Design
Full Spring Boot authentication microservice with Domain-Driven Design approach.
### 1. Introduction
#### 1.1. Purpose of this Repository
This is a list of the main goals of this repository:
* Showing how you can implement a Domain-Drive design
* Showing how you can implement a CQRS
* Presentation of the full implementation of an application
* This is not another proof of concept (PoC)
* The goal is to present the implementation of an application that would be ready to run in production
* Showing the application of best practices and object-oriented programming principles
* Presentation of the use of design patterns. When, how and why they can be used
* Presentation of the implementation using Domain-Driven Design approach (tactical patterns)
* Presentation of the implementation of Unit Tests for Domain Model (Testable Design in mind)
* Presentation of the implementation of Integration Tests
* Presentation of the implementation of testing Web-Layer only
#### 1.2 Your contribution
* Give it a star
* Share it
* Become a contributor
### 2. Domain
#### 2.1. Business logic of the repository
The main idea of this repository is to create small microservice for authentication that provides next functionalities:
* Form Registration
* Form Login, Google Login, Facebook Login
* Password recovery
* Email notifications
* Session identification and authentication
#### 2.2. How to run
* Run database docker container first: `docker-compose up -d`
* Run application locally with `local` profile
* Plan is to dockerize the application in order to run it easy
#### 2.3. How to run tests
* Run database docker container first: `docker-compose up -d`. Plan is to add testdb for testing purposes.
* Run Integration test separately
* Run Unit test separately
* Run Web-Layer (tests that are testing Spring Boot implementation and Rest Controller) tests separately
### 3. Desired TODO List to complete the application:
* Clean the code from inconsistencies
* Add more session details
* Implement a tool like ELK
* Caching if/when needed
* More tests
* CI
* Pull out 'ddd' folder and create a library
* Pull out 'CQRS' folders (contracts and configuration) and create a library
* Finish SpringBoot security and CSFR token
* Dockerize
### 4. The main idea is to create a reusable microservice network that consists of the next microservices:
* Service discovery (probably with K8s).
* Create a microservice for authentication (current repository).
* Create a microservice for authorization - simple implementation of RBAC.
* Create a microservice for sending emails.
* Create a microservice for localization - the idea is to provide UI for translating the application to various languages as a common part of most applications.
* Create a microservice for asynchronous communication (AC) - the idea is to create a microservice that distributes the messages between microservices. The microservice should work over DB (e.g. Redis) and RMQ to provide asynchrony. The microservice should provide the REST API for accessing it. In this way, we should have RMQ in only one place and communication with this microservice should go over REST API.
The microservice should provide these routes:
* route for registering messages by other microservices. E.g. Email-Microservice could register message **send-email** with _required properties_, _endpoint_, and _version_. That configuration should be saved into a DB.
* sending messages - E.g. Authentication microservice should send a message after registering a user with the name **send-email** and _required properties_. The AC microservice will receive that message, validate the required properties, enrich the message body with an endpoint (which is saved in DB) and publish a message to RMQ. The RMQ consumer will consume the message and distribute it to the endpoint.
### 5. License
The project is under [MIT license](https://opensource.org/licenses/MIT).
### 6. Inspiration
#### 6.1. Domain-Driven Design
- ["Domain-Driven Design: Tackling Complexity in the Heart of Software"](https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215) book, Eric Evans
- ["Implementing Domain-Driven Design"](https://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577) book, Vaughn Vernon
- ["Domain-Driven Design in PHP"](https://www.amazon.com/dp/1787284948) book, by Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary
- ["IDDD_Samples"](https://github.com/VaughnVernon/IDDD_Samples) GH repository, Vaughn Vernon
- ["Blog CQRS"](https://github.com/dddshelf/blog-cqrs) GH repository, by Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary
- ["DDD example - Last Wishes"](https://github.com/dddshelf/last-wishes) GH repository, by Carlos Buenosvinos, Christian Soronellas, Keyvan Akbary
- ["Modular Monolith with DDD"](https://github.com/kgrzybek/modular-monolith-with-ddd) GH repository, by Kamil Grzybek
- ["Mediator implementation"](https://github.com/jbogard/MediatR) GH repository, by Jimmy Bogard
#### 6.2 Application Architecture
- ["Patterns of Enterprise Application Architecture"](https://martinfowler.com/books/eaa.html) book, Martin Fowler
- ["Clean Architecture: A Craftsman's Guide to Software Structure and Design (Robert C. Martin Series"](https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164) book, Robert C. Martin
- ["The Clean Architecture"](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) article, Robert C. Martin
- ["DDD, Hexagonal, Onion, Clean, CQRS, … How I put it all together"](https://herbertograca.com/2017/11/16/explicit-architecture-01-ddd-hexagonal-onion-clean-cqrs-how-i-put-it-all-together/) article, Herberto Graca
#### 6.2. System Architecture
- ["Building Microservices: Designing Fine-Grained Systems"](https://www.amazon.com/Building-Microservices-Designing-Fine-Grained-Systems/dp/1491950358) book, Sam Newman
#### 6.3. Design
- ["Clean Code: A Handbook of Agile Software Craftsmanship"](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) book, Robert C. Martin
- ["Design Patterns: Elements of Reusable Object-Oriented Software"](https://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612) book, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
================================================
FILE: docker-compose-ci.yml
================================================
version: '3.7'
services:
mc-authentication-db-test:
container_name: mc-authentication-db-test
image: postgres:12
restart: always
ports:
- 127.0.0.1:5432:5432
networks:
- mc-network-test
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
volumes:
- mc-authentication-db-test:/var/lib/postgresql
- ./1-init.sql:/docker-entrypoint-initdb.d/1-init.sql
mc-authentication-service-test:
container_name: mc-authentication-service-test
depends_on:
- mc-authentication-db-test
build:
context: ./
dockerfile: Dockerfile
target: test
ports:
- 127.0.0.1:8080:8080
networks:
- mc-network-test
volumes:
mc-authentication-db-test:
networks:
mc-network-test:
driver: bridge
================================================
FILE: docker-compose.yml
================================================
version: '3.7'
services:
mc-authentication_db:
container_name: mc-authentication_db
image: postgres:12
restart: always
ports:
- 127.0.0.1:5432:5432
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
volumes:
- mc-authentication-db:/var/lib/postgresql
- ./1-init.sql:/docker-entrypoint-initdb.d/1-init.sql
volumes:
mc-authentication-db:
networks:
mc-network:
driver: bridge
================================================
FILE: mvnw
================================================
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
================================================
FILE: mvnw.cmd
================================================
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tomo</groupId>
<artifactId>mc-authentication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mc-authentication</name>
<description>API for Authentication</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!--https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages–>-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<junit.version>4.13.2</junit.version>
<junit-vintage-engine>4.12.1</junit-vintage-engine>
<junit-jupiter.version>5.8.2</junit-jupiter.version>
<junit-platform.version>1.0.1</junit-platform.version>
</properties>
<repositories>
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/src/main/resources/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-client</artifactId>
</dependency>
<!-- JWT library -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<!-- PipelineR -->
<dependency>
<groupId>net.sizovs</groupId>
<artifactId>pipelinr</artifactId>
<version>0.7</version>
</dependency>
<!-- Postgres -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>8.4.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- Validation annotation-->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- Entity to DTO-->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.4.5</version>
</dependency>
<!-- Java Faker-->
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<!-- mailgun lib for ddd folder-->
<dependency>
<groupId>net.sargue</groupId>
<artifactId>mailgun</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.28</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<!-- swagger 2.0 with spring boot-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.tomo</groupId>
<artifactId>ddd_common</artifactId>
<version>v1.0.0</version>
</dependency>
<dependency>
<groupId>org.tomo</groupId>
<artifactId>ddd_common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.codehaus.mojo</groupId>-->
<!-- <artifactId>exec-maven-plugin</artifactId>-->
<!-- <version>1.2.1</version>-->
<!-- <configuration>-->
<!-- <mainClass>com.tomo.mcauthentication.McAuthenticationApplication</mainClass>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<profiles>
<profile>
<id>flyway</id>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>8.4.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<driver>org.postgresql.Driver</driver>
<user>mcuser</user>
<password>mcuser</password>
<url>jdbc:postgresql://localhost:5432/mc_authentication</url>
<placeholderReplacement>false</placeholderReplacement>
<baselineOnMigrate>true</baselineOnMigrate>
<schemas>
<schema>public</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>unittest</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version> <!-- matters until now-->
<configuration>
<includes>
<include>com.tomo.mcauthentication.unit.**</include>
</includes>
</configuration>
<dependencies>
<!-- to let surefire to run JUnit 4 but also JUnit 5 tests -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform.version}</version>
</dependency>
<!-- JUnit vintage engine to run JUnit 3 or JUnit 4 tests -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-vintage-engine}</version>
</dependency>
<!-- JUnit 5 engine to run JUnit 5 tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integrationtest</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>8.4.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<driver>org.postgresql.Driver</driver>
<user>mcuser</user>
<password>mcuser</password>
<url>jdbc:postgresql://mc-authentication-db-test:5432/mc_authentication</url>
<placeholderReplacement>false</placeholderReplacement>
<baselineOnMigrate>true</baselineOnMigrate>
<schemas>
<schema>public</schema>
</schemas>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes>
<include>com.tomo.mcauthentication.integration.*</include>
</includes>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version> <!-- matters until now-->
<configuration>
<excludes>
<exclude>com.tomo.mcauthentication.unit.**</exclude>
</excludes>
</configuration>
<dependencies>
<!-- to let surefire to run JUnit 4 but also JUnit 5 tests -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform.version}</version>
</dependency>
<!-- JUnit vintage engine to run JUnit 3 or JUnit 4 tests -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-vintage-engine}</version>
</dependency>
<!-- JUnit 5 engine to run JUnit 5 tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
================================================
FILE: src/main/java/com/tomo/mcauthentication/McAuthenticationApplication.java
================================================
package com.tomo.mcauthentication;
import com.tomo.mcauthentication.infrastructure.springboot.configuration.AppProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableWebMvc
@EnableSwagger2
@SpringBootApplication
@EnableConfigurationProperties(AppProperties.class)
@EnableAspectJAutoProxy(proxyTargetClass=true)
@ComponentScan(basePackages = { "com.tomo.*" })
@EntityScan("com.tomo.*")
public class McAuthenticationApplication {
public static void main(String[] args) {
SpringApplication.run(McAuthenticationApplication.class, args);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/BaseMapper.java
================================================
package com.tomo.mcauthentication.application;
import org.modelmapper.ModelMapper;
public class BaseMapper {
protected ModelMapper modelMapper;
public BaseMapper() {}
public BaseMapper(ModelMapper modelMapper) {
this.modelMapper = modelMapper;
}
protected <T, E> T toDto(E source, Class<T> destinationType) {
return modelMapper.map(source, destinationType);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/McAuthenticationEventHandler.java
================================================
package com.tomo.mcauthentication.application;
import com.tomo.ddd.domain.DomainEvent;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.ddd.domain.DomainEventSubscriber;
import com.tomo.ddd.event.EventStore;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class McAuthenticationEventHandler {
private EventStore eventStore;
public McAuthenticationEventHandler(EventStore eventStore) {
this.eventStore = eventStore;
}
@Before(value = "execution(* *(..)) && within(com.tomo.mcauthentication.application..*)")
public void listen() {
DomainEventPublisher
.instance()
.subscribe(new DomainEventSubscriber<DomainEvent>() {
public void handleEvent(DomainEvent aDomainEvent) {
store(aDomainEvent);
}
public Class<DomainEvent> subscribedToEventType() {
return DomainEvent.class; // all domain events
}
});
}
/**
* Stores aDomainEvent to the event store.
* @param aDomainEvent the DomainEvent to store
*/
private void store(DomainEvent aDomainEvent) {
this.eventStore().append(aDomainEvent);
}
/**
* Answers my EventStore.
* @return EventStore
*/
private EventStore eventStore() {
return this.eventStore;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/BaseLoginCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.BaseMapper;
import com.tomo.mcauthentication.application.authentication.dto.SessionDto;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionRepository;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import org.modelmapper.ModelMapper;
public class BaseLoginCommandHandler extends BaseMapper {
protected SessionRepository sessionRepository;
protected TokenProvider tokenProvider;
public BaseLoginCommandHandler() {
}
public BaseLoginCommandHandler(ModelMapper modelMapper, TokenProvider tokenProvider) {
super(modelMapper);
this.tokenProvider = tokenProvider;
}
public BaseLoginCommandHandler(
ModelMapper modelMapper,
SessionRepository sessionRepository,
TokenProvider tokenProvider) {
super(modelMapper);
this.sessionRepository = sessionRepository;
this.tokenProvider = tokenProvider;
}
protected SessionDto toDto(Session session) {
return SessionDto.create(session, this.modelMapper);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/EmailLoginCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.authentication.command.EmailLoginCommand;
import com.tomo.mcauthentication.application.authentication.dto.SessionDto;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionRepository;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import com.tomo.mcauthentication.domain.registration.EmailAuthenticationService;
import com.tomo.mcauthentication.domain.users.User;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class EmailLoginCommandHandler extends BaseLoginCommandHandler implements CommandHandler<EmailLoginCommand, SessionDto> {
EmailAuthenticationService authenticationService;
public EmailLoginCommandHandler(
EmailAuthenticationService emailAuthenticationService,
@Qualifier("sessionRepositoryJpaAdapter") SessionRepository sessionRepository,
@Qualifier("jwtTokenProvider") TokenProvider tokenProvider,
ModelMapper modelMapper) {
super(modelMapper, sessionRepository, tokenProvider);
this.authenticationService = emailAuthenticationService;
this.tokenProvider = tokenProvider;
}
@Override
public SessionDto handle(EmailLoginCommand command) {
User user = authenticationService.authenticate(command.getEmail(), command.getPassword());
Session session = new Session(
sessionRepository.nextIdentity(),
user,tokenProvider,
command.getRememberMe(),
command.getUserAgent(), command.getIpAddress());
sessionRepository.save(session);
return toDto(session);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/FacebookLoginCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.authentication.command.FacebookLoginCommand;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.users.dto.BaseUserDto;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Service;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionRepository;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import com.tomo.mcauthentication.domain.users.User;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class FacebookLoginCommandHandler extends BaseLoginCommandHandler implements CommandHandler<FacebookLoginCommand, BaseUserDto> {
OAuth2Service oAuth2Service;
public FacebookLoginCommandHandler(
@Qualifier("facebookOAuth2Service") OAuth2Service oAuth2Service,
@Qualifier("jwtTokenProvider") TokenProvider tokenProvider,
@Qualifier("sessionRepositoryJpaAdapter") SessionRepository sessionRepository,
ModelMapper modelMapper) {
super(modelMapper, sessionRepository, tokenProvider);
this.oAuth2Service = oAuth2Service;
this.tokenProvider = tokenProvider;
}
@Override
public BaseUserDto handle(FacebookLoginCommand command) {
User user = oAuth2Service.registerAuthenticate(command.getAccessCode());
Session session = new Session(
sessionRepository.nextIdentity(),
user,tokenProvider,
command.getRememberMe(),
command.getUserAgent(), command.getIpAddress());
sessionRepository.save(session);
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/GoogleLoginCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.authentication.command.GoogleLoginCommand;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.users.dto.BaseUserDto;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Service;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionRepository;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import com.tomo.mcauthentication.domain.users.User;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class GoogleLoginCommandHandler extends BaseLoginCommandHandler implements CommandHandler<GoogleLoginCommand, BaseUserDto> {
OAuth2Service oAuth2Service;
public GoogleLoginCommandHandler(
@Qualifier("googleOAuth2Service") OAuth2Service oAuth2Service,
@Qualifier("jwtTokenProvider") TokenProvider tokenProvider,
@Qualifier("sessionRepositoryJpaAdapter") SessionRepository sessionRepository,
ModelMapper modelMapper) {
super(modelMapper, sessionRepository, tokenProvider);
this.oAuth2Service = oAuth2Service;
this.tokenProvider = tokenProvider;
}
@Override
public BaseUserDto handle(GoogleLoginCommand command) {
User user = oAuth2Service.registerAuthenticate(command.getAccessCode());
Session session = new Session(
sessionRepository.nextIdentity(),
user,tokenProvider,
command.getRememberMe(),
command.getUserAgent(), command.getIpAddress());
sessionRepository.save(session);
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/LogoutCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.authentication.command.LogoutCommand;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.domain.session.SessionAuthenticationService;
import org.springframework.stereotype.Service;
@Service
public class LogoutCommandHandler extends AbstractVoidyCommandHandler<LogoutCommand> {
SessionAuthenticationService sessionAuthenticationService;
public LogoutCommandHandler(SessionAuthenticationService sessionAuthenticationService) {
this.sessionAuthenticationService = sessionAuthenticationService;
}
@Override
protected void abstractHandle(LogoutCommand aCommand) {
sessionAuthenticationService.logout(aCommand.getAuthToken());
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/SessionAuthenticationCommandHandler.java
================================================
package com.tomo.mcauthentication.application.authentication;
import com.tomo.mcauthentication.application.BaseMapper;
import com.tomo.mcauthentication.application.authentication.command.SessionAuthenticationCommand;
import com.tomo.mcauthentication.application.authentication.dto.SessionDto;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionAuthenticationService;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;
@Service
public class SessionAuthenticationCommandHandler extends BaseMapper implements CommandHandler<SessionAuthenticationCommand, SessionDto> {
SessionAuthenticationService sessionAuthenticationService;
public SessionAuthenticationCommandHandler(
SessionAuthenticationService sessionAuthenticationService,
ModelMapper modelMapper) {
super(modelMapper);
this.sessionAuthenticationService = sessionAuthenticationService;
}
@Override
public SessionDto handle(SessionAuthenticationCommand command) {
Session session = sessionAuthenticationService.authenticate(command.getAuthToken());
return SessionDto.create(session, this.modelMapper);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/BaseLoginCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BaseLoginCommand extends BaseCommand {
private Boolean rememberMe;
private String userAgent;
private String ipAddress;
public BaseLoginCommand() {
super();
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/EmailLoginCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class EmailLoginCommand extends BaseLoginCommand {
@NotBlank
@Email
private String email;
@NotBlank
private String password;
private Boolean rememberMe;
private String userAgent;
private String ipAddress;
public EmailLoginCommand() {
super();
}
public EmailLoginCommand(String email, String password) {
super();
this.email = email;
this.password = password;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/FacebookLoginCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
public class FacebookLoginCommand extends BaseLoginCommand {
private String accessCode;
public FacebookLoginCommand(String accessCode) {
this.accessCode = accessCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/GoogleLoginCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
public class GoogleLoginCommand extends BaseLoginCommand {
private String accessCode;
public GoogleLoginCommand(String accessCode) {
this.accessCode = accessCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/LogoutCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import com.tomo.mcauthentication.application.contracts.security.AbstractAuthenticateCommand;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
public class LogoutCommand extends AbstractAuthenticateCommand {
public LogoutCommand(String authToken) {
super(authToken);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/SessionAuthenticationCommand.java
================================================
package com.tomo.mcauthentication.application.authentication.command;
import com.tomo.mcauthentication.application.contracts.security.AbstractAuthenticateCommand;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SessionAuthenticationCommand extends AbstractAuthenticateCommand {
public SessionAuthenticationCommand(String authToken) {
super(authToken);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/dto/RecoveryPasswordDto.java
================================================
package com.tomo.mcauthentication.application.authentication.dto;
import com.tomo.mcauthentication.application.contracts.Response;
import lombok.Getter;
@Getter
public class RecoveryPasswordDto implements Response {
String recoveryCode;
public RecoveryPasswordDto(String recoveryCode) {
this.recoveryCode = recoveryCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/dto/SessionDto.java
================================================
package com.tomo.mcauthentication.application.authentication.dto;
import com.tomo.mcauthentication.application.users.dto.BaseUserDto;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionId;
import com.tomo.mcauthentication.domain.users.UserId;
import org.modelmapper.ModelMapper;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SessionDto extends BaseUserDto {
private String sessionId;
private String accessToken;
private LocalDateTime expirationDate;
int expirationDateMilis;
private String tokenType;
private String refreshToken;
private String userAgent;
private String ipAddress;
private LocalDateTime lastActivity;
private String userId;
public static SessionDto create(Session session, ModelMapper mapper) {
SessionDto dto = mapper.map(session, SessionDto.class);
dto.setTokenType(session.getTokenType());
dto.setUserId(session.getUserId());
return dto;
}
public void setSessionId(SessionId sessionId) {
this.sessionId = sessionId.toString();
}
public void setTokenType(Session.TokenType tokenType) {
this.tokenType = tokenType.toString();
}
public void setUserId(UserId userId) {
this.userId = userId.id().toString();
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/AbstractVoidyCommandHandler.java
================================================
package com.tomo.mcauthentication.application.configuration;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Voidy;
import javax.transaction.Transactional;
public abstract class AbstractVoidyCommandHandler<T extends Command> implements CommandHandler<T, Voidy> {
@Override
@Transactional
public Voidy handle(T aCommand) {
abstractHandle(aCommand);
return new Voidy();
}
abstract protected void abstractHandle(T aCommand);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/CommandHandler.java
================================================
package com.tomo.mcauthentication.application.configuration;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Response;
public interface CommandHandler<T extends Command, R extends Response> extends RequestHandler {
R handle(T aCommand);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/QueryHandler.java
================================================
package com.tomo.mcauthentication.application.configuration;
import com.tomo.mcauthentication.application.contracts.Query;
import com.tomo.mcauthentication.application.contracts.Response;
public interface QueryHandler<T extends Query, R extends Response> extends RequestHandler {
R handle(T query);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/RequestHandler.java
================================================
package com.tomo.mcauthentication.application.configuration;
import com.tomo.mcauthentication.application.contracts.Request;
import com.tomo.mcauthentication.application.contracts.Response;
public interface RequestHandler<T extends Request, R extends Response> {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseCommand.java
================================================
package com.tomo.mcauthentication.application.contracts;
public class BaseCommand extends BaseRequest implements Command {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseQuery.java
================================================
package com.tomo.mcauthentication.application.contracts;
public class BaseQuery extends BaseRequest implements Query {}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseRequest.java
================================================
package com.tomo.mcauthentication.application.contracts;
import java.util.UUID;
public class BaseRequest implements Request {
private UUID id;
public BaseRequest() {
setId(UUID.randomUUID());
}
public BaseRequest(UUID anId) {
this.id = anId;
}
@Override
public UUID id() {
return this.id;
}
protected void setId(UUID anId) {
this.id = anId;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Command.java
================================================
package com.tomo.mcauthentication.application.contracts;
public interface Command extends Request {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Identifiable.java
================================================
package com.tomo.mcauthentication.application.contracts;
import java.util.UUID;
public interface Identifiable {
UUID id();
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/McAuthenticationModule.java
================================================
package com.tomo.mcauthentication.application.contracts;
import org.springframework.stereotype.Component;
@Component
public interface McAuthenticationModule {
Response executeCommand(Command command);
Response executeQuery(Query query);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Query.java
================================================
package com.tomo.mcauthentication.application.contracts;
public interface Query extends Request {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Request.java
================================================
package com.tomo.mcauthentication.application.contracts;
public interface Request extends Identifiable {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Response.java
================================================
package com.tomo.mcauthentication.application.contracts;
public interface Response {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Voidy.java
================================================
package com.tomo.mcauthentication.application.contracts;
public class Voidy implements Response {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateCommand.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.Command;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthenticateCommand extends AbstractAuthenticateRequest implements Command {
public AbstractAuthenticateCommand(String authToken) {
super(authToken);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateQuery.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.BaseRequest;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Query;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthenticateQuery extends AbstractAuthenticateRequest implements Query {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateRequest.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.BaseRequest;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Request;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthenticateRequest extends BaseRequest implements Authenticate, Request {
String authToken;
public AbstractAuthenticateRequest(String authToken) {
this.authToken = authToken;
}
@Override
public String authToken() {
return this.authToken;
}
@Override
public void setAuthToken(String authToken) {
this.authToken = authToken;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeCommand.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.Command;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthorizeCommand extends AbstractAuthorizeRequest implements Command {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeQuery.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Query;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthorizeQuery extends AbstractAuthorizeRequest implements Query {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeRequest.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Request;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractAuthorizeRequest extends AbstractAuthenticateRequest implements Request, Authorize {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/Authenticate.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
public interface Authenticate {
String authToken();
void setAuthToken(String authToken);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/Authorize.java
================================================
package com.tomo.mcauthentication.application.contracts.security;
import java.util.List;
public interface Authorize extends Authenticate {
default List<String> getAuthorities() {
return List.of("USER");
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/CreatePasswordRecoveryCodeCommandHandler.java
================================================
package com.tomo.mcauthentication.application.recovery;
import com.tomo.mcauthentication.application.recovery.command.CreatePasswordRecoveryCodeCommand;
import com.tomo.mcauthentication.application.authentication.dto.RecoveryPasswordDto;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.domain.registration.EmailAuthenticationService;
import org.springframework.stereotype.Service;
@Service
public class CreatePasswordRecoveryCodeCommandHandler implements CommandHandler<CreatePasswordRecoveryCodeCommand, RecoveryPasswordDto> {
EmailAuthenticationService emailAuthenticationService;
public CreatePasswordRecoveryCodeCommandHandler(EmailAuthenticationService emailAuthenticationService) {
this.emailAuthenticationService = emailAuthenticationService;
}
@Override
public RecoveryPasswordDto handle(CreatePasswordRecoveryCodeCommand aCommand) {
return new RecoveryPasswordDto(
emailAuthenticationService
.createPasswordRecoveryCode(aCommand.getEmail())
);
//todo send recovery code
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/GetUserRegistrationWithRecoveryCodeQueryHandler.java
================================================
package com.tomo.mcauthentication.application.recovery;
import com.tomo.mcauthentication.application.BaseMapper;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.registration.dto.UserRegistrationDto;
import com.tomo.mcauthentication.application.recovery.dto.GetUserRegistrationWithRecoveryCodeQuery;
import com.tomo.mcauthentication.domain.EncryptionService;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Component;
@Component
public class GetUserRegistrationWithRecoveryCodeQueryHandler extends BaseMapper implements QueryHandler<GetUserRegistrationWithRecoveryCodeQuery, UserRegistrationDto> {
private UserRegistrationRepository userRegistrationRepository;
private EncryptionService encryptionService;
public GetUserRegistrationWithRecoveryCodeQueryHandler(
UserRegistrationRepository aUserRegistrationRepository,
EncryptionService anEncryptionService,
ModelMapper modelMapper) {
super(modelMapper);
this.userRegistrationRepository = aUserRegistrationRepository;
this.encryptionService = anEncryptionService;
}
@Override
public UserRegistrationDto handle(GetUserRegistrationWithRecoveryCodeQuery query) {
UserRegistration userRegistration = userRegistrationRepository
.findByRecoveryCode(encryptionService.encryptedValue(query.getRecoveryCode()));
if (userRegistration == null) {
throw new IllegalStateException(String.format("User with recovery code %s doesn't exists.", query.getRecoveryCode()));
}
UserRegistrationDto dto = toDto(
userRegistration,
UserRegistrationDto.class
);
return dto;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/PasswordRecoveryCodeCreatedEventHandler.java
================================================
package com.tomo.mcauthentication.application.recovery;
import com.tomo.mcauthentication.application.contracts.McAuthenticationModule;
import com.tomo.mcauthentication.application.recovery.command.SendPasswordRecoveryEmailCommand;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.ddd.domain.DomainEventSubscriber;
import com.tomo.mcauthentication.domain.registration.events.PasswordRecoveryCodeCreated;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class PasswordRecoveryCodeCreatedEventHandler {
private McAuthenticationModule module;
/**
* In order to not mix business logic with plugins like a GUI..
* baseUrl + URI + queryString eg. localhost/reset-passwrod/?recoveryCode=
*/
private String recoveryLink;
public PasswordRecoveryCodeCreatedEventHandler(McAuthenticationModule authenticationModule, String recoveryLink) {
this.module = authenticationModule;
this.recoveryLink = recoveryLink;
}
@Before("execution(" +
"public * com.tomo.mcauthentication.application.configuration.CommandHandler.*(..)) && " +
"target(com.tomo.mcauthentication.application.recovery.CreatePasswordRecoveryCodeCommandHandler))")
public void listen() {
DomainEventPublisher
.instance()
.subscribe(new DomainEventSubscriber<PasswordRecoveryCodeCreated>() {
public void handleEvent(PasswordRecoveryCodeCreated aDomainEvent) {
module.executeCommand(new SendPasswordRecoveryEmailCommand(
aDomainEvent.getEmail(),
aDomainEvent.getRecoveryCode(),
recoveryLink,
aDomainEvent.getRecoveryCodeExpirationDate()));
}
public Class<PasswordRecoveryCodeCreated> subscribedToEventType() {
return PasswordRecoveryCodeCreated.class;
}
});
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/SendPasswordRecoveryEmailCommandHandler.java
================================================
package com.tomo.mcauthentication.application.recovery;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.recovery.command.SendPasswordRecoveryEmailCommand;
import com.tomo.ddd.email.EmailSender;
import com.tomo.ddd.port.adapter.message.email.EmailMessage;
import org.springframework.stereotype.Component;
@Component
public class SendPasswordRecoveryEmailCommandHandler extends AbstractVoidyCommandHandler<SendPasswordRecoveryEmailCommand> {
EmailSender emailMessageSender;
public SendPasswordRecoveryEmailCommandHandler(EmailSender emailMessageSender) {
this.emailMessageSender = emailMessageSender;
}
@Override
protected void abstractHandle(SendPasswordRecoveryEmailCommand aCommand) {
//todo maybe validate if exist
this.emailMessageSender.send(new EmailMessage(
aCommand.getEmail(), ""
, " Recovery code",
"To reset your password, visit the following link: " + aCommand.getRecoveryLink() + aCommand.getRecoveryCode()));
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/UpdatePasswordWithRecoveryCodeCommandHandler.java
================================================
package com.tomo.mcauthentication.application.recovery;
import com.tomo.mcauthentication.application.recovery.command.UpdatePasswordWithRecoveryCodeCommand;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.domain.registration.EmailAuthenticationService;
import org.springframework.stereotype.Service;
@Service
public class UpdatePasswordWithRecoveryCodeCommandHandler extends AbstractVoidyCommandHandler<UpdatePasswordWithRecoveryCodeCommand> {
EmailAuthenticationService emailAuthenticationService;
public UpdatePasswordWithRecoveryCodeCommandHandler(EmailAuthenticationService emailAuthenticationService) {
this.emailAuthenticationService = emailAuthenticationService;
}
@Override
protected void abstractHandle(UpdatePasswordWithRecoveryCodeCommand aCommand) {
emailAuthenticationService.recoverPasswordWithRecoveryCode(
aCommand.getRecoveryCode(),
aCommand.getNewPassword(),
aCommand.getNewPasswordRepeated());
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/CreatePasswordRecoveryCodeCommand.java
================================================
package com.tomo.mcauthentication.application.recovery.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class CreatePasswordRecoveryCodeCommand extends BaseCommand {
@NotNull
private String email;
public CreatePasswordRecoveryCodeCommand(String email) {
this.email = email;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/SendPasswordRecoveryEmailCommand.java
================================================
package com.tomo.mcauthentication.application.recovery.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SendPasswordRecoveryEmailCommand extends BaseCommand {
String email;
String recoveryCode;
String recoveryLink;
LocalDateTime recoveryCodeExpirationDate;
public SendPasswordRecoveryEmailCommand(String email, String recoveryCode, String recoveryLink, LocalDateTime recoveryCodeExpirationDate) {
this.email = email;
this.recoveryCode = recoveryCode;
this.recoveryLink = recoveryLink;
this.recoveryCodeExpirationDate = recoveryCodeExpirationDate;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/UpdatePasswordWithRecoveryCodeCommand.java
================================================
package com.tomo.mcauthentication.application.recovery.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UpdatePasswordWithRecoveryCodeCommand extends BaseCommand {
@NotNull
private String newPassword;
@NotNull
private String newPasswordRepeated;
@NotNull
private String recoveryCode;
public UpdatePasswordWithRecoveryCodeCommand(String newPassword, String newPasswordRepeated, String recoveryCode) {
this.newPassword = newPassword;
this.newPasswordRepeated = newPasswordRepeated;
this.recoveryCode = recoveryCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/dto/GetUserRegistrationWithRecoveryCodeQuery.java
================================================
package com.tomo.mcauthentication.application.recovery.dto;
import com.tomo.mcauthentication.application.contracts.BaseQuery;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class GetUserRegistrationWithRecoveryCodeQuery extends BaseQuery {
@NotNull
String recoveryCode;
public GetUserRegistrationWithRecoveryCodeQuery(String recoveryCode) {
this.recoveryCode = recoveryCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/ChangePasswordCommandHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.registration.command.ChangePasswordCommand;
import com.tomo.mcauthentication.domain.registration.EmailAuthenticationService;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionAuthenticationService;
import org.springframework.stereotype.Service;
@Service
public class ChangePasswordCommandHandler extends AbstractVoidyCommandHandler<ChangePasswordCommand> {
EmailAuthenticationService emailAuthenticationService;
SessionAuthenticationService sessionAuthenticationService;
UserRegistrationRepository userRegistrationRepository;
public ChangePasswordCommandHandler(
EmailAuthenticationService emailAuthenticationService,
SessionAuthenticationService aSessionAuthenticationService,
UserRegistrationRepository anUserRegistrationRepository) {
this.emailAuthenticationService = emailAuthenticationService;
this.sessionAuthenticationService = aSessionAuthenticationService;
this.userRegistrationRepository = anUserRegistrationRepository;
}
@Override
protected void abstractHandle(ChangePasswordCommand aCommand) {
Session session = sessionAuthenticationService.authenticate(aCommand.getAccessToken());
UserRegistration userRegistration = userRegistrationRepository.findByUserId(session.getUserId());
if (userRegistration == null) {
throw new IllegalStateException(String.format("User with id %s doesn't exist.", session.getUserId().id()));
}
userRegistration.changePassword(aCommand.getOldPassword(), aCommand.getNewPassword(), aCommand.getNewPasswordRepeated());
userRegistrationRepository.save(userRegistration);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/ConfirmUserRegistrationCommandHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.registration.command.ConfirmUserRegistrationCommand;
import com.tomo.mcauthentication.application.users.dto.BaseUserDto;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.stereotype.Component;
@Component
public class ConfirmUserRegistrationCommandHandler implements CommandHandler<ConfirmUserRegistrationCommand, BaseUserDto> {
UserRegistrationRepository userRegistrationRepository;
UserRepository userRepository;
public ConfirmUserRegistrationCommandHandler(
UserRegistrationRepository userRegistrationRepository,
UserRepository userRepository) {
this.userRegistrationRepository = userRegistrationRepository;
this.userRepository = userRepository;
}
@Override
public BaseUserDto handle(ConfirmUserRegistrationCommand command) {
UserRegistration userRegistration = userRegistrationRepository.findByConfirmationCode(command.getConfirmationLink());
if (userRegistration == null) {
throw new IllegalStateException(
String.format("UserRegistration with confirmation link %s cannot be found.", command.getConfirmationLink())
);
}
User user = userRegistration.createUser(userRepository);
userRegistration.setUserId(user.getUserId());
userRepository.save(user);
userRegistrationRepository.save(userRegistration);
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/GetUserRegistrationQueryHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.registration.dto.UserRegistrationDto;
import com.tomo.mcauthentication.application.registration.query.GetUserRegistrationQuery;
public class GetUserRegistrationQueryHandler implements QueryHandler<GetUserRegistrationQuery, UserRegistrationDto> {
@Override public UserRegistrationDto handle(GetUserRegistrationQuery request) {
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/NewUserRegisteredEventHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.contracts.McAuthenticationModule;
import com.tomo.mcauthentication.application.registration.command.SendRegistrationConfirmationEmailCommand;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.ddd.domain.DomainEventSubscriber;
import com.tomo.mcauthentication.domain.registration.events.UserRegistrationRequested;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class NewUserRegisteredEventHandler {
private McAuthenticationModule authenticationModule;
/**
* In order to not mix business logic with plugins like a GUI..
* baseUrl + URI + queryString eg. localhost/register/confirm/?confirmationCode=
*/
private String confirmationLink;
public NewUserRegisteredEventHandler(McAuthenticationModule authenticationModule, String confirmationLink) {
this.authenticationModule = authenticationModule;
this.confirmationLink = confirmationLink;
}
@Before(value = "execution(public * com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler.*(..)) && target(com.tomo.mcauthentication.application.registration.RegisterNewUserCommandHandler))")
public void listen() {
DomainEventPublisher
.instance()
.subscribe(new DomainEventSubscriber<UserRegistrationRequested>() {
public void handleEvent(UserRegistrationRequested aDomainEvent) {
authenticationModule.executeCommand(new SendRegistrationConfirmationEmailCommand(
aDomainEvent.getEmail(),
confirmationLink,
aDomainEvent.getConfirmationCode()));
}
public Class<UserRegistrationRequested> subscribedToEventType() {
return UserRegistrationRequested.class; // all domain events
}
});
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/RegisterNewUserCommandHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.registration.command.RegisterNewUserCommand;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.stereotype.Component;
@Component
public class RegisterNewUserCommandHandler extends AbstractVoidyCommandHandler<RegisterNewUserCommand> {
UserRegistrationRepository userRegistrationRepository;
UserRepository userRepository;
public RegisterNewUserCommandHandler(
UserRegistrationRepository userRegistrationRepository,
UserRepository userRepository) {
this.userRegistrationRepository = userRegistrationRepository;
this.userRepository = userRepository;
}
@Override
protected void abstractHandle(RegisterNewUserCommand aCommand) {
UserRegistration userRegistration = UserRegistration.registerNewUser(
aCommand.getPassword(),
aCommand.getEmail(),
aCommand.getFirstName(),
aCommand.getLastName()
);
userRegistrationRepository.save(userRegistration);
//todo send email
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/SendRegistrationConfirmationEmailCommandHandler.java
================================================
package com.tomo.mcauthentication.application.registration;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.registration.command.SendRegistrationConfirmationEmailCommand;
import com.tomo.ddd.email.EmailSender;
import com.tomo.ddd.port.adapter.message.email.EmailMessage;
import org.springframework.stereotype.Component;
@Component
public class SendRegistrationConfirmationEmailCommandHandler extends AbstractVoidyCommandHandler<SendRegistrationConfirmationEmailCommand> {
EmailSender emailMessageSender;
public SendRegistrationConfirmationEmailCommandHandler(EmailSender emailMessageSender) {
this.emailMessageSender = emailMessageSender;
}
@Override
protected void abstractHandle(SendRegistrationConfirmationEmailCommand aCommand) {
//todo maybe validate if exist
this.emailMessageSender.send(new EmailMessage(
aCommand.getEmail(), ""
, "Confirm registration",
"Click on this confirmation link " + aCommand.getConfirmLink() + aCommand.getConfirmationCode()));
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/ChangePasswordCommand.java
================================================
package com.tomo.mcauthentication.application.registration.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class ChangePasswordCommand extends BaseCommand {
String accessToken;
@NotNull
private String oldPassword;
@NotNull
private String newPassword;
@NotNull
private String newPasswordRepeated;
public ChangePasswordCommand(String accessToken, String oldPassword, String newPassword, String newPasswordRepeated) {
this.accessToken = accessToken;
this.oldPassword = oldPassword;
this.newPassword = newPassword;
this.newPasswordRepeated = newPasswordRepeated;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/ConfirmUserRegistrationCommand.java
================================================
package com.tomo.mcauthentication.application.registration.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter
@Getter
@NoArgsConstructor
public class ConfirmUserRegistrationCommand extends BaseCommand {
private String confirmationLink;
public ConfirmUserRegistrationCommand(String confirmLink) {
this.confirmationLink = confirmLink;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/RegisterNewUserCommand.java
================================================
package com.tomo.mcauthentication.application.registration.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import javax.validation.constraints.NotNull;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class RegisterNewUserCommand extends BaseCommand {
@NotNull
String firstName;
@NotNull
String lastName;
@NotNull
String email;
@NotNull
String password;
public RegisterNewUserCommand(String firstName, String lastName, String email, String password) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.password = password;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/SendRegistrationConfirmationEmailCommand.java
================================================
package com.tomo.mcauthentication.application.registration.command;
import com.tomo.mcauthentication.application.contracts.BaseCommand;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SendRegistrationConfirmationEmailCommand extends BaseCommand {
String email;
String confirmLink;
String confirmationCode;
public SendRegistrationConfirmationEmailCommand(String email, String confirmLink, String confirmationCode) {
this.email = email;
this.confirmLink = confirmLink;
this.confirmationCode = confirmationCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/dto/UserRegistrationDto.java
================================================
package com.tomo.mcauthentication.application.registration.dto;
import com.tomo.mcauthentication.application.contracts.Response;
import com.tomo.mcauthentication.domain.registration.UserRegistrationId;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserRegistrationDto implements Response {
private String email;
private String firstName;
private String lastName;
private LocalDateTime registerDate;
private UserRegistrationStatus status;
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/registration/query/GetUserRegistrationQuery.java
================================================
package com.tomo.mcauthentication.application.registration.query;
import com.tomo.mcauthentication.application.contracts.BaseQuery;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class GetUserRegistrationQuery extends BaseQuery {
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/users/ChangeUserDetailsCommandHandler.java
================================================
package com.tomo.mcauthentication.application.users;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.users.command.ChangeUserDetailsCommand;
import com.tomo.mcauthentication.domain.registration.EmailAuthenticationService;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
@Service
@AllArgsConstructor
public class ChangeUserDetailsCommandHandler extends AbstractVoidyCommandHandler<ChangeUserDetailsCommand> {
EmailAuthenticationService emailAuthenticationService;
TokenProvider tokenProvider;
UserRepository userRepository;
@Override
public void abstractHandle(ChangeUserDetailsCommand aCommand) {
UserId userId = tokenProvider.getUserIdFromToken(aCommand.getAuthToken());
if (!aCommand.getUserId().equals(userId.id())) {
throw new IllegalArgumentException(String.format("Forbidden access. User with ID %s cannot change user details for user with ID: %s", userId.id(), aCommand.getUserId()));
}
User user = userRepository.findById(new UserId(aCommand.getUserId()));
user.updateDetails(aCommand.getFirstName(), aCommand.getLastName());
userRepository.save(user);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/users/GetUserQueryHandler.java
================================================
package com.tomo.mcauthentication.application.users;
import com.tomo.mcauthentication.application.BaseMapper;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.users.dto.BaseUserDto;
import com.tomo.mcauthentication.application.users.query.GetUserQuery;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Component;
@Component
public class GetUserQueryHandler extends BaseMapper implements QueryHandler<GetUserQuery, BaseUserDto> {
private UserRepository userRepository;
public GetUserQueryHandler(
UserRepository userRepository,
ModelMapper modelMapper) {
super(modelMapper);
this.userRepository = userRepository;
}
@Override
public BaseUserDto handle(GetUserQuery query) {
User user = userRepository.findById(query.getUserId());
if (user == null) {
throw new IllegalStateException(String.format("User with id %s doesn't exists.", query.getUserId().toString()));
}
return toDto(user);
}
private BaseUserDto toDto(User user) {
return modelMapper.map(user, BaseUserDto.class);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/users/command/ChangeUserDetailsCommand.java
================================================
package com.tomo.mcauthentication.application.users.command;
import com.tomo.mcauthentication.application.contracts.security.AbstractAuthorizeCommand;
import java.util.List;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class ChangeUserDetailsCommand extends AbstractAuthorizeCommand {
private UUID userId;
private String firstName;
private String lastName;
public ChangeUserDetailsCommand(UUID userId, String firstName, String lastName) {
this.userId = userId;
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public List<String> getAuthorities() {
List<String> authorities = super.getAuthorities();
authorities.add("ADMIN");
return authorities;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/users/dto/BaseUserDto.java
================================================
package com.tomo.mcauthentication.application.users.dto;
import com.tomo.mcauthentication.application.contracts.Response;
import com.tomo.mcauthentication.domain.users.UserId;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class BaseUserDto implements Response {
private String userId;
String firstName;
String lastName;
public void setUserId(UserId userId) {
this.userId = userId.id().toString();
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/application/users/query/GetUserQuery.java
================================================
package com.tomo.mcauthentication.application.users.query;
import com.tomo.mcauthentication.application.contracts.security.AbstractAuthenticateQuery;
import com.tomo.mcauthentication.domain.users.UserId;
import javax.validation.constraints.NotNull;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class GetUserQuery extends AbstractAuthenticateQuery {
@NotNull
String userId;
public GetUserQuery(String userId) {
this.userId = userId;
}
public UserId getUserId() {
return new UserId(UUID.fromString(this.userId));
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/DomainRegistry.java
================================================
package com.tomo.mcauthentication.domain;
import com.tomo.mcauthentication.domain.registration.PasswordService;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.registration.rules.UserRegistrationMustBeUnique;
import com.tomo.mcauthentication.domain.session.TokenProvider;
import com.tomo.mcauthentication.domain.users.UserRepository;
import com.tomo.mcauthentication.domain.users.rules.UserEmailMustBeUnique;
import org.modelmapper.ModelMapper;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class DomainRegistry implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public static EncryptionService encryptionService() {
return (EncryptionService) applicationContext.getBean("MD5EncryptionService");
}
public static PasswordService passwordService() {
return (PasswordService) applicationContext.getBean("passwordService");
}
public static TokenProvider tokenProvider() {
return (TokenProvider) applicationContext.getBean("jwtTokenProvider");
}
public static ModelMapper modelMapper() {
return (ModelMapper) applicationContext.getBean("modelMapper");
}
public static UserRepository userRepository() {
return (UserRepository) applicationContext.getBean("userRepository");
}
public static UserRegistrationRepository userRegistrationRepository() {
return (UserRegistrationRepository) applicationContext.getBean("userRegistrationRepository");
}
public static UserEmailMustBeUnique userEmailMustBeUnique(String anEmail) {
return new UserEmailMustBeUnique(userRepository(), anEmail);
}
public static UserRegistrationMustBeUnique userRegistrationMustBeUnique(String anEmail) {
return new UserRegistrationMustBeUnique(userRegistrationRepository(), anEmail);
}
@Override
public void setApplicationContext(ApplicationContext anApplicationContext) throws BeansException {
// if (DomainRegistry.applicationContext == null) {
// DomainRegistry.applicationContext = anApplicationContext;
// }
DomainRegistry.applicationContext = anApplicationContext;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/EncryptionService.java
================================================
package com.tomo.mcauthentication.domain;
public interface EncryptionService {
String encryptedValue(String aPlainTextValue);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Authentication.java
================================================
package com.tomo.mcauthentication.domain.oauth2;
public interface OAuth2Authentication {
OAuth2Principal authenticate(String anAccessCode);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Principal.java
================================================
package com.tomo.mcauthentication.domain.oauth2;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
public class OAuth2Principal {
private String id;
private String email;
private String firstName;
private String lastName;
private String imageUrl;
private String provider;
public OAuth2Principal(String id, String email, String firstName, String lastName, String imageUrl, String provider) {
this.id = id;
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
this.imageUrl = imageUrl;
this.provider = provider;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Service.java
================================================
package com.tomo.mcauthentication.domain.oauth2;
import com.tomo.ddd.domain.BusinessRuleValidationException;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserRepository;
import com.tomo.mcauthentication.domain.users.rules.UserEmailMustBeUnique;
public class OAuth2Service {
private OAuth2Authentication oAuth2Authentication;
private UserRepository userRespository;
public OAuth2Service(OAuth2Authentication oAuth2Authentication, UserRepository userRespository) {
this.oAuth2Authentication = oAuth2Authentication;
this.userRespository = userRespository;
}
public User registerAuthenticate(String anAccessCode) {
OAuth2Principal principal = oAuth2Authentication.authenticate(anAccessCode);
User user;
try {
user = authenticateAndRegister(principal);
} catch (BusinessRuleValidationException exception) {
if (UserEmailMustBeUnique.class == exception.getBrokenRule().getClass()) {
user = userRespository.findByEmail(principal.getEmail());
if (!User.AuthProvider.valueOf(principal.getProvider()).equals(user.getProvider())) {
throw exception;
}
} else {
throw exception;
}
}
return user;
}
protected User authenticateAndRegister(OAuth2Principal principal) {
User user = new User(
userRespository.nextIdentity(),
principal.getFirstName(),
principal.getLastName(),
principal.getEmail(),
User.AuthProvider.valueOf(principal.getProvider()));
return userRespository.save(user);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/EmailAuthenticationService.java
================================================
package com.tomo.mcauthentication.domain.registration;
import com.tomo.ddd.domain.BusinessRuleValidator;
import com.tomo.mcauthentication.domain.EncryptionService;
import com.tomo.mcauthentication.domain.registration.rules.PasswordsMustMatch;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.stereotype.Service;
@Service
public class EmailAuthenticationService extends BusinessRuleValidator {
UserRegistrationRepository userRegistrationRepository;
UserRepository userRepository;
EncryptionService encryptionService;
public EmailAuthenticationService(
UserRegistrationRepository userRegistrationRepository,
UserRepository userRepository,
EncryptionService encryptionService) {
this.userRegistrationRepository = userRegistrationRepository;
this.userRepository = userRepository;
this.encryptionService = encryptionService;
}
public User authenticate(
String anEmail,
String aPassword) {
this.assertArgumentNotEmpty(anEmail, "Email must be provided.");
this.assertArgumentNotEmpty(aPassword, "Password must be provided.");
UserRegistration userRegistration = userRegistrationRepository.findByEmail(anEmail);
if (userRegistration == null) {
throw new IllegalStateException(String.format("User with email %s doesn't exists.", anEmail));
}
this.checkRule(new PasswordsMustMatch(userRegistration.getPassword(), encryptionService.encryptedValue(aPassword)));
return userRepository.findByEmail(anEmail);
}
public String createPasswordRecoveryCode(String anEmail) {
this.assertArgumentNotEmpty(anEmail, "Email must be provided.");
UserRegistration userRegistration = userRegistrationRepository.findByEmail(anEmail);
if (userRegistration == null) {
throw new IllegalStateException(String.format("User with email %s doesn't exists.", anEmail));
}
return userRegistration.createRecoveryCode();
}
public void recoverPasswordWithRecoveryCode(String aRecoveryCode, String aNewPassword, String aNewPasswordRepeated) {
this.assertArgumentNotNull(aRecoveryCode, "Recovery code is missing.");
UserRegistration userRegistration = userRegistrationRepository
.findByRecoveryCode(encryptionService.encryptedValue(aRecoveryCode));
if (userRegistration == null) {
throw new IllegalStateException(String.format("User with recovery code %s doesn't exists.", aRecoveryCode));
}
userRegistration.changePasswordWithRecoveryCode(aRecoveryCode, aNewPassword, aNewPasswordRepeated);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/PasswordService.java
================================================
package com.tomo.mcauthentication.domain.registration;
import com.tomo.ddd.AssertionConcern;
import org.springframework.stereotype.Component;
import java.util.Random;
@Component
public final class PasswordService extends AssertionConcern {
private static final String DIGITS = "0123456789";
private static final String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final int STRONG_THRESHOLD = 20;
private static final String SYMBOLS = "\"`!?$?%^&*()_-+={[}]:;@'~#|\\<,>.?/";
private static final int VERY_STRONG_THRESHOLD = 40;
public PasswordService() {
super();
}
public String generateStrongPassword() {
String generatedPassword = null;
StringBuffer password = new StringBuffer();
Random random = new Random();
boolean isStrong = false;
int index = 0;
while (!isStrong) {
int opt = random.nextInt(4);
switch (opt) {
case 0:
index = random.nextInt(LETTERS.length());
password.append(LETTERS.substring(index, index+1));
break;
case 1:
index = random.nextInt(LETTERS.length());
password.append(LETTERS.substring(index, index+1).toLowerCase());
break;
case 2:
index = random.nextInt(DIGITS.length());
password.append(DIGITS.substring(index, index+1));
break;
case 3:
index = random.nextInt(SYMBOLS.length());
password.append(SYMBOLS.substring(index, index+1));
break;
}
generatedPassword = password.toString();
if (generatedPassword.length() >= 7) {
isStrong = this.isStrong(generatedPassword);
}
}
return generatedPassword;
}
public boolean isStrong(String aPlainTextPassword) {
return this.calculatePasswordStrength(aPlainTextPassword) >= STRONG_THRESHOLD;
}
public boolean isVeryStrong(String aPlainTextPassword) {
return this.calculatePasswordStrength(aPlainTextPassword) >= VERY_STRONG_THRESHOLD;
}
public boolean isWeak(String aPlainTextPassword) {
return this.calculatePasswordStrength(aPlainTextPassword) < STRONG_THRESHOLD;
}
private int calculatePasswordStrength(String aPlainTextPassword) {
this.assertArgumentNotNull(aPlainTextPassword, "Password strength cannot be tested on null.");
int strength = 0;
int length = aPlainTextPassword.length();
if (length > 7) {
strength += 10;
// bonus: one point each additional
strength += (length - 7);
}
int digitCount = 0;
int letterCount = 0;
int lowerCount = 0;
int upperCount = 0;
int symbolCount = 0;
for (int idx = 0; idx < length; ++idx) {
char ch = aPlainTextPassword.charAt(idx);
if (Character.isLetter(ch)) {
++letterCount;
if (Character.isUpperCase(ch)) {
++upperCount;
} else {
++lowerCount;
}
} else if (Character.isDigit(ch)) {
++digitCount;
} else {
++symbolCount;
}
}
strength += (upperCount + lowerCount + symbolCount);
// bonus: letters and digits
if (letterCount >= 2 && digitCount >= 2) {
strength += (letterCount + digitCount);
}
return strength;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistration.java
================================================
package com.tomo.mcauthentication.domain.registration;
import com.tomo.ddd.domain.ConcurrencySafeEntity;
import com.tomo.ddd.domain.DomainEvent;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.mcauthentication.domain.DomainRegistry;
import com.tomo.mcauthentication.domain.registration.events.PasswordChanged;
import com.tomo.mcauthentication.domain.registration.events.PasswordRecovered;
import com.tomo.mcauthentication.domain.registration.events.PasswordRecoveryCodeCreated;
import com.tomo.mcauthentication.domain.registration.events.UserRegistrationConfirmed;
import com.tomo.mcauthentication.domain.registration.events.UserRegistrationRequested;
import com.tomo.mcauthentication.domain.registration.rules.PasswordRecoveryCodeShouldBeExpiredOrNull;
import com.tomo.mcauthentication.domain.registration.rules.PasswordRecoveryCodeShouldNotExpired;
import com.tomo.mcauthentication.domain.registration.rules.PasswordsMustMatch;
import com.tomo.mcauthentication.domain.registration.rules.RecoveryCodeMustMatch;
import com.tomo.mcauthentication.domain.registration.rules.UserRegistrationCannotBeConfirmedAfterExpiration;
import com.tomo.mcauthentication.domain.registration.rules.UserRegistrationCannotBeConfirmedMoreThanOnce;
import com.tomo.mcauthentication.domain.registration.rules.UserRegistrationMustBeConfirmed;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import com.tomo.mcauthentication.domain.users.UserRepository;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@NoArgsConstructor
@Getter
@Setter
public class UserRegistration extends ConcurrencySafeEntity {
public static Long RECOVERY_CODE_EXPIREATION_MSEC = 172800000L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String password;
private String email;
private String firstName;
private String lastName;
private String confirmationCode;
private LocalDateTime registerDate;
@Enumerated(EnumType.STRING)
private UserRegistrationStatus status;
private String recoveryCode;
private LocalDateTime recoveryCodeExpirationDate;
@Embedded
@AttributeOverride(name="id", column = @Column(name="user_id"))
private UserId userId;
public static UserRegistration registerNewUser(
String password,
String email,
String firstName,
String lastName)
{
return new UserRegistration(password, email, firstName, lastName);
}
private UserRegistration(
String aPassword,
String anEmail,
String aFirstName,
String aLastName) {
this.checkRule(DomainRegistry.userRegistrationMustBeUnique(anEmail));
this.checkRule(DomainRegistry.userEmailMustBeUnique(anEmail));
this.email = anEmail;
this.firstName = aFirstName;
this.lastName = aLastName;
this.confirmationCode = UUID.randomUUID().toString();
this.registerDate = LocalDateTime.now();
this.status = UserRegistrationStatus.WaitingForConfirmation;
this.protectPassword("", aPassword);
this.publishEvent(new UserRegistrationRequested(
this.email,
this.confirmationCode,
this.firstName,
this.lastName,
this.registerDate,
this.status
));
}
public User createUser(UserRepository userRespository) {
this.checkRule(new UserRegistrationCannotBeConfirmedMoreThanOnce(this.status));
this.checkRule(new UserRegistrationCannotBeConfirmedAfterExpiration(this.registerDate));
this.setStatus(UserRegistrationStatus.Confirmed);
UserId userId = userRespository.nextIdentity();
this.setUserId(userId);
this.publishEvent(new UserRegistrationConfirmed(this.id, this.getStatus(), this.getUserId()));
return new User(userId, getFirstName(), getLastName(), getEmail(), User.AuthProvider.EMAIL);
}
public String createRecoveryCode() {
this.checkRule(new UserRegistrationMustBeConfirmed(this.getStatus()));
this.checkRule(new PasswordRecoveryCodeShouldBeExpiredOrNull(this));
String recoveryCode = UUID.randomUUID().toString();
this.recoveryCodeExpirationDate = LocalDateTime.now().plus(RECOVERY_CODE_EXPIREATION_MSEC, ChronoField.MILLI_OF_DAY.getBaseUnit());
this.setRecoveryCodeExpirationDate(recoveryCodeExpirationDate);
this.setRecoveryCode(this.asEncryptedValue(recoveryCode));
this.publishEvent(new PasswordRecoveryCodeCreated(
this.id,
this.email,
recoveryCode,
this.recoveryCodeExpirationDate));
return recoveryCode;
}
public boolean isRecoveryCodeUnexpired() {
return recoveryCodeExpirationDate != null && recoveryCodeExpirationDate.isAfter(LocalDateTime.now());
}
public boolean isRecoveryCodeExpired() {
return recoveryCodeExpirationDate != null && recoveryCodeExpirationDate.isBefore(LocalDateTime.now());
}
public void changePassword(String anOldPassword, String aNewPassword, String aNewPasswordRepeated) {
this.assertArgumentNotNull(anOldPassword, "Old password is missing.");
this.assertNewPassword(aNewPassword, aNewPasswordRepeated);
this.checkRule(new PasswordsMustMatch(this.getPassword(), this.asEncryptedValue(anOldPassword)));
this.protectPassword(this.getPassword(), aNewPassword);
this.publishEvent(new PasswordChanged(this.id, this.password));
}
public void changePasswordWithRecoveryCode(String aRecoveryCode, String aNewPassword, String aNewPasswordRepeated) {
this.assertArgumentNotNull(aNewPassword, "New password is missing.");
this.assertNewPassword(aNewPassword, aNewPasswordRepeated);
this.checkRule(new RecoveryCodeMustMatch(this.asEncryptedValue(aRecoveryCode), this.getRecoveryCode()));
this.checkRule(new PasswordRecoveryCodeShouldNotExpired(this));
this.protectPassword(this.getPassword(), aNewPassword);
this.setRecoveryCodeExpirationDate(LocalDateTime.now());
this.publishEvent(new PasswordRecovered(
this.id,
this.getPassword(),
this.getRecoveryCode()
));
}
protected void assertNewPassword(String aNewPassword, String aNewPasswordRepeated) {
this.assertArgumentNotNull(aNewPassword, "New password is missing.");
this.assertArgumentNotNull(aNewPasswordRepeated, "Repeated password is missing.");
this.assertArgumentEquals(aNewPassword, aNewPasswordRepeated, "Provided passwords must be equal.");
}
protected void protectPassword(String aCurrentPassword, String aChangedPassword) {
this.assertPasswordsNotSame(aCurrentPassword, this.asEncryptedValue(aChangedPassword));
this.assertPasswordNotWeak(aChangedPassword);
this.assertUsernamePasswordNotSame(aChangedPassword);
this.setPassword(this.asEncryptedValue(aChangedPassword));
}
protected void assertPasswordsNotSame(String aCurrentPassword, String aChangedPassword) {
this.assertArgumentNotEquals(
aCurrentPassword,
aChangedPassword,
"The password is unchanged.");
}
protected void assertPasswordNotWeak(String aPlainTextPassword) {
this.assertArgumentFalse(
DomainRegistry.passwordService().isWeak(aPlainTextPassword),
"The password must be stronger.");
}
protected void assertUsernamePasswordNotSame(String aPlainTextPassword) {
this.assertArgumentNotEquals(
this.getEmail(),
aPlainTextPassword,
"The username and password must not be the same.");
}
protected String asEncryptedValue(String aPlainTextPassword) {
String encryptedValue =
DomainRegistry
.encryptionService()
.encryptedValue(aPlainTextPassword);
return encryptedValue;
}
protected void setPassword(String aPassword) {
this.password = aPassword;
}
private void publishEvent(DomainEvent domainEvent) {
DomainEventPublisher.instance().publish(domainEvent);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationId.java
================================================
package com.tomo.mcauthentication.domain.registration;
import com.tomo.ddd.domain.AbstractId;
import javax.persistence.Embeddable;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Embeddable
@Getter
@Setter
@NoArgsConstructor
public class UserRegistrationId extends AbstractId {
public UserRegistrationId(UUID anId) {
super(anId);
}
@Override
protected int hashPrimeValue() {
return 0;
}
@Override
protected int hashOddValue() {
return 0;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationRepository.java
================================================
package com.tomo.mcauthentication.domain.registration;
import com.tomo.ddd.domain.BaseRepository;
import com.tomo.mcauthentication.domain.users.UserId;
import java.util.List;
public interface UserRegistrationRepository extends BaseRepository<UserRegistration, Long> {
List<UserRegistration> findAllByEmail(List<String> emails);
UserRegistration findByEmail(String anEmail);
long countByEmailAndStatus(String email, UserRegistrationStatus status);
UserRegistration findByConfirmationCode(String confirmationCode);
UserRegistration findByRecoveryCode(String aRecoveryCode);
UserRegistration findByUserId(UserId anUserId);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationStatus.java
================================================
package com.tomo.mcauthentication.domain.registration;
public enum
UserRegistrationStatus {
WaitingForConfirmation("WaitingForConfirmation"),
Confirmed("Confirmed"),
Expired("Expired");
String value;
UserRegistrationStatus(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UsersCounter.java
================================================
package com.tomo.mcauthentication.domain.registration;
public interface UsersCounter {
int countUsersWithLogin();
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordChanged.java
================================================
package com.tomo.mcauthentication.domain.registration.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class PasswordChanged extends BaseDomainEvent {
private long userRegistrationId;
private String password; //encrypted
public PasswordChanged(long userRegistrationId, String password) {
this.userRegistrationId = userRegistrationId;
this.password = password;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecovered.java
================================================
package com.tomo.mcauthentication.domain.registration.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class PasswordRecovered extends BaseDomainEvent {
private long userRegistrationId;
private String password; //encrypted
private String recoveryCode; //encrypted
public PasswordRecovered(long userRegistrationId, String password, String recoveryCode) {
this.userRegistrationId = userRegistrationId;
this.password = password;
this.recoveryCode = recoveryCode;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecoveryCodeCreated.java
================================================
package com.tomo.mcauthentication.domain.registration.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class PasswordRecoveryCodeCreated extends BaseDomainEvent {
long userRegistrationId;
private String email;
private String recoveryCode;
private LocalDateTime recoveryCodeExpirationDate;
public PasswordRecoveryCodeCreated(long userRegistrationId, String email, String recoveryCode, LocalDateTime recoveryCodeExpirationDate) {
this.userRegistrationId = userRegistrationId;
this.email = email;
this.recoveryCode = recoveryCode;
this.recoveryCodeExpirationDate = recoveryCodeExpirationDate;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationConfirmed.java
================================================
package com.tomo.mcauthentication.domain.registration.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
import com.tomo.mcauthentication.domain.users.UserId;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserRegistrationConfirmed extends BaseDomainEvent {
private long userRegistrationId;
private UserRegistrationStatus status;
private UserId userId;
public UserRegistrationConfirmed(long userRegistrationId, UserRegistrationStatus status, UserId userId) {
this.userRegistrationId = userRegistrationId;
this.status = status;
this.userId = userId;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationRequested.java
================================================
package com.tomo.mcauthentication.domain.registration.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserRegistrationRequested extends BaseDomainEvent {
private long userRegistrationId;
private String email;
private String confirmationCode;
private String firstName;
private String lastName;
private LocalDateTime registerDate;
private UserRegistrationStatus status;
public UserRegistrationRequested(
String email,
String confirmationCode,
String firstName,
String lastName,
LocalDateTime registerDate,
UserRegistrationStatus status) {
this.email = email;
this.confirmationCode = confirmationCode;
this.firstName = firstName;
this.lastName = lastName;
this.registerDate = registerDate;
this.status = status;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldBeExpiredOrNull.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
public class PasswordRecoveryCodeShouldBeExpiredOrNull implements BusinessRule {
private UserRegistration userRegistration;
public PasswordRecoveryCodeShouldBeExpiredOrNull(UserRegistration aUserRegistration) {
this.userRegistration = aUserRegistration;
}
@Override
public Boolean isRuleComplied() {
return userRegistration.isRecoveryCodeExpired() || userRegistration.getRecoveryCode() == null;
}
@Override
public String message() {
return "User recovery code is not expired yet. You can't get new one after the current code expire.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldNotExpired.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
public class PasswordRecoveryCodeShouldNotExpired implements BusinessRule {
private UserRegistration userRegistration;
public PasswordRecoveryCodeShouldNotExpired(UserRegistration aUserRegistration) {
this.userRegistration = aUserRegistration;
}
@Override
public Boolean isRuleComplied() {
return userRegistration.isRecoveryCodeUnexpired();
}
@Override
public String message() {
return "User recovery code is not expired yet. You can't get new one after the current code expire.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordsMustMatch.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
public class PasswordsMustMatch implements BusinessRule {
private String providedPassoword;
private String storedPassword;
public PasswordsMustMatch(String storedPassword, String providedPassoword) {
this.storedPassword = storedPassword;
this.providedPassoword = providedPassoword;
}
@Override
public Boolean isRuleComplied() {
return providedPassoword.equals(storedPassword);
}
@Override
public String message() {
return "Passwords dont match.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/RecoveryCodeMustMatch.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
public class RecoveryCodeMustMatch implements BusinessRule {
private String providedCode;
private String storedCode;
public RecoveryCodeMustMatch(String aStoredCode, String aProvidedCode) {
this.storedCode = aStoredCode;
this.providedCode = aProvidedCode;
}
@Override
public Boolean isRuleComplied() {
return providedCode.equals(storedCode);
}
@Override
public String message() {
return "Passwords dont match.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedAfterExpiration.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import java.time.LocalDateTime;
public class UserRegistrationCannotBeConfirmedAfterExpiration implements BusinessRule {
public static final int CONFIRMATION_LINK_DURATION = 8;
LocalDateTime registerDate;
public UserRegistrationCannotBeConfirmedAfterExpiration(LocalDateTime aRegisterDate) {
this.registerDate = aRegisterDate;
}
@Override
public Boolean isRuleComplied() {
return LocalDateTime.now().isBefore(this.registerDate.plusDays(CONFIRMATION_LINK_DURATION));
}
@Override
public String message() {
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedMoreThanOnce.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
public class UserRegistrationCannotBeConfirmedMoreThanOnce implements BusinessRule {
UserRegistrationStatus status;
public UserRegistrationCannotBeConfirmedMoreThanOnce(UserRegistrationStatus aStatus) {
this.status = aStatus;
}
@Override
public Boolean isRuleComplied() {
return !this.status.equals(UserRegistrationStatus.Confirmed);
}
@Override
public String message() {
return "User Registration cannot be confirmed more than once";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeConfirmed.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
public class UserRegistrationMustBeConfirmed implements BusinessRule {
private UserRegistrationStatus userRegistrationStatus;
public UserRegistrationMustBeConfirmed(UserRegistrationStatus anUserRegistrationStatus) {
this.userRegistrationStatus = anUserRegistrationStatus;
}
@Override
public Boolean isRuleComplied() {
return userRegistrationStatus.equals(UserRegistrationStatus.Confirmed);
}
@Override
public String message() {
return "User registration is not confirmed yet.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeUnique.java
================================================
package com.tomo.mcauthentication.domain.registration.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
public class UserRegistrationMustBeUnique implements BusinessRule {
private UserRegistrationRepository repository;
private String email;
public UserRegistrationMustBeUnique(UserRegistrationRepository usersCounter, String email) {
this.repository = usersCounter;
this.email = email;
}
@Override
public Boolean isRuleComplied() {
return repository.countByEmailAndStatus(email, UserRegistrationStatus.Confirmed) < 1;
}
@Override
public String message() {
return "User login must be unique";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/JwtTokenProvider.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.mcauthentication.domain.session.Session.TokenType;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import com.tomo.mcauthentication.infrastructure.springboot.configuration.AppProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import javax.crypto.SecretKey;
import java.util.Date;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.MalformedJwtException;
import io.jsonwebtoken.UnsupportedJwtException;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
@Service
@Qualifier("jwtTokenProvider")
public class JwtTokenProvider implements TokenProvider {
private static final Logger logger = LoggerFactory.getLogger(TokenProvider.class);
private AppProperties appProperties;
public JwtTokenProvider(AppProperties appProperties) {
this.appProperties = appProperties;
}
@Override public String createToken(User user) {
Date now = new Date();
Date expiryDate = new Date(now.getTime() + appProperties.getAuth().getTokenExpirationMsec());
return Jwts.builder()
.setSubject(user.getUserId().id().toString())
.setIssuedAt(new Date())
.setExpiration(expiryDate)
.signWith(secretKey())
.compact();
}
@Override
public UserId getUserIdFromToken(String anAuthToken) {
Claims claims = Jwts.parserBuilder()
.setSigningKey(secretKey())
.build()
.parseClaimsJws(anAuthToken)
.getBody();
return new UserId(claims.getSubject());
}
@Override
public boolean validateToken(String anAuthToken) {
try {
Jwts.parserBuilder()
.setSigningKey(secretKey())
.build()
.parseClaimsJws(anAuthToken);
return true;
} catch (SecurityException ex) {
logger.error("Invalid JWT signature");
} catch (MalformedJwtException ex) {
logger.error("Invalid JWT token");
} catch (ExpiredJwtException ex) {
logger.error("Expired JWT token");
throw ex;
} catch (UnsupportedJwtException ex) {
logger.error("Unsupported JWT token");
} catch (IllegalArgumentException ex) {
logger.error("JWT claims string is empty.");
}
return false;
}
@Override
public TokenType getTokenType() {
return TokenType.CLIENT_SECRET_JWT;
}
@Override public String createRefreshToken(User user) {
return null;
}
private SecretKey secretKey() {
return Keys.hmacShaKeyFor(Decoders.BASE64.decode(appProperties.getAuth().getTokenSecret()));
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/Session.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.ddd.domain.RootEntity;
import com.tomo.mcauthentication.domain.DomainRegistry;
import com.tomo.mcauthentication.domain.session.events.SessionCreated;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@NoArgsConstructor
@Getter
@Setter
public class Session extends RootEntity {
public static Long EXPIRATION_MSEC = 15000L;
public enum TokenType {
CLIENT_SECRET_JWT,
PRIVATE_KEY_JWT,
BASIC,
API_KEY
}
@EmbeddedId
private SessionId sessionId;
private String accessToken;
private LocalDateTime expirationDate;
@Enumerated(EnumType.STRING)
private TokenType tokenType;
private String refreshToken;
private String userAgent;
private String ipAddress;
private LocalDateTime lastActivity;
@Embedded
@AttributeOverride(name="id", column = @Column(name="user_id"))
private UserId userId;
public Session(SessionId sessionId, User user, TokenProvider tokenProvider, Boolean rememberMe, String userAgent, String ipAddress)
{
this.sessionId = sessionId;
this.ipAddress = ipAddress;
this.userAgent = userAgent;
this.tokenType = tokenProvider.getTokenType();
this.userId = user.getUserId();
this.expirationDate = LocalDateTime.now().plus(EXPIRATION_MSEC, ChronoField.MILLI_OF_DAY.getBaseUnit());
this.accessToken = tokenProvider.createToken(user);
if (Boolean.TRUE.equals(rememberMe)) {
this.refreshToken = tokenProvider.createRefreshToken(user);
}
DomainEventPublisher.instance().publish(
new SessionCreated(this.getSessionId(), this.getUserId())
);
}
public boolean isExpired() {
return !expirationDate.isAfter(LocalDateTime.now());
}
private void protectedAccessToken(String anToken) {
this.assertArgumentNotEmpty(anToken, "Access token cannot be empty.");
this.setAccessToken(DomainRegistry.encryptionService().encryptedValue(anToken));
}
private void protectedRefreshToken(String anToken) {
this.assertArgumentNotEmpty(anToken, "Refresh token cannot be empty.");
this.setRefreshToken(DomainRegistry.encryptionService().encryptedValue(anToken));
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionAuthenticationService.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.ddd.domain.BusinessRuleValidator;
import com.tomo.mcauthentication.domain.session.rule.SessionCannotBeExpiredWhenRefreshTokenIsMissing;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
public class SessionAuthenticationService extends BusinessRuleValidator {
TokenProvider tokenProvider;
SessionRepository sessionRepository;
UserRepository userRepository;
public SessionAuthenticationService(
TokenProvider tokenProvider,
SessionRepository sessionRepository,
@Qualifier("userRepositoryJpaAdapter") UserRepository userRepository) {
this.tokenProvider = tokenProvider;
this.sessionRepository = sessionRepository;
this.userRepository = userRepository;
}
public Session authenticate(String anAccessToken) {
assertArgumentNotEmpty(anAccessToken, "Session token cannot be empty.");
Session session = sessionRepository.findByAccessToken(anAccessToken);
if (session == null) {
throw new IllegalStateException(String.format("Session with access code %s doesn't exist.", anAccessToken));
}
checkRule(new SessionCannotBeExpiredWhenRefreshTokenIsMissing(session));
if (session.isExpired()) {
return new Session(
sessionRepository.nextIdentity(),
userRepository.findById(session.getUserId()),
tokenProvider,
true,
session.getUserAgent(),
session.getIpAddress());
}
session.setLastActivity(LocalDateTime.now());
return session;
}
public Session logout(String anAccessToken) {
assertArgumentNotEmpty(anAccessToken, "Session token cannot be empty.");
Session session = sessionRepository.findByAccessToken(anAccessToken);
if (session == null) {
throw new IllegalStateException(String.format("Session with access code %s doesn't exist.", anAccessToken));
}
session.setExpirationDate(LocalDateTime.now());
session.setRefreshToken(null);
return sessionRepository.save(session);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionId.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.ddd.domain.AbstractId;
import javax.persistence.Embeddable;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Embeddable
@Getter
@Setter
@NoArgsConstructor
public class SessionId extends AbstractId {
public SessionId(UUID id) {
super(id);
}
@Override
protected int hashOddValue() {
return 5785;
}
@Override
protected int hashPrimeValue() {
return 31;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionRepository.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.ddd.domain.BaseRepository;
import com.tomo.mcauthentication.domain.users.UserId;
import java.util.List;
public interface SessionRepository extends BaseRepository<Session, SessionId> {
SessionId nextIdentity();
List<Session> findByUserId(UserId userId);
Session findByAccessToken(String anAccessToken);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/TokenProvider.java
================================================
package com.tomo.mcauthentication.domain.session;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
public interface TokenProvider {
String createToken(User user);
String createRefreshToken(User user);
UserId getUserIdFromToken(String anAuthToken);
boolean validateToken(String anAuthToken);
Session.TokenType getTokenType();
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/events/SessionCreated.java
================================================
package com.tomo.mcauthentication.domain.session.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import com.tomo.mcauthentication.domain.session.SessionId;
import com.tomo.mcauthentication.domain.users.UserId;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SessionCreated extends BaseDomainEvent {
private SessionId sessionId;
private UserId userId;
public SessionCreated(SessionId sessionId, UserId userId) {
this.sessionId = sessionId;
this.userId = userId;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/session/rule/SessionCannotBeExpiredWhenRefreshTokenIsMissing.java
================================================
package com.tomo.mcauthentication.domain.session.rule;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.session.Session;
public class SessionCannotBeExpiredWhenRefreshTokenIsMissing implements BusinessRule {
Session session;
public SessionCannotBeExpiredWhenRefreshTokenIsMissing(Session session) {
this.session = session;
}
@Override
public Boolean isRuleComplied() {
return (!session.isExpired()) || (session.isExpired() && session.getRefreshToken() != null);
}
@Override
public String message() {
return String.format("Session token is expired and refresh token is missing.");
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/EmailLogin.java
================================================
package com.tomo.mcauthentication.domain.users;
public class EmailLogin {
User user;
String username;
String password;
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/User.java
================================================
package com.tomo.mcauthentication.domain.users;
import com.tomo.ddd.domain.ConcurrencySafeEntity;
import com.tomo.ddd.domain.DomainEvent;
import com.tomo.ddd.domain.DomainEventPublisher;
import com.tomo.mcauthentication.domain.DomainRegistry;
import com.tomo.mcauthentication.domain.users.events.UserCreated;
import com.tomo.mcauthentication.domain.users.events.UserNameChanged;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Entity(name = "mcuser")
@Getter
@NoArgsConstructor
public class User extends ConcurrencySafeEntity {
public enum AuthProvider {
EMAIL,
FACEBOOK,
GOOGLE
}
@EmbeddedId
UserId userId;
String firstName;
String lastName;
String email;
@Enumerated(EnumType.STRING)
AuthProvider provider;
public User(
UserId anId,
String aFirstName,
String aLastName,
String anEmail,
AuthProvider aProvider) {
this.checkRule(DomainRegistry.userEmailMustBeUnique(anEmail));
this.userId = anId;
this.firstName = aFirstName;
this.lastName = aLastName;
this.email = anEmail;
this.provider = aProvider;
this.publish(new UserCreated(
this.getUserId(),
this.getFirstName(),
this.getLastName(),
this.getEmail(),
this.getProvider()
));
}
public void updateDetails(String aFirstName, String aLastName) {
this.setFirstName(aFirstName);
this.setLastName(aLastName);
publish(new UserNameChanged(
this.getEmail(),
this.getFirstName(),
this.getLastName()));
}
public void setLastName(String aLastName) {
assertArgumentNotEmpty(lastName, "Last name cannot be empty.");
this.lastName = aLastName;
}
public void setFirstName(String aFirstName) {
assertArgumentNotEmpty(aFirstName, "First name cannot be empty.");
this.firstName = aFirstName;
}
private void publish(DomainEvent event) {
DomainEventPublisher.instance().publish(event);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/UserId.java
================================================
package com.tomo.mcauthentication.domain.users;
import com.tomo.ddd.domain.AbstractId;
import javax.persistence.Embeddable;
import java.util.UUID;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Embeddable
@Getter
@Setter
@NoArgsConstructor
public class UserId extends AbstractId {
public UserId(UUID id) {
super(id);
}
public UserId(String id) {
super(UUID.fromString(id));
}
@Override
protected int hashOddValue() {
return 83811;
}
@Override
protected int hashPrimeValue() {
return 263;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/UserRepository.java
================================================
package com.tomo.mcauthentication.domain.users;
import com.tomo.ddd.domain.BaseRepository;
public interface UserRepository extends BaseRepository<User, UserId> {
UserId nextIdentity();
User findByEmail(String anEmail);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/events/UserCreated.java
================================================
package com.tomo.mcauthentication.domain.users.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserCreated extends BaseDomainEvent {
UserId userId;
String firstName;
String lastName;
String email;
User.AuthProvider provider;
public UserCreated(UserId userId, String firstName, String lastName, String email, User.AuthProvider provider) {
this.userId = userId;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.provider = provider;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/events/UserNameChanged.java
================================================
package com.tomo.mcauthentication.domain.users.events;
import com.tomo.ddd.domain.BaseDomainEvent;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class UserNameChanged extends BaseDomainEvent {
String email;
String firstName;
String lastName;
public UserNameChanged(String email, String firstName, String lastName) {
this.email = email;
this.firstName = firstName;
this.lastName = lastName;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/domain/users/rules/UserEmailMustBeUnique.java
================================================
package com.tomo.mcauthentication.domain.users.rules;
import com.tomo.ddd.domain.BusinessRule;
import com.tomo.mcauthentication.domain.users.UserRepository;
public class UserEmailMustBeUnique implements BusinessRule {
UserRepository userRespository;
String email;
public UserEmailMustBeUnique(UserRepository userRespository, String email) {
this.userRespository = userRespository;
this.email = email;
}
@Override
public Boolean isRuleComplied() {
return userRespository.findByEmail(this.email) == null;
}
@Override
public String message() {
return "User with this email already exists.";
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/McAuthenticationModuleExecutor.java
================================================
package com.tomo.mcauthentication.infrastructure;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.McAuthenticationModule;
import com.tomo.mcauthentication.application.contracts.Query;
import com.tomo.mcauthentication.application.contracts.Response;
import com.tomo.mcauthentication.infrastructure.processing.builder.CommandHandlerPipelineBuilder;
import com.tomo.mcauthentication.infrastructure.processing.builder.QueryHandlerPipelineBuilder;
import org.springframework.stereotype.Component;
@Component
public class McAuthenticationModuleExecutor implements McAuthenticationModule {
CommandHandlerPipelineBuilder commandHandlerPipelineBuilder;
QueryHandlerPipelineBuilder queryHandlerPipelineBuilder;
public McAuthenticationModuleExecutor(
CommandHandlerPipelineBuilder commandHandlerPipelineBuilder,
QueryHandlerPipelineBuilder queryHandlerPipelineBuilder) {
this.commandHandlerPipelineBuilder = commandHandlerPipelineBuilder;
this.queryHandlerPipelineBuilder = queryHandlerPipelineBuilder;
}
@Override
public Response executeCommand(Command command) {
CommandHandler commandHandler = commandHandlerPipelineBuilder
.with(command)
.build();
return commandHandler.handle(command);
}
@Override
public Response executeQuery(Query query) {
QueryHandler queryHandler = queryHandlerPipelineBuilder
.with(query)
.build();
return queryHandler.handle(query);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/AbstractOAuth2Authentication.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Principal;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.OAuth2UserInfo;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.OAuth2UserInfoFactory;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.security.oauth2.core.user.OAuth2User;
import java.time.Instant;
public abstract class AbstractOAuth2Authentication {
ClientRegistration clientRegistration;
CustomOAuth2UserService customOAuth2UserService;
public AbstractOAuth2Authentication(ClientRegistration clientRegistration,
CustomOAuth2UserService customOAuth2UserService) {
this.clientRegistration = clientRegistration;
this.customOAuth2UserService = customOAuth2UserService;
}
protected OAuth2Principal authenticateUser(String anAccessCode) {
OAuth2UserRequest oAuth2UserRequest = new OAuth2UserRequest(clientRegistration, new OAuth2AccessToken(
OAuth2AccessToken.TokenType.BEARER,
anAccessCode,
Instant.now(), Instant.now().plusSeconds(10000L)));
OAuth2User oAuth2User = customOAuth2UserService.loadUser(oAuth2UserRequest);
OAuth2UserInfo userInfo = OAuth2UserInfoFactory
.getOAuth2UserInfo(clientRegistration.getRegistrationId(), oAuth2User.getAttributes());
return new OAuth2Principal(
userInfo.getId(),
userInfo.getEmail(),
userInfo.getName(),
userInfo.getName(),
userInfo.getImageUrl(),
clientRegistration.getRegistrationId());
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/CustomOAuth2UserService.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2;
import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
@Service
public class CustomOAuth2UserService extends DefaultOAuth2UserService {
public OAuth2User loadUser(OAuth2UserRequest oAuth2UserRequest) throws OAuth2AuthenticationException {
return super.loadUser(oAuth2UserRequest);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/FacebookOAuth2Authentication.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Authentication;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Principal;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.FacebookOAuth2UserInfo;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.OAuth2UserInfoFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
@Service
public class FacebookOAuth2Authentication extends AbstractOAuth2Authentication implements OAuth2Authentication {
public FacebookOAuth2Authentication(
@Qualifier("facebookClientRegistration") ClientRegistration clientRegistration,
CustomOAuth2UserService customOAuth2UserService) {
super(clientRegistration, customOAuth2UserService);
}
@Override
public OAuth2Principal authenticate(String anAccessCode) {
return super.authenticateUser(anAccessCode);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/GoogleOAuth2Authentication.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Authentication;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Principal;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.FacebookOAuth2UserInfo;
import com.tomo.mcauthentication.infrastructure.http.oauth2.user.OAuth2UserInfoFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
@Service
public class GoogleOAuth2Authentication extends AbstractOAuth2Authentication implements OAuth2Authentication {
public GoogleOAuth2Authentication(
@Qualifier("googleClientRegistration") ClientRegistration clientRegistration,
CustomOAuth2UserService customOAuth2UserService) {
super(clientRegistration, customOAuth2UserService);
}
@Override
public OAuth2Principal authenticate(String anAccessCode) {
return super.authenticateUser(anAccessCode);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/FacebookOAuth2UserInfo.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2.user;
import java.util.Map;
public class FacebookOAuth2UserInfo extends OAuth2UserInfo {
public FacebookOAuth2UserInfo(Map<String, Object> attributes) {
super(attributes);
}
@Override
public String getId() {
return (String) attributes.get("id");
}
@Override
public String getName() {
return (String) attributes.get("name");
}
@Override
public String getEmail() {
return (String) attributes.get("email");
}
@Override
public String getImageUrl() {
if(attributes.containsKey("picture")) {
Map<String, Object> pictureObj = (Map<String, Object>) attributes.get("picture");
if(pictureObj.containsKey("data")) {
Map<String, Object> dataObj = (Map<String, Object>) pictureObj.get("data");
if(dataObj.containsKey("url")) {
return (String) dataObj.get("url");
}
}
}
return null;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/GoogleOAuth2UserInfo.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2.user;
import java.util.Map;
public class GoogleOAuth2UserInfo extends OAuth2UserInfo {
public GoogleOAuth2UserInfo(Map<String, Object> attributes) {
super(attributes);
}
@Override
public String getId() {
return (String) attributes.get("sub");
}
@Override
public String getName() {
return (String) attributes.get("name");
}
@Override
public String getEmail() {
return (String) attributes.get("email");
}
@Override
public String getImageUrl() {
return (String) attributes.get("picture");
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfo.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2.user;
import java.util.Map;;
public abstract class OAuth2UserInfo {
protected Map<String, Object> attributes;
public OAuth2UserInfo(Map<String, Object> attributes) {
this.attributes = attributes;
}
public Map<String, Object> getAttributes() {
return attributes;
}
public abstract String getId();
public abstract String getName();
public abstract String getEmail();
public abstract String getImageUrl();
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfoFactory.java
================================================
package com.tomo.mcauthentication.infrastructure.http.oauth2.user;
import com.tomo.mcauthentication.domain.users.User;
import java.util.Map;
public class OAuth2UserInfoFactory {
public static OAuth2UserInfo getOAuth2UserInfo(String registrationId, Map<String, Object> attributes) {
if(registrationId.equalsIgnoreCase(User.AuthProvider.GOOGLE.toString().toLowerCase())) {
return new GoogleOAuth2UserInfo(attributes);
} else if (registrationId.equalsIgnoreCase(User.AuthProvider.FACEBOOK.toString().toLowerCase())) {
return new FacebookOAuth2UserInfo(attributes);
} else {
throw new IllegalArgumentException("Sorry! Login with " + registrationId + " is not supported yet.");
}
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/BaseJpaAdapter.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.ddd.domain.BaseRepository;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.McCrudRepository;
import java.util.List;
import java.util.Optional;
//https://github.com/benthurley82/generic-type-resolver-test/blob/main/src/main/java/com/example/test/AbstractFoo.java
public class BaseJpaAdapter<T, ID, E extends McCrudRepository> implements BaseRepository<T, ID> {
protected E jpaRepository;
public BaseJpaAdapter(E jpaRepository) {
this.jpaRepository = jpaRepository;
}
@Override
public T save(T entity) {
return (T) jpaRepository.save(entity);
}
@Override
public T findById(ID id) {
Optional<T> entity = jpaRepository.findById(id);
return entity.isPresent() ? entity.get() : null;
}
@Override
public List<T> findAll() {
return jpaRepository.findAll();
}
@Override
public void saveAll(List<T> entities) {
jpaRepository.saveAll(entities);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionJpaRepository.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.McCrudRepository;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionId;
import com.tomo.mcauthentication.domain.users.UserId;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SessionJpaRepository extends McCrudRepository<Session, SessionId> {
List<Session> findAllByUserId(UserId userId);
Session findSessionByAccessToken(String accessToken);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionRepositoryJpaAdapter.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.mcauthentication.domain.session.Session;
import com.tomo.mcauthentication.domain.session.SessionId;
import com.tomo.mcauthentication.domain.session.SessionRepository;
import com.tomo.mcauthentication.domain.users.UserId;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.UUID;
@Repository
public class SessionRepositoryJpaAdapter extends BaseJpaAdapter<Session, SessionId, SessionJpaRepository> implements SessionRepository {
public SessionRepositoryJpaAdapter(SessionJpaRepository jpaRepository) {
super(jpaRepository);
}
@Override
public SessionId nextIdentity() {
return new SessionId(UUID.randomUUID());
}
@Override
public List<Session> findByUserId(UserId userId) {
return jpaRepository.findAllByUserId(userId);
}
@Override
public Session findByAccessToken(String anAccessToken) {
return jpaRepository.findSessionByAccessToken(anAccessToken);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserJpaRepository.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.McCrudRepository;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import org.springframework.stereotype.Repository;
@Repository
public interface UserJpaRepository extends McCrudRepository<User, UserId> {
User findUserByEmail(String email);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepository.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.McCrudRepository;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.users.UserId;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Qualifier("UserRegistrationJpaRepository")
public interface UserRegistrationJpaRepository extends McCrudRepository <UserRegistration, Long> {
long countByEmail(String email);
List<UserRegistration> findAllByEmailIn(List<String> email);
UserRegistration findUserRegistrationByConfirmationCode(String confirmLink);
UserRegistration findUserRegistrationByEmail(String email);
UserRegistration findUserRegistrationByRecoveryCode(String recoveryCode);
UserRegistration findUserRegistrationByUserId(UserId userId);
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepositoryAdapter.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.mcauthentication.domain.registration.UserRegistration;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.registration.UserRegistrationStatus;
import com.tomo.mcauthentication.domain.users.UserId;
import java.util.List;
public class UserRegistrationJpaRepositoryAdapter
extends BaseJpaAdapter<UserRegistration, Long, UserRegistrationJpaRepository>
implements UserRegistrationRepository {
public UserRegistrationJpaRepositoryAdapter(UserRegistrationJpaRepository jpaRepository) {
super(jpaRepository);
}
@Override
public long countByEmailAndStatus(String email, UserRegistrationStatus status) {
return jpaRepository.countByEmail(email);
}
@Override
public List<UserRegistration> findAllByEmail(List<String> emails) {
return jpaRepository.findAllByEmailIn(emails);
}
@Override
public UserRegistration findByEmail(String anEmail) {
return jpaRepository.findUserRegistrationByEmail(anEmail);
}
@Override public UserRegistration findByConfirmationCode(String confirmationCode) {
return jpaRepository.findUserRegistrationByConfirmationCode(confirmationCode);
}
@Override
public UserRegistration findByRecoveryCode(String aRecoveryCode) {
return jpaRepository.findUserRegistrationByRecoveryCode(aRecoveryCode);
}
@Override public UserRegistration findByUserId(UserId anUserId) {
return jpaRepository.findUserRegistrationByUserId(anUserId);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRepositoryJpaAdapter.java
================================================
package com.tomo.mcauthentication.infrastructure.persistence;
import com.tomo.mcauthentication.domain.users.User;
import com.tomo.mcauthentication.domain.users.UserId;
import com.tomo.mcauthentication.domain.users.UserRepository;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
public class UserRepositoryJpaAdapter extends BaseJpaAdapter<User, UserId, UserJpaRepository> implements UserRepository {
public UserRepositoryJpaAdapter(UserJpaRepository userJpaRepository) {
super(userJpaRepository);
}
@Override
public UserId nextIdentity() {
return new UserId(UUID.randomUUID());
}
@Override
public User findByEmail(String anEmail) {
return jpaRepository.findUserByEmail(anEmail);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/ErrorCommandHandlerDecorator.java
================================================
package com.tomo.mcauthentication.infrastructure.processing;
import com.tomo.mcauthentication.application.configuration.AbstractVoidyCommandHandler;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.contracts.Command;
public class ErrorCommandHandlerDecorator<T extends Command> extends AbstractVoidyCommandHandler<T> {
CommandHandler commandHandler;
public ErrorCommandHandlerDecorator(CommandHandler commandHandler) {
this.commandHandler = commandHandler;
}
@Override
protected void abstractHandle(T aCommand) {
commandHandler.handle(aCommand);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingCommandHandlerDecorator.java
================================================
package com.tomo.mcauthentication.infrastructure.processing;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.application.contracts.Response;
public class LoggingCommandHandlerDecorator implements CommandHandler<Command, Response> {
CommandHandler commandHandler;
public LoggingCommandHandlerDecorator(CommandHandler commandHandler) {
this.commandHandler = commandHandler;
}
@Override
public Response handle(Command aCommand) {
//todo log
return commandHandler.handle(aCommand);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingQueryHandlerDecorator.java
================================================
package com.tomo.mcauthentication.infrastructure.processing;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.contracts.Query;
import com.tomo.mcauthentication.application.contracts.Response;
public class LoggingQueryHandlerDecorator implements QueryHandler {
QueryHandler queryHandler;
public LoggingQueryHandlerDecorator(QueryHandler queryHandler) {
this.queryHandler = queryHandler;
}
@Override
public Response handle(Query query) {
return queryHandler.handle(query);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/PipelineBuilder.java
================================================
package com.tomo.mcauthentication.infrastructure.processing;
public interface PipelineBuilder<C, R> {
PipelineBuilder with(C aRequest);
R build();
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/AbstractPipelineBuilder.java
================================================
package com.tomo.mcauthentication.infrastructure.processing.builder;
import com.tomo.mcauthentication.application.configuration.RequestHandler;
import com.tomo.mcauthentication.application.contracts.Request;
import com.tomo.mcauthentication.infrastructure.processing.PipelineBuilder;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public abstract class AbstractPipelineBuilder<E extends Request, S extends RequestHandler> implements PipelineBuilder<E, S>, ApplicationContextAware {
protected E request;
protected S handler;
protected ApplicationContext applicationContext;
@Override
public PipelineBuilder with(E aRequest) {
this.request = aRequest;
this.handler = this.getHandler();
return this;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
protected S getHandler() {
String beanName = this.getHandlerName();
return (S) applicationContext.getBean(beanName);
}
protected String getHandlerName() {
String fullHandlerName = this.request.getClass().getSimpleName() + "Handler";
return Character.toLowerCase(fullHandlerName.charAt(0)) + fullHandlerName.substring(1);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/CommandHandlerPipelineBuilder.java
================================================
package com.tomo.mcauthentication.infrastructure.processing.builder;
import com.tomo.mcauthentication.application.configuration.CommandHandler;
import com.tomo.mcauthentication.application.contracts.Command;
import com.tomo.mcauthentication.infrastructure.processing.LoggingCommandHandlerDecorator;
import com.tomo.mcauthentication.infrastructure.processing.PipelineBuilder;
public class CommandHandlerPipelineBuilder extends AbstractPipelineBuilder<Command, CommandHandler> {
public CommandHandlerPipelineBuilder() {}
@Override
public CommandHandlerPipelineBuilder with(Command aRequest) {
return (CommandHandlerPipelineBuilder) super.with(aRequest);
}
@Override
public CommandHandler build() {
return new LoggingCommandHandlerDecorator(handler);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/QueryHandlerPipelineBuilder.java
================================================
package com.tomo.mcauthentication.infrastructure.processing.builder;
import com.tomo.mcauthentication.application.configuration.QueryHandler;
import com.tomo.mcauthentication.application.contracts.Query;
import com.tomo.mcauthentication.infrastructure.processing.LoggingQueryHandlerDecorator;
import com.tomo.mcauthentication.infrastructure.processing.PipelineBuilder;
public class QueryHandlerPipelineBuilder extends AbstractPipelineBuilder<Query, QueryHandler> {
public QueryHandlerPipelineBuilder() {
}
@Override
public QueryHandlerPipelineBuilder with(Query aRequest) {
return (QueryHandlerPipelineBuilder) super.with(aRequest);
}
@Override
public QueryHandler build() {
return new LoggingQueryHandlerDecorator(handler);
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/service/MD5EncryptionService.java
================================================
package com.tomo.mcauthentication.infrastructure.service;
import com.tomo.ddd.AssertionConcern;
import com.tomo.mcauthentication.domain.EncryptionService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.math.BigInteger;
import java.security.MessageDigest;
@Service
@Qualifier("MD5EncryptionService")
public class MD5EncryptionService extends AssertionConcern implements EncryptionService {
public MD5EncryptionService() {
super();
}
@Override
public String encryptedValue(String aPlainTextValue) {
this.assertArgumentNotEmpty(
aPlainTextValue,
"Plain text value to encrypt must be provided.");
String encryptedValue = null;
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(aPlainTextValue.getBytes("UTF-8"));
BigInteger bigInt = new BigInteger(1, messageDigest.digest());
encryptedValue = bigInt.toString(16);
} catch (Exception e) {
throw new IllegalStateException(e);
}
return encryptedValue;
}
}
================================================
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/AppConfig.java
================================================
package com.tomo.mcauthentication.infrastructure.springboot.configuration;
import com.tomo.mcauthentication.application.contracts.McAuthenticationModule;
import com.tomo.ddd.email.EmailSender;
import com.tomo.ddd.event.EventStore;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.EventStoreJpaRepositoryAdapter;
import com.tomo.ddd.infrastructure.persistence.springdata.jpa.StoredEventJpaRepository;
import com.tomo.ddd.port.adapter.message.email.MailGunMessageSender;
import com.tomo.mcauthentication.domain.oauth2.OAuth2Service;
import com.tomo.mcauthentication.domain.registration.UserRegistrationRepository;
import com.tomo.mcauthentication.domain.users.UserRepository;
import com.tomo.mcauthentication.infrastructure.McAuthenticationModuleExecutor;
import com.tomo.mcauthentication.infrastructure.http.oauth2.FacebookOAuth2Authentication;
import com.tomo.mcauthentication.infrastructure.http.oauth2.GoogleOAuth2Authentication;
import com.tomo.mcauthentication.infrastructure.persistence.UserJpaRepository;
import com.tomo.mcauthentication.infrastructure.persistence.UserRegistrationJpaRepository;
import com.tomo.mcauthentication.infrastructure.persistence.UserRegistrationJpaRepositoryAdapter;
import com.tomo.mcauthentication.infrastructure.persistence.UserRepositoryJpaAdapter;
import com.tomo.mcauthentication.infrastructure.processing.builder.CommandHandlerPipelineBuilder;
import com.tomo.mcauthentication.infrastructure.processing.builder.QueryHandlerPipelineBuilder;
import com.tomo.mcauthentication.infrastructure.springboot.filter.TokenAuthenticationFilter;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
@Configuration
@EnableJpaRepositories({
"com.tomo.ddd.infrastructure.persistence.springdata.jpa",
"com.tomo.mcauthentication.infrastructure.persistence"
})
public class AppConfig {
@Autowired
UserRegistrationJpaRepository userRegistrationJpaRepository;
@Autowired
UserJpaRepository userJpaRepository;
@Autowired
private Environment env;
@Autowired
AppProperties appProperties;
@Autowired
StoredEventJpaRepository storedEventJpaRepository;
@Bean
EventStore eventStore() {
return new EventStoreJpaRepositoryAdapter(storedEventJpaRepository);
}
@Bean
String recoveryLink() {
return appProperties.getGui().getRecoveryRoute();
}
@Bean
String confirmationLink() {
return appProperties.getGui().getConfirmationRoute();
}
@Bean
net.sargue.mailgun.Configuration mailGunConfiguration() {
MessageProperties.Email.MailGun mailGun = appProperties.getMessage().getEmail().getMailGun();
net.sargue.mailgun.Configuration configuration = new net.sargue.mailgun.Configuration()
.domain(mailGun.getDomains())
.apiUrl(mailGun.getApiUrl())
.apiKey(mailGun.getApiKey())
.from(mailGun.getFrom().getName(), mailGun.getFrom().getEmail());
return configuration;
}
@Bean
EmailSender emailMessageSender(net.sargue.mailgun.Configuration mailGunConfiguration) {
return new MailGunMessageSender(mailGunConfiguration);
}
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
@Bean
public TokenAuthenticationFilter tokenAuthenticationFilter() {
return new TokenAuthenticationFilter();
}
@Bean
McAuthenticationModule authenticationModule(CommandHandlerPipelineBuilder commandHandlerPipelineBuilder,
QueryHandlerPipelineBuilder queryHandlerPipelineBuilder) {
return new McAuthenticationModuleExecutor(commandHandlerPipelineBuilder, queryHandlerPipelineBuilder);
}
@Bean
CommandHandlerPipelineBuilder commandHandlerPipelineBuilder() {
return new CommandHandlerPipelineBuilder();
}
@Bean
QueryHandlerPipelineBuilder queryHandlerPipelineBuilder() {
return new QueryHandlerPipelineBuilder();
}
gitextract_3sq3ne0n/
├── .github/
│ └── workflows/
│ └── maven.yml
├── .gitignore
├── .mvn/
│ └── wrapper/
│ ├── MavenWrapperDownloader.java
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── 1-init.sql
├── Dockerfile
├── LICENSE
├── README.md
├── ddd_common-v1.0.0.jar
├── docker-compose-ci.yml
├── docker-compose.yml
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── tomo/
│ │ └── mcauthentication/
│ │ ├── McAuthenticationApplication.java
│ │ ├── application/
│ │ │ ├── BaseMapper.java
│ │ │ ├── McAuthenticationEventHandler.java
│ │ │ ├── authentication/
│ │ │ │ ├── BaseLoginCommandHandler.java
│ │ │ │ ├── EmailLoginCommandHandler.java
│ │ │ │ ├── FacebookLoginCommandHandler.java
│ │ │ │ ├── GoogleLoginCommandHandler.java
│ │ │ │ ├── LogoutCommandHandler.java
│ │ │ │ ├── SessionAuthenticationCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── BaseLoginCommand.java
│ │ │ │ │ ├── EmailLoginCommand.java
│ │ │ │ │ ├── FacebookLoginCommand.java
│ │ │ │ │ ├── GoogleLoginCommand.java
│ │ │ │ │ ├── LogoutCommand.java
│ │ │ │ │ └── SessionAuthenticationCommand.java
│ │ │ │ └── dto/
│ │ │ │ ├── RecoveryPasswordDto.java
│ │ │ │ └── SessionDto.java
│ │ │ ├── configuration/
│ │ │ │ ├── AbstractVoidyCommandHandler.java
│ │ │ │ ├── CommandHandler.java
│ │ │ │ ├── QueryHandler.java
│ │ │ │ └── RequestHandler.java
│ │ │ ├── contracts/
│ │ │ │ ├── BaseCommand.java
│ │ │ │ ├── BaseQuery.java
│ │ │ │ ├── BaseRequest.java
│ │ │ │ ├── Command.java
│ │ │ │ ├── Identifiable.java
│ │ │ │ ├── McAuthenticationModule.java
│ │ │ │ ├── Query.java
│ │ │ │ ├── Request.java
│ │ │ │ ├── Response.java
│ │ │ │ ├── Voidy.java
│ │ │ │ └── security/
│ │ │ │ ├── AbstractAuthenticateCommand.java
│ │ │ │ ├── AbstractAuthenticateQuery.java
│ │ │ │ ├── AbstractAuthenticateRequest.java
│ │ │ │ ├── AbstractAuthorizeCommand.java
│ │ │ │ ├── AbstractAuthorizeQuery.java
│ │ │ │ ├── AbstractAuthorizeRequest.java
│ │ │ │ ├── Authenticate.java
│ │ │ │ └── Authorize.java
│ │ │ ├── recovery/
│ │ │ │ ├── CreatePasswordRecoveryCodeCommandHandler.java
│ │ │ │ ├── GetUserRegistrationWithRecoveryCodeQueryHandler.java
│ │ │ │ ├── PasswordRecoveryCodeCreatedEventHandler.java
│ │ │ │ ├── SendPasswordRecoveryEmailCommandHandler.java
│ │ │ │ ├── UpdatePasswordWithRecoveryCodeCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── CreatePasswordRecoveryCodeCommand.java
│ │ │ │ │ ├── SendPasswordRecoveryEmailCommand.java
│ │ │ │ │ └── UpdatePasswordWithRecoveryCodeCommand.java
│ │ │ │ └── dto/
│ │ │ │ └── GetUserRegistrationWithRecoveryCodeQuery.java
│ │ │ ├── registration/
│ │ │ │ ├── ChangePasswordCommandHandler.java
│ │ │ │ ├── ConfirmUserRegistrationCommandHandler.java
│ │ │ │ ├── GetUserRegistrationQueryHandler.java
│ │ │ │ ├── NewUserRegisteredEventHandler.java
│ │ │ │ ├── RegisterNewUserCommandHandler.java
│ │ │ │ ├── SendRegistrationConfirmationEmailCommandHandler.java
│ │ │ │ ├── command/
│ │ │ │ │ ├── ChangePasswordCommand.java
│ │ │ │ │ ├── ConfirmUserRegistrationCommand.java
│ │ │ │ │ ├── RegisterNewUserCommand.java
│ │ │ │ │ └── SendRegistrationConfirmationEmailCommand.java
│ │ │ │ ├── dto/
│ │ │ │ │ └── UserRegistrationDto.java
│ │ │ │ └── query/
│ │ │ │ └── GetUserRegistrationQuery.java
│ │ │ └── users/
│ │ │ ├── ChangeUserDetailsCommandHandler.java
│ │ │ ├── GetUserQueryHandler.java
│ │ │ ├── command/
│ │ │ │ └── ChangeUserDetailsCommand.java
│ │ │ ├── dto/
│ │ │ │ └── BaseUserDto.java
│ │ │ └── query/
│ │ │ └── GetUserQuery.java
│ │ ├── domain/
│ │ │ ├── DomainRegistry.java
│ │ │ ├── EncryptionService.java
│ │ │ ├── oauth2/
│ │ │ │ ├── OAuth2Authentication.java
│ │ │ │ ├── OAuth2Principal.java
│ │ │ │ └── OAuth2Service.java
│ │ │ ├── registration/
│ │ │ │ ├── EmailAuthenticationService.java
│ │ │ │ ├── PasswordService.java
│ │ │ │ ├── UserRegistration.java
│ │ │ │ ├── UserRegistrationId.java
│ │ │ │ ├── UserRegistrationRepository.java
│ │ │ │ ├── UserRegistrationStatus.java
│ │ │ │ ├── UsersCounter.java
│ │ │ │ ├── events/
│ │ │ │ │ ├── PasswordChanged.java
│ │ │ │ │ ├── PasswordRecovered.java
│ │ │ │ │ ├── PasswordRecoveryCodeCreated.java
│ │ │ │ │ ├── UserRegistrationConfirmed.java
│ │ │ │ │ └── UserRegistrationRequested.java
│ │ │ │ └── rules/
│ │ │ │ ├── PasswordRecoveryCodeShouldBeExpiredOrNull.java
│ │ │ │ ├── PasswordRecoveryCodeShouldNotExpired.java
│ │ │ │ ├── PasswordsMustMatch.java
│ │ │ │ ├── RecoveryCodeMustMatch.java
│ │ │ │ ├── UserRegistrationCannotBeConfirmedAfterExpiration.java
│ │ │ │ ├── UserRegistrationCannotBeConfirmedMoreThanOnce.java
│ │ │ │ ├── UserRegistrationMustBeConfirmed.java
│ │ │ │ └── UserRegistrationMustBeUnique.java
│ │ │ ├── session/
│ │ │ │ ├── JwtTokenProvider.java
│ │ │ │ ├── Session.java
│ │ │ │ ├── SessionAuthenticationService.java
│ │ │ │ ├── SessionId.java
│ │ │ │ ├── SessionRepository.java
│ │ │ │ ├── TokenProvider.java
│ │ │ │ ├── events/
│ │ │ │ │ └── SessionCreated.java
│ │ │ │ └── rule/
│ │ │ │ └── SessionCannotBeExpiredWhenRefreshTokenIsMissing.java
│ │ │ └── users/
│ │ │ ├── EmailLogin.java
│ │ │ ├── User.java
│ │ │ ├── UserId.java
│ │ │ ├── UserRepository.java
│ │ │ ├── events/
│ │ │ │ ├── UserCreated.java
│ │ │ │ └── UserNameChanged.java
│ │ │ └── rules/
│ │ │ └── UserEmailMustBeUnique.java
│ │ └── infrastructure/
│ │ ├── McAuthenticationModuleExecutor.java
│ │ ├── http/
│ │ │ └── oauth2/
│ │ │ ├── AbstractOAuth2Authentication.java
│ │ │ ├── CustomOAuth2UserService.java
│ │ │ ├── FacebookOAuth2Authentication.java
│ │ │ ├── GoogleOAuth2Authentication.java
│ │ │ └── user/
│ │ │ ├── FacebookOAuth2UserInfo.java
│ │ │ ├── GoogleOAuth2UserInfo.java
│ │ │ ├── OAuth2UserInfo.java
│ │ │ └── OAuth2UserInfoFactory.java
│ │ ├── persistence/
│ │ │ ├── BaseJpaAdapter.java
│ │ │ ├── SessionJpaRepository.java
│ │ │ ├── SessionRepositoryJpaAdapter.java
│ │ │ ├── UserJpaRepository.java
│ │ │ ├── UserRegistrationJpaRepository.java
│ │ │ ├── UserRegistrationJpaRepositoryAdapter.java
│ │ │ └── UserRepositoryJpaAdapter.java
│ │ ├── processing/
│ │ │ ├── ErrorCommandHandlerDecorator.java
│ │ │ ├── LoggingCommandHandlerDecorator.java
│ │ │ ├── LoggingQueryHandlerDecorator.java
│ │ │ ├── PipelineBuilder.java
│ │ │ └── builder/
│ │ │ ├── AbstractPipelineBuilder.java
│ │ │ ├── CommandHandlerPipelineBuilder.java
│ │ │ └── QueryHandlerPipelineBuilder.java
│ │ ├── service/
│ │ │ └── MD5EncryptionService.java
│ │ ├── springboot/
│ │ │ ├── configuration/
│ │ │ │ ├── AppConfig.java
│ │ │ │ ├── AppProperties.java
│ │ │ │ ├── GUIProperties.java
│ │ │ │ ├── MessageProperties.java
│ │ │ │ ├── SecurityConfig.java
│ │ │ │ ├── SwaggerConfig.java
│ │ │ │ └── SwaggerUiWebMvcConfigurer.java
│ │ │ ├── controller/
│ │ │ │ ├── AbstractController.java
│ │ │ │ ├── AuthenticationController.java
│ │ │ │ ├── RegistrationController.java
│ │ │ │ ├── RestApiRoutes.java
│ │ │ │ └── UserController.java
│ │ │ ├── filter/
│ │ │ │ └── TokenAuthenticationFilter.java
│ │ │ └── security/
│ │ │ ├── CurrentUser.java
│ │ │ ├── OAuth2AuthenticationFailureHandler.java
│ │ │ ├── OAuth2AuthenticationSuccessHandler.java
│ │ │ ├── UserAuthPrincipal.java
│ │ │ └── UserAuthToken.java
│ │ └── util/
│ │ └── CookieUtils.java
│ └── resources/
│ ├── application.yml
│ ├── db/
│ │ └── migration/
│ │ └── V2022_02_02_1124__initial_structure.sql
│ └── repo/
│ └── org/
│ └── tomo/
│ └── ddd_common/
│ ├── 1.0.0/
│ │ ├── ddd_common-1.0.0.jar
│ │ ├── ddd_common-1.0.0.jar.md5
│ │ ├── ddd_common-1.0.0.jar.sha1
│ │ ├── ddd_common-1.0.0.pom
│ │ ├── ddd_common-1.0.0.pom.md5
│ │ └── ddd_common-1.0.0.pom.sha1
│ ├── maven-metadata.xml
│ ├── maven-metadata.xml.md5
│ └── maven-metadata.xml.sha1
└── test/
├── java/
│ └── com/
│ └── tomo/
│ └── mcauthentication/
│ ├── integration/
│ │ ├── BaseIntegrationTest.java
│ │ └── application/
│ │ ├── AbstractApplicationServiceTest.java
│ │ ├── authentication/
│ │ │ ├── EmailLoginCommandHandlerTest.java
│ │ │ ├── FacebookLoginCommandHandlerTest.java
│ │ │ ├── GoogleLoginCommandHandlerTest.java
│ │ │ ├── LogoutCommandHandlerTest.java
│ │ │ └── SessionAuthenticationCommandHandlerTest.java
│ │ ├── recovery/
│ │ │ ├── CreatePasswordRecoveryCodeCommandHandlerTest.java
│ │ │ ├── GetUserRegistrationWithRecoveryCodeQueryHandlerTest.java
│ │ │ └── UpdatePasswordWithRecoveryCodeCommandHandlerTest.java
│ │ ├── registration/
│ │ │ ├── ChangePasswordCommandHandlerTest.java
│ │ │ ├── ConfirmUserRegistrationCommandHandlerTest.java
│ │ │ └── RegisterNewUserCommandHandlerTest.java
│ │ └── users/
│ │ ├── ChangeUserDetailsCommandHandlerTest.java
│ │ └── GetUserQueryHandlerTest.java
│ ├── smoke/
│ │ └── McAuthenticationApplicationSmokeTest.java
│ ├── testdata/
│ │ ├── CommandObjectMother.java
│ │ └── StaticFields.java
│ ├── unit/
│ │ ├── application/
│ │ │ └── registration/
│ │ │ └── UserRegistrationCommandHandlerTest.java
│ │ └── domain/
│ │ ├── AbstractUnitTest.java
│ │ ├── registration/
│ │ │ ├── UserRegistrationTest.java
│ │ │ └── rules/
│ │ │ ├── PasswordRecoveryCodeShouldBeExpiredOrNullTest.java
│ │ │ ├── PasswordRecoveryCodeShouldNotExpiredTest.java
│ │ │ ├── PasswordsMustMatchTest.java
│ │ │ ├── RecoveryCodeMustMatchTest.java
│ │ │ ├── UserRegistrationCannotBeConfirmedAfterExpirationTest.java
│ │ │ ├── UserRegistrationCannotBeConfirmedMoreThanOnceTest.java
│ │ │ ├── UserRegistrationMustBeConfirmedTest.java
│ │ │ └── UserRegistrationMustBeUniqueTest.java
│ │ ├── session/
│ │ │ └── rules/
│ │ │ └── SessionCannotBeExpiredWhenRefreshTokenIsMissingTest.java
│ │ └── user/
│ │ └── rules/
│ │ └── UserEmailMustBeUniqueTest.java
│ └── weblayer/
│ ├── BaseWebLayerTest.java
│ └── springboot/
│ └── controller/
│ ├── AbstractControllerTest.java
│ └── RegistrationControllerTest.java
└── resources/
└── application-ci.yml
SYMBOL INDEX (639 symbols across 183 files)
FILE: .mvn/wrapper/MavenWrapperDownloader.java
class MavenWrapperDownloader (line 21) | public class MavenWrapperDownloader {
method main (line 48) | public static void main(String args[]) {
method downloadFileFromURL (line 97) | private static void downloadFileFromURL(String urlString, File destina...
FILE: src/main/java/com/tomo/mcauthentication/McAuthenticationApplication.java
class McAuthenticationApplication (line 16) | @EnableWebMvc
method main (line 25) | public static void main(String[] args) {
FILE: src/main/java/com/tomo/mcauthentication/application/BaseMapper.java
class BaseMapper (line 5) | public class BaseMapper {
method BaseMapper (line 8) | public BaseMapper() {}
method BaseMapper (line 10) | public BaseMapper(ModelMapper modelMapper) {
method toDto (line 14) | protected <T, E> T toDto(E source, Class<T> destinationType) {
FILE: src/main/java/com/tomo/mcauthentication/application/McAuthenticationEventHandler.java
class McAuthenticationEventHandler (line 12) | @Aspect
method McAuthenticationEventHandler (line 18) | public McAuthenticationEventHandler(EventStore eventStore) {
method listen (line 22) | @Before(value = "execution(* *(..)) && within(com.tomo.mcauthenticatio...
method store (line 42) | private void store(DomainEvent aDomainEvent) {
method eventStore (line 50) | private EventStore eventStore() {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/BaseLoginCommandHandler.java
class BaseLoginCommandHandler (line 11) | public class BaseLoginCommandHandler extends BaseMapper {
method BaseLoginCommandHandler (line 15) | public BaseLoginCommandHandler() {
method BaseLoginCommandHandler (line 18) | public BaseLoginCommandHandler(ModelMapper modelMapper, TokenProvider ...
method BaseLoginCommandHandler (line 23) | public BaseLoginCommandHandler(
method toDto (line 32) | protected SessionDto toDto(Session session) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/EmailLoginCommandHandler.java
class EmailLoginCommandHandler (line 16) | @Component
method EmailLoginCommandHandler (line 21) | public EmailLoginCommandHandler(
method handle (line 31) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/FacebookLoginCommandHandler.java
class FacebookLoginCommandHandler (line 16) | @Component
method FacebookLoginCommandHandler (line 21) | public FacebookLoginCommandHandler(
method handle (line 31) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/GoogleLoginCommandHandler.java
class GoogleLoginCommandHandler (line 16) | @Component
method GoogleLoginCommandHandler (line 21) | public GoogleLoginCommandHandler(
method handle (line 31) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/LogoutCommandHandler.java
class LogoutCommandHandler (line 9) | @Service
method LogoutCommandHandler (line 14) | public LogoutCommandHandler(SessionAuthenticationService sessionAuthen...
method abstractHandle (line 18) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/SessionAuthenticationCommandHandler.java
class SessionAuthenticationCommandHandler (line 13) | @Service
method SessionAuthenticationCommandHandler (line 18) | public SessionAuthenticationCommandHandler(
method handle (line 25) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/BaseLoginCommand.java
class BaseLoginCommand (line 8) | @Getter
method BaseLoginCommand (line 15) | public BaseLoginCommand() {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/EmailLoginCommand.java
class EmailLoginCommand (line 9) | @Setter
method EmailLoginCommand (line 22) | public EmailLoginCommand() {
method EmailLoginCommand (line 26) | public EmailLoginCommand(String email, String password) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/FacebookLoginCommand.java
class FacebookLoginCommand (line 7) | @Setter
method FacebookLoginCommand (line 13) | public FacebookLoginCommand(String accessCode) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/GoogleLoginCommand.java
class GoogleLoginCommand (line 7) | @Setter
method GoogleLoginCommand (line 13) | public GoogleLoginCommand(String accessCode) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/LogoutCommand.java
class LogoutCommand (line 9) | @Setter
method LogoutCommand (line 14) | public LogoutCommand(String authToken) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/command/SessionAuthenticationCommand.java
class SessionAuthenticationCommand (line 9) | @Getter
method SessionAuthenticationCommand (line 14) | public SessionAuthenticationCommand(String authToken) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/dto/RecoveryPasswordDto.java
class RecoveryPasswordDto (line 7) | @Getter
method RecoveryPasswordDto (line 12) | public RecoveryPasswordDto(String recoveryCode) {
FILE: src/main/java/com/tomo/mcauthentication/application/authentication/dto/SessionDto.java
class SessionDto (line 16) | @Getter
method create (line 31) | public static SessionDto create(Session session, ModelMapper mapper) {
method setSessionId (line 38) | public void setSessionId(SessionId sessionId) {
method setTokenType (line 42) | public void setTokenType(Session.TokenType tokenType) {
method setUserId (line 46) | public void setUserId(UserId userId) {
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/AbstractVoidyCommandHandler.java
class AbstractVoidyCommandHandler (line 8) | public abstract class AbstractVoidyCommandHandler<T extends Command> imp...
method handle (line 10) | @Override
method abstractHandle (line 17) | abstract protected void abstractHandle(T aCommand);
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/CommandHandler.java
type CommandHandler (line 6) | public interface CommandHandler<T extends Command, R extends Response> e...
method handle (line 7) | R handle(T aCommand);
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/QueryHandler.java
type QueryHandler (line 6) | public interface QueryHandler<T extends Query, R extends Response> exten...
method handle (line 7) | R handle(T query);
FILE: src/main/java/com/tomo/mcauthentication/application/configuration/RequestHandler.java
type RequestHandler (line 6) | public interface RequestHandler<T extends Request, R extends Response> {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseCommand.java
class BaseCommand (line 3) | public class BaseCommand extends BaseRequest implements Command {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseQuery.java
class BaseQuery (line 3) | public class BaseQuery extends BaseRequest implements Query {}
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/BaseRequest.java
class BaseRequest (line 5) | public class BaseRequest implements Request {
method BaseRequest (line 9) | public BaseRequest() {
method BaseRequest (line 13) | public BaseRequest(UUID anId) {
method id (line 17) | @Override
method setId (line 22) | protected void setId(UUID anId) {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Command.java
type Command (line 3) | public interface Command extends Request {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Identifiable.java
type Identifiable (line 5) | public interface Identifiable {
method id (line 7) | UUID id();
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/McAuthenticationModule.java
type McAuthenticationModule (line 5) | @Component
method executeCommand (line 7) | Response executeCommand(Command command);
method executeQuery (line 9) | Response executeQuery(Query query);
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Query.java
type Query (line 3) | public interface Query extends Request {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Request.java
type Request (line 3) | public interface Request extends Identifiable {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Response.java
type Response (line 3) | public interface Response {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/Voidy.java
class Voidy (line 3) | public class Voidy implements Response {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateCommand.java
class AbstractAuthenticateCommand (line 9) | @Getter
method AbstractAuthenticateCommand (line 14) | public AbstractAuthenticateCommand(String authToken) {
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateQuery.java
class AbstractAuthenticateQuery (line 11) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateRequest.java
class AbstractAuthenticateRequest (line 11) | @Getter
method AbstractAuthenticateRequest (line 18) | public AbstractAuthenticateRequest(String authToken) {
method authToken (line 22) | @Override
method setAuthToken (line 27) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeCommand.java
class AbstractAuthorizeCommand (line 9) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeQuery.java
class AbstractAuthorizeQuery (line 10) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeRequest.java
class AbstractAuthorizeRequest (line 10) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/Authenticate.java
type Authenticate (line 3) | public interface Authenticate {
method authToken (line 5) | String authToken();
method setAuthToken (line 7) | void setAuthToken(String authToken);
FILE: src/main/java/com/tomo/mcauthentication/application/contracts/security/Authorize.java
type Authorize (line 5) | public interface Authorize extends Authenticate {
method getAuthorities (line 7) | default List<String> getAuthorities() {
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/CreatePasswordRecoveryCodeCommandHandler.java
class CreatePasswordRecoveryCodeCommandHandler (line 10) | @Service
method CreatePasswordRecoveryCodeCommandHandler (line 15) | public CreatePasswordRecoveryCodeCommandHandler(EmailAuthenticationSer...
method handle (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/GetUserRegistrationWithRecoveryCodeQueryHandler.java
class GetUserRegistrationWithRecoveryCodeQueryHandler (line 14) | @Component
method GetUserRegistrationWithRecoveryCodeQueryHandler (line 20) | public GetUserRegistrationWithRecoveryCodeQueryHandler(
method handle (line 29) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/PasswordRecoveryCodeCreatedEventHandler.java
class PasswordRecoveryCodeCreatedEventHandler (line 13) | @Aspect
method PasswordRecoveryCodeCreatedEventHandler (line 25) | public PasswordRecoveryCodeCreatedEventHandler(McAuthenticationModule ...
method listen (line 30) | @Before("execution(" +
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/SendPasswordRecoveryEmailCommandHandler.java
class SendPasswordRecoveryEmailCommandHandler (line 10) | @Component
method SendPasswordRecoveryEmailCommandHandler (line 15) | public SendPasswordRecoveryEmailCommandHandler(EmailSender emailMessag...
method abstractHandle (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/UpdatePasswordWithRecoveryCodeCommandHandler.java
class UpdatePasswordWithRecoveryCodeCommandHandler (line 9) | @Service
method UpdatePasswordWithRecoveryCodeCommandHandler (line 14) | public UpdatePasswordWithRecoveryCodeCommandHandler(EmailAuthenticatio...
method abstractHandle (line 18) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/CreatePasswordRecoveryCodeCommand.java
class CreatePasswordRecoveryCodeCommand (line 11) | @Getter
method CreatePasswordRecoveryCodeCommand (line 19) | public CreatePasswordRecoveryCodeCommand(String email) {
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/SendPasswordRecoveryEmailCommand.java
class SendPasswordRecoveryEmailCommand (line 11) | @Getter
method SendPasswordRecoveryEmailCommand (line 21) | public SendPasswordRecoveryEmailCommand(String email, String recoveryC...
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/command/UpdatePasswordWithRecoveryCodeCommand.java
class UpdatePasswordWithRecoveryCodeCommand (line 11) | @Getter
method UpdatePasswordWithRecoveryCodeCommand (line 25) | public UpdatePasswordWithRecoveryCodeCommand(String newPassword, Strin...
FILE: src/main/java/com/tomo/mcauthentication/application/recovery/dto/GetUserRegistrationWithRecoveryCodeQuery.java
class GetUserRegistrationWithRecoveryCodeQuery (line 11) | @Getter
method GetUserRegistrationWithRecoveryCodeQuery (line 19) | public GetUserRegistrationWithRecoveryCodeQuery(String recoveryCode) {
FILE: src/main/java/com/tomo/mcauthentication/application/registration/ChangePasswordCommandHandler.java
class ChangePasswordCommandHandler (line 13) | @Service
method ChangePasswordCommandHandler (line 20) | public ChangePasswordCommandHandler(
method abstractHandle (line 29) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/registration/ConfirmUserRegistrationCommandHandler.java
class ConfirmUserRegistrationCommandHandler (line 13) | @Component
method ConfirmUserRegistrationCommandHandler (line 19) | public ConfirmUserRegistrationCommandHandler(
method handle (line 26) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/registration/GetUserRegistrationQueryHandler.java
class GetUserRegistrationQueryHandler (line 7) | public class GetUserRegistrationQueryHandler implements QueryHandler<Get...
method handle (line 9) | @Override public UserRegistrationDto handle(GetUserRegistrationQuery r...
FILE: src/main/java/com/tomo/mcauthentication/application/registration/NewUserRegisteredEventHandler.java
class NewUserRegisteredEventHandler (line 13) | @Aspect
method NewUserRegisteredEventHandler (line 25) | public NewUserRegisteredEventHandler(McAuthenticationModule authentica...
method listen (line 30) | @Before(value = "execution(public * com.tomo.mcauthentication.applicat...
FILE: src/main/java/com/tomo/mcauthentication/application/registration/RegisterNewUserCommandHandler.java
class RegisterNewUserCommandHandler (line 11) | @Component
method RegisterNewUserCommandHandler (line 17) | public RegisterNewUserCommandHandler(
method abstractHandle (line 24) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/registration/SendRegistrationConfirmationEmailCommandHandler.java
class SendRegistrationConfirmationEmailCommandHandler (line 10) | @Component
method SendRegistrationConfirmationEmailCommandHandler (line 15) | public SendRegistrationConfirmationEmailCommandHandler(EmailSender ema...
method abstractHandle (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/ChangePasswordCommand.java
class ChangePasswordCommand (line 11) | @Getter
method ChangePasswordCommand (line 27) | public ChangePasswordCommand(String accessToken, String oldPassword, S...
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/ConfirmUserRegistrationCommand.java
class ConfirmUserRegistrationCommand (line 11) | @Setter
method ConfirmUserRegistrationCommand (line 18) | public ConfirmUserRegistrationCommand(String confirmLink) {
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/RegisterNewUserCommand.java
class RegisterNewUserCommand (line 12) | @Getter
method RegisterNewUserCommand (line 29) | public RegisterNewUserCommand(String firstName, String lastName, Strin...
method getPassword (line 36) | public String getPassword() {
method setPassword (line 40) | public void setPassword(String password) {
method getEmail (line 44) | public String getEmail() {
method setEmail (line 48) | public void setEmail(String email) {
method getFirstName (line 52) | public String getFirstName() {
method setFirstName (line 56) | public void setFirstName(String firstName) {
method getLastName (line 60) | public String getLastName() {
method setLastName (line 64) | public void setLastName(String lastName) {
FILE: src/main/java/com/tomo/mcauthentication/application/registration/command/SendRegistrationConfirmationEmailCommand.java
class SendRegistrationConfirmationEmailCommand (line 9) | @Getter
method SendRegistrationConfirmationEmailCommand (line 17) | public SendRegistrationConfirmationEmailCommand(String email, String c...
FILE: src/main/java/com/tomo/mcauthentication/application/registration/dto/UserRegistrationDto.java
class UserRegistrationDto (line 13) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/registration/query/GetUserRegistrationQuery.java
class GetUserRegistrationQuery (line 11) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/application/users/ChangeUserDetailsCommandHandler.java
class ChangeUserDetailsCommandHandler (line 15) | @Service
method abstractHandle (line 23) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/users/GetUserQueryHandler.java
class GetUserQueryHandler (line 13) | @Component
method GetUserQueryHandler (line 18) | public GetUserQueryHandler(
method handle (line 25) | @Override
method toDto (line 36) | private BaseUserDto toDto(User user) {
FILE: src/main/java/com/tomo/mcauthentication/application/users/command/ChangeUserDetailsCommand.java
class ChangeUserDetailsCommand (line 12) | @Getter
method ChangeUserDetailsCommand (line 21) | public ChangeUserDetailsCommand(UUID userId, String firstName, String ...
method getAuthorities (line 27) | @Override
FILE: src/main/java/com/tomo/mcauthentication/application/users/dto/BaseUserDto.java
class BaseUserDto (line 10) | @Getter
method setUserId (line 18) | public void setUserId(UserId userId) {
FILE: src/main/java/com/tomo/mcauthentication/application/users/query/GetUserQuery.java
class GetUserQuery (line 12) | @Getter
method GetUserQuery (line 19) | public GetUserQuery(String userId) {
method getUserId (line 23) | public UserId getUserId() {
FILE: src/main/java/com/tomo/mcauthentication/domain/DomainRegistry.java
class DomainRegistry (line 16) | @Component
method encryptionService (line 21) | public static EncryptionService encryptionService() {
method passwordService (line 25) | public static PasswordService passwordService() {
method tokenProvider (line 29) | public static TokenProvider tokenProvider() {
method modelMapper (line 33) | public static ModelMapper modelMapper() {
method userRepository (line 37) | public static UserRepository userRepository() {
method userRegistrationRepository (line 41) | public static UserRegistrationRepository userRegistrationRepository() {
method userEmailMustBeUnique (line 45) | public static UserEmailMustBeUnique userEmailMustBeUnique(String anEma...
method userRegistrationMustBeUnique (line 49) | public static UserRegistrationMustBeUnique userRegistrationMustBeUniqu...
method setApplicationContext (line 53) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/EncryptionService.java
type EncryptionService (line 3) | public interface EncryptionService {
method encryptedValue (line 5) | String encryptedValue(String aPlainTextValue);
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Authentication.java
type OAuth2Authentication (line 3) | public interface OAuth2Authentication {
method authenticate (line 4) | OAuth2Principal authenticate(String anAccessCode);
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Principal.java
class OAuth2Principal (line 6) | @Getter
method OAuth2Principal (line 16) | public OAuth2Principal(String id, String email, String firstName, Stri...
FILE: src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Service.java
class OAuth2Service (line 8) | public class OAuth2Service {
method OAuth2Service (line 13) | public OAuth2Service(OAuth2Authentication oAuth2Authentication, UserRe...
method registerAuthenticate (line 18) | public User registerAuthenticate(String anAccessCode) {
method authenticateAndRegister (line 37) | protected User authenticateAndRegister(OAuth2Principal principal) {
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/EmailAuthenticationService.java
class EmailAuthenticationService (line 11) | @Service
method EmailAuthenticationService (line 18) | public EmailAuthenticationService(
method authenticate (line 27) | public User authenticate(
method createPasswordRecoveryCode (line 44) | public String createPasswordRecoveryCode(String anEmail) {
method recoverPasswordWithRecoveryCode (line 56) | public void recoverPasswordWithRecoveryCode(String aRecoveryCode, Stri...
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/PasswordService.java
class PasswordService (line 9) | @Component
method PasswordService (line 18) | public PasswordService() {
method generateStrongPassword (line 22) | public String generateStrongPassword() {
method isStrong (line 66) | public boolean isStrong(String aPlainTextPassword) {
method isVeryStrong (line 70) | public boolean isVeryStrong(String aPlainTextPassword) {
method isWeak (line 74) | public boolean isWeak(String aPlainTextPassword) {
method calculatePasswordStrength (line 78) | private int calculatePasswordStrength(String aPlainTextPassword) {
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistration.java
class UserRegistration (line 40) | @Entity
method registerNewUser (line 66) | public static UserRegistration registerNewUser(
method UserRegistration (line 75) | private UserRegistration(
method createUser (line 101) | public User createUser(UserRepository userRespository) {
method createRecoveryCode (line 115) | public String createRecoveryCode() {
method isRecoveryCodeUnexpired (line 134) | public boolean isRecoveryCodeUnexpired() {
method isRecoveryCodeExpired (line 138) | public boolean isRecoveryCodeExpired() {
method changePassword (line 142) | public void changePassword(String anOldPassword, String aNewPassword, ...
method changePasswordWithRecoveryCode (line 153) | public void changePasswordWithRecoveryCode(String aRecoveryCode, Strin...
method assertNewPassword (line 170) | protected void assertNewPassword(String aNewPassword, String aNewPassw...
method protectPassword (line 176) | protected void protectPassword(String aCurrentPassword, String aChange...
method assertPasswordsNotSame (line 183) | protected void assertPasswordsNotSame(String aCurrentPassword, String ...
method assertPasswordNotWeak (line 190) | protected void assertPasswordNotWeak(String aPlainTextPassword) {
method assertUsernamePasswordNotSame (line 196) | protected void assertUsernamePasswordNotSame(String aPlainTextPassword) {
method asEncryptedValue (line 203) | protected String asEncryptedValue(String aPlainTextPassword) {
method setPassword (line 212) | protected void setPassword(String aPassword) {
method publishEvent (line 216) | private void publishEvent(DomainEvent domainEvent) {
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationId.java
class UserRegistrationId (line 12) | @Embeddable
method UserRegistrationId (line 18) | public UserRegistrationId(UUID anId) {
method hashPrimeValue (line 22) | @Override
method hashOddValue (line 27) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationRepository.java
type UserRegistrationRepository (line 8) | public interface UserRegistrationRepository extends BaseRepository<UserR...
method findAllByEmail (line 9) | List<UserRegistration> findAllByEmail(List<String> emails);
method findByEmail (line 10) | UserRegistration findByEmail(String anEmail);
method countByEmailAndStatus (line 11) | long countByEmailAndStatus(String email, UserRegistrationStatus status);
method findByConfirmationCode (line 12) | UserRegistration findByConfirmationCode(String confirmationCode);
method findByRecoveryCode (line 13) | UserRegistration findByRecoveryCode(String aRecoveryCode);
method findByUserId (line 14) | UserRegistration findByUserId(UserId anUserId);
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationStatus.java
type UserRegistrationStatus (line 2) | public enum
method UserRegistrationStatus (line 10) | UserRegistrationStatus(String value) {
method toString (line 14) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/UsersCounter.java
type UsersCounter (line 3) | public interface UsersCounter {
method countUsersWithLogin (line 4) | int countUsersWithLogin();
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordChanged.java
class PasswordChanged (line 9) | @Getter
method PasswordChanged (line 16) | public PasswordChanged(long userRegistrationId, String password) {
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecovered.java
class PasswordRecovered (line 9) | @Getter
method PasswordRecovered (line 17) | public PasswordRecovered(long userRegistrationId, String password, Str...
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecoveryCodeCreated.java
class PasswordRecoveryCodeCreated (line 11) | @Getter
method PasswordRecoveryCodeCreated (line 20) | public PasswordRecoveryCodeCreated(long userRegistrationId, String ema...
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationConfirmed.java
class UserRegistrationConfirmed (line 11) | @Getter
method UserRegistrationConfirmed (line 19) | public UserRegistrationConfirmed(long userRegistrationId, UserRegistra...
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationRequested.java
class UserRegistrationRequested (line 12) | @Getter
method UserRegistrationRequested (line 24) | public UserRegistrationRequested(
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldBeExpiredOrNull.java
class PasswordRecoveryCodeShouldBeExpiredOrNull (line 6) | public class PasswordRecoveryCodeShouldBeExpiredOrNull implements Busine...
method PasswordRecoveryCodeShouldBeExpiredOrNull (line 10) | public PasswordRecoveryCodeShouldBeExpiredOrNull(UserRegistration aUse...
method isRuleComplied (line 14) | @Override
method message (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldNotExpired.java
class PasswordRecoveryCodeShouldNotExpired (line 6) | public class PasswordRecoveryCodeShouldNotExpired implements BusinessRule {
method PasswordRecoveryCodeShouldNotExpired (line 10) | public PasswordRecoveryCodeShouldNotExpired(UserRegistration aUserRegi...
method isRuleComplied (line 14) | @Override
method message (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordsMustMatch.java
class PasswordsMustMatch (line 5) | public class PasswordsMustMatch implements BusinessRule {
method PasswordsMustMatch (line 10) | public PasswordsMustMatch(String storedPassword, String providedPassow...
method isRuleComplied (line 15) | @Override
method message (line 20) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/RecoveryCodeMustMatch.java
class RecoveryCodeMustMatch (line 5) | public class RecoveryCodeMustMatch implements BusinessRule {
method RecoveryCodeMustMatch (line 10) | public RecoveryCodeMustMatch(String aStoredCode, String aProvidedCode) {
method isRuleComplied (line 15) | @Override
method message (line 20) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedAfterExpiration.java
class UserRegistrationCannotBeConfirmedAfterExpiration (line 7) | public class UserRegistrationCannotBeConfirmedAfterExpiration implements...
method UserRegistrationCannotBeConfirmedAfterExpiration (line 13) | public UserRegistrationCannotBeConfirmedAfterExpiration(LocalDateTime ...
method isRuleComplied (line 17) | @Override
method message (line 22) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedMoreThanOnce.java
class UserRegistrationCannotBeConfirmedMoreThanOnce (line 6) | public class UserRegistrationCannotBeConfirmedMoreThanOnce implements Bu...
method UserRegistrationCannotBeConfirmedMoreThanOnce (line 10) | public UserRegistrationCannotBeConfirmedMoreThanOnce(UserRegistrationS...
method isRuleComplied (line 14) | @Override
method message (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeConfirmed.java
class UserRegistrationMustBeConfirmed (line 6) | public class UserRegistrationMustBeConfirmed implements BusinessRule {
method UserRegistrationMustBeConfirmed (line 10) | public UserRegistrationMustBeConfirmed(UserRegistrationStatus anUserRe...
method isRuleComplied (line 14) | @Override
method message (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeUnique.java
class UserRegistrationMustBeUnique (line 7) | public class UserRegistrationMustBeUnique implements BusinessRule {
method UserRegistrationMustBeUnique (line 12) | public UserRegistrationMustBeUnique(UserRegistrationRepository usersCo...
method isRuleComplied (line 17) | @Override
method message (line 22) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/session/JwtTokenProvider.java
class JwtTokenProvider (line 24) | @Service
method JwtTokenProvider (line 32) | public JwtTokenProvider(AppProperties appProperties) {
method createToken (line 36) | @Override public String createToken(User user) {
method getUserIdFromToken (line 48) | @Override
method validateToken (line 59) | @Override
method getTokenType (line 83) | @Override
method createRefreshToken (line 88) | @Override public String createRefreshToken(User user) {
method secretKey (line 92) | private SecretKey secretKey() {
FILE: src/main/java/com/tomo/mcauthentication/domain/session/Session.java
class Session (line 24) | @Entity
type TokenType (line 32) | public enum TokenType {
method Session (line 55) | public Session(SessionId sessionId, User user, TokenProvider tokenProv...
method isExpired (line 74) | public boolean isExpired() {
method protectedAccessToken (line 78) | private void protectedAccessToken(String anToken) {
method protectedRefreshToken (line 83) | private void protectedRefreshToken(String anToken) {
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionAuthenticationService.java
class SessionAuthenticationService (line 12) | @Service
method SessionAuthenticationService (line 19) | public SessionAuthenticationService(
method authenticate (line 28) | public Session authenticate(String anAccessToken) {
method logout (line 52) | public Session logout(String anAccessToken) {
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionId.java
class SessionId (line 12) | @Embeddable
method SessionId (line 18) | public SessionId(UUID id) {
method hashOddValue (line 22) | @Override
method hashPrimeValue (line 27) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/session/SessionRepository.java
type SessionRepository (line 8) | public interface SessionRepository extends BaseRepository<Session, Sessi...
method nextIdentity (line 9) | SessionId nextIdentity();
method findByUserId (line 10) | List<Session> findByUserId(UserId userId);
method findByAccessToken (line 11) | Session findByAccessToken(String anAccessToken);
FILE: src/main/java/com/tomo/mcauthentication/domain/session/TokenProvider.java
type TokenProvider (line 6) | public interface TokenProvider {
method createToken (line 7) | String createToken(User user);
method createRefreshToken (line 8) | String createRefreshToken(User user);
method getUserIdFromToken (line 9) | UserId getUserIdFromToken(String anAuthToken);
method validateToken (line 10) | boolean validateToken(String anAuthToken);
method getTokenType (line 11) | Session.TokenType getTokenType();
FILE: src/main/java/com/tomo/mcauthentication/domain/session/events/SessionCreated.java
class SessionCreated (line 11) | @Getter
method SessionCreated (line 18) | public SessionCreated(SessionId sessionId, UserId userId) {
FILE: src/main/java/com/tomo/mcauthentication/domain/session/rule/SessionCannotBeExpiredWhenRefreshTokenIsMissing.java
class SessionCannotBeExpiredWhenRefreshTokenIsMissing (line 6) | public class SessionCannotBeExpiredWhenRefreshTokenIsMissing implements ...
method SessionCannotBeExpiredWhenRefreshTokenIsMissing (line 10) | public SessionCannotBeExpiredWhenRefreshTokenIsMissing(Session session) {
method isRuleComplied (line 14) | @Override
method message (line 19) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/users/EmailLogin.java
class EmailLogin (line 3) | public class EmailLogin {
FILE: src/main/java/com/tomo/mcauthentication/domain/users/User.java
class User (line 18) | @Entity(name = "mcuser")
type AuthProvider (line 23) | public enum AuthProvider {
method User (line 38) | public User(
method updateDetails (line 60) | public void updateDetails(String aFirstName, String aLastName) {
method setLastName (line 70) | public void setLastName(String aLastName) {
method setFirstName (line 75) | public void setFirstName(String aFirstName) {
method publish (line 80) | private void publish(DomainEvent event) {
FILE: src/main/java/com/tomo/mcauthentication/domain/users/UserId.java
class UserId (line 13) | @Embeddable
method UserId (line 19) | public UserId(UUID id) {
method UserId (line 23) | public UserId(String id) {
method hashOddValue (line 27) | @Override
method hashPrimeValue (line 32) | @Override
FILE: src/main/java/com/tomo/mcauthentication/domain/users/UserRepository.java
type UserRepository (line 5) | public interface UserRepository extends BaseRepository<User, UserId> {
method nextIdentity (line 6) | UserId nextIdentity();
method findByEmail (line 7) | User findByEmail(String anEmail);
FILE: src/main/java/com/tomo/mcauthentication/domain/users/events/UserCreated.java
class UserCreated (line 11) | @Getter
method UserCreated (line 21) | public UserCreated(UserId userId, String firstName, String lastName, S...
FILE: src/main/java/com/tomo/mcauthentication/domain/users/events/UserNameChanged.java
class UserNameChanged (line 9) | @Getter
method UserNameChanged (line 17) | public UserNameChanged(String email, String firstName, String lastName) {
FILE: src/main/java/com/tomo/mcauthentication/domain/users/rules/UserEmailMustBeUnique.java
class UserEmailMustBeUnique (line 6) | public class UserEmailMustBeUnique implements BusinessRule {
method UserEmailMustBeUnique (line 11) | public UserEmailMustBeUnique(UserRepository userRespository, String em...
method isRuleComplied (line 16) | @Override
method message (line 21) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/McAuthenticationModuleExecutor.java
class McAuthenticationModuleExecutor (line 14) | @Component
method McAuthenticationModuleExecutor (line 21) | public McAuthenticationModuleExecutor(
method executeCommand (line 28) | @Override
method executeQuery (line 37) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/AbstractOAuth2Authentication.java
class AbstractOAuth2Authentication (line 14) | public abstract class AbstractOAuth2Authentication {
method AbstractOAuth2Authentication (line 19) | public AbstractOAuth2Authentication(ClientRegistration clientRegistrat...
method authenticateUser (line 25) | protected OAuth2Principal authenticateUser(String anAccessCode) {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/CustomOAuth2UserService.java
class CustomOAuth2UserService (line 9) | @Service
method loadUser (line 12) | public OAuth2User loadUser(OAuth2UserRequest oAuth2UserRequest) throws...
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/FacebookOAuth2Authentication.java
class FacebookOAuth2Authentication (line 13) | @Service
method FacebookOAuth2Authentication (line 16) | public FacebookOAuth2Authentication(
method authenticate (line 22) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/GoogleOAuth2Authentication.java
class GoogleOAuth2Authentication (line 13) | @Service
method GoogleOAuth2Authentication (line 16) | public GoogleOAuth2Authentication(
method authenticate (line 22) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/FacebookOAuth2UserInfo.java
class FacebookOAuth2UserInfo (line 5) | public class FacebookOAuth2UserInfo extends OAuth2UserInfo {
method FacebookOAuth2UserInfo (line 6) | public FacebookOAuth2UserInfo(Map<String, Object> attributes) {
method getId (line 10) | @Override
method getName (line 15) | @Override
method getEmail (line 20) | @Override
method getImageUrl (line 25) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/GoogleOAuth2UserInfo.java
class GoogleOAuth2UserInfo (line 5) | public class GoogleOAuth2UserInfo extends OAuth2UserInfo {
method GoogleOAuth2UserInfo (line 7) | public GoogleOAuth2UserInfo(Map<String, Object> attributes) {
method getId (line 11) | @Override
method getName (line 16) | @Override
method getEmail (line 21) | @Override
method getImageUrl (line 26) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfo.java
class OAuth2UserInfo (line 5) | public abstract class OAuth2UserInfo {
method OAuth2UserInfo (line 8) | public OAuth2UserInfo(Map<String, Object> attributes) {
method getAttributes (line 12) | public Map<String, Object> getAttributes() {
method getId (line 16) | public abstract String getId();
method getName (line 18) | public abstract String getName();
method getEmail (line 20) | public abstract String getEmail();
method getImageUrl (line 22) | public abstract String getImageUrl();
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfoFactory.java
class OAuth2UserInfoFactory (line 7) | public class OAuth2UserInfoFactory {
method getOAuth2UserInfo (line 9) | public static OAuth2UserInfo getOAuth2UserInfo(String registrationId, ...
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/BaseJpaAdapter.java
class BaseJpaAdapter (line 10) | public class BaseJpaAdapter<T, ID, E extends McCrudRepository> implement...
method BaseJpaAdapter (line 14) | public BaseJpaAdapter(E jpaRepository) {
method save (line 18) | @Override
method findById (line 23) | @Override
method findAll (line 29) | @Override
method saveAll (line 34) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionJpaRepository.java
type SessionJpaRepository (line 12) | @Repository
method findAllByUserId (line 15) | List<Session> findAllByUserId(UserId userId);
method findSessionByAccessToken (line 17) | Session findSessionByAccessToken(String accessToken);
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionRepositoryJpaAdapter.java
class SessionRepositoryJpaAdapter (line 13) | @Repository
method SessionRepositoryJpaAdapter (line 16) | public SessionRepositoryJpaAdapter(SessionJpaRepository jpaRepository) {
method nextIdentity (line 20) | @Override
method findByUserId (line 25) | @Override
method findByAccessToken (line 30) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserJpaRepository.java
type UserJpaRepository (line 9) | @Repository
method findUserByEmail (line 12) | User findUserByEmail(String email);
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepository.java
type UserRegistrationJpaRepository (line 12) | @Repository
method countByEmail (line 16) | long countByEmail(String email);
method findAllByEmailIn (line 18) | List<UserRegistration> findAllByEmailIn(List<String> email);
method findUserRegistrationByConfirmationCode (line 20) | UserRegistration findUserRegistrationByConfirmationCode(String confirm...
method findUserRegistrationByEmail (line 22) | UserRegistration findUserRegistrationByEmail(String email);
method findUserRegistrationByRecoveryCode (line 24) | UserRegistration findUserRegistrationByRecoveryCode(String recoveryCode);
method findUserRegistrationByUserId (line 26) | UserRegistration findUserRegistrationByUserId(UserId userId);
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepositoryAdapter.java
class UserRegistrationJpaRepositoryAdapter (line 10) | public class UserRegistrationJpaRepositoryAdapter
method UserRegistrationJpaRepositoryAdapter (line 14) | public UserRegistrationJpaRepositoryAdapter(UserRegistrationJpaReposit...
method countByEmailAndStatus (line 18) | @Override
method findAllByEmail (line 23) | @Override
method findByEmail (line 28) | @Override
method findByConfirmationCode (line 33) | @Override public UserRegistration findByConfirmationCode(String confir...
method findByRecoveryCode (line 37) | @Override
method findByUserId (line 42) | @Override public UserRegistration findByUserId(UserId anUserId) {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRepositoryJpaAdapter.java
class UserRepositoryJpaAdapter (line 11) | @Component
method UserRepositoryJpaAdapter (line 14) | public UserRepositoryJpaAdapter(UserJpaRepository userJpaRepository) {
method nextIdentity (line 18) | @Override
method findByEmail (line 23) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/ErrorCommandHandlerDecorator.java
class ErrorCommandHandlerDecorator (line 7) | public class ErrorCommandHandlerDecorator<T extends Command> extends Abs...
method ErrorCommandHandlerDecorator (line 11) | public ErrorCommandHandlerDecorator(CommandHandler commandHandler) {
method abstractHandle (line 15) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingCommandHandlerDecorator.java
class LoggingCommandHandlerDecorator (line 7) | public class LoggingCommandHandlerDecorator implements CommandHandler<Co...
method LoggingCommandHandlerDecorator (line 11) | public LoggingCommandHandlerDecorator(CommandHandler commandHandler) {
method handle (line 15) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingQueryHandlerDecorator.java
class LoggingQueryHandlerDecorator (line 7) | public class LoggingQueryHandlerDecorator implements QueryHandler {
method LoggingQueryHandlerDecorator (line 11) | public LoggingQueryHandlerDecorator(QueryHandler queryHandler) {
method handle (line 15) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/PipelineBuilder.java
type PipelineBuilder (line 3) | public interface PipelineBuilder<C, R> {
method with (line 4) | PipelineBuilder with(C aRequest);
method build (line 5) | R build();
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/AbstractPipelineBuilder.java
class AbstractPipelineBuilder (line 11) | public abstract class AbstractPipelineBuilder<E extends Request, S exten...
method with (line 18) | @Override
method setApplicationContext (line 25) | @Override
method getHandler (line 30) | protected S getHandler() {
method getHandlerName (line 35) | protected String getHandlerName() {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/CommandHandlerPipelineBuilder.java
class CommandHandlerPipelineBuilder (line 8) | public class CommandHandlerPipelineBuilder extends AbstractPipelineBuild...
method CommandHandlerPipelineBuilder (line 10) | public CommandHandlerPipelineBuilder() {}
method with (line 12) | @Override
method build (line 17) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/QueryHandlerPipelineBuilder.java
class QueryHandlerPipelineBuilder (line 8) | public class QueryHandlerPipelineBuilder extends AbstractPipelineBuilder...
method QueryHandlerPipelineBuilder (line 10) | public QueryHandlerPipelineBuilder() {
method with (line 13) | @Override
method build (line 18) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/service/MD5EncryptionService.java
class MD5EncryptionService (line 12) | @Service
method MD5EncryptionService (line 16) | public MD5EncryptionService() {
method encryptedValue (line 20) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/AppConfig.java
class AppConfig (line 33) | @Configuration
method eventStore (line 55) | @Bean
method recoveryLink (line 60) | @Bean
method confirmationLink (line 65) | @Bean
method mailGunConfiguration (line 70) | @Bean
method emailMessageSender (line 82) | @Bean
method modelMapper (line 87) | @Bean
method tokenAuthenticationFilter (line 92) | @Bean
method authenticationModule (line 97) | @Bean
method commandHandlerPipelineBuilder (line 103) | @Bean
method queryHandlerPipelineBuilder (line 108) | @Bean
method userRegistrationRepository (line 113) | @Bean
method userRepository (line 118) | @Bean
method facebookClientRegistration (line 123) | @Bean
method googleClientRegistration (line 133) | @Bean
method facebookOAuth2Service (line 143) | @Bean
method googleOAuth2Service (line 151) | @Bean
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/AppProperties.java
class AppProperties (line 8) | @ConfigurationProperties(prefix = "app")
class Auth (line 16) | public static class Auth {
method getTokenSecret (line 21) | public String getTokenSecret() {
method setTokenSecret (line 25) | public void setTokenSecret(String tokenSecret) {
method getTokenExpirationMsec (line 29) | public long getTokenExpirationMsec() {
method setTokenExpirationMsec (line 33) | public void setTokenExpirationMsec(long tokenExpirationMsec) {
method getSessionAuthTokenName (line 37) | public String getSessionAuthTokenName() {
method setSessionAuthTokenName (line 41) | public void setSessionAuthTokenName(String sessionAuthTokenName) {
class OAuth2 (line 46) | public static final class OAuth2 {
method getAuthorizedRedirectUris (line 49) | public List<String> getAuthorizedRedirectUris() {
method authorizedRedirectUris (line 53) | public OAuth2 authorizedRedirectUris(List<String> authorizedRedirect...
method getAuth (line 59) | public Auth getAuth() {
method getOauth2 (line 63) | public OAuth2 getOauth2() {
method getMessage (line 67) | public MessageProperties getMessage() {
method getGui (line 71) | public GUIProperties getGui() {
method getBaseUrl (line 75) | public String getBaseUrl() {
method setBaseUrl (line 79) | public void setBaseUrl(String baseUrl) {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/GUIProperties.java
class GUIProperties (line 7) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/MessageProperties.java
class MessageProperties (line 7) | @Getter
class Email (line 14) | @Getter
class MailGun (line 21) | @Getter
class From (line 30) | @Getter
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SecurityConfig.java
class SecurityConfig (line 14) | @Configuration
method configure (line 29) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SwaggerConfig.java
class SwaggerConfig (line 11) | @Configuration
method api (line 13) | @Bean
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SwaggerUiWebMvcConfigurer.java
class SwaggerUiWebMvcConfigurer (line 11) | @Component
method SwaggerUiWebMvcConfigurer (line 15) | public SwaggerUiWebMvcConfigurer(@Value("${app.base-url:}") String bas...
method addResourceHandlers (line 19) | @Override
method addViewControllers (line 28) | @Override
method addCorsMappings (line 34) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/AbstractController.java
class AbstractController (line 18) | public abstract class AbstractController {
method executeCommand (line 32) | protected Response executeCommand(Command command) {
method executeCommand (line 37) | protected <T extends Response> T executeCommand(Command command, Class...
method executeQuery (line 42) | protected <T extends Response> T executeQuery(Query query, Class<T> tc...
method setAuthToken (line 47) | private void setAuthToken(Request request) {
method getJwtFromRequest (line 56) | private String getJwtFromRequest() {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/AuthenticationController.java
class AuthenticationController (line 27) | @RestController
method formLogin (line 34) | @RequestMapping(method = RequestMethod.POST, path = AuthRoutes.FORM_LO...
method facebookLogin (line 41) | @RequestMapping(method = RequestMethod.POST, path = AuthRoutes.FACEBOO...
method googleLogin (line 48) | @RequestMapping(method = RequestMethod.POST, path = AuthRoutes.GOOGLE_...
method logout (line 55) | @RequestMapping(method = RequestMethod.PATCH, path = AuthRoutes.LOGOUT)
method executeCommand (line 68) | protected SessionDto executeCommand(Command command, UserAuthPrincipal...
method addAccessTokenToCookie (line 79) | private void addAccessTokenToCookie(String accessToken) {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/RegistrationController.java
class RegistrationController (line 18) | @RestController
method formRegister (line 22) | @RequestMapping(method = RequestMethod.POST, path = RegistrationRoutes...
method formRegisterConfirmation (line 28) | @RequestMapping(method = RequestMethod.POST, path = RegistrationRoutes...
method formRegisterRecovery (line 34) | @RequestMapping(method = RequestMethod.PATCH, path = RegistrationRoute...
method passwordReset (line 40) | @RequestMapping(method = RequestMethod.PATCH, path = RegistrationRoute...
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/RestApiRoutes.java
class RestApiRoutes (line 3) | public class RestApiRoutes {
class RegistrationRoutes (line 8) | public static class RegistrationRoutes {
class AuthRoutes (line 15) | public static class AuthRoutes {
class User (line 22) | public static class User {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/UserController.java
class UserController (line 19) | @RestController
method user (line 23) | @RequestMapping(method = RequestMethod.GET, path = User.USER_DETAILS)
method user (line 30) | @RequestMapping(method = RequestMethod.PATCH, path = User.USER_DETAILS)
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/filter/TokenAuthenticationFilter.java
class TokenAuthenticationFilter (line 30) | public class TokenAuthenticationFilter extends OncePerRequestFilter {
method doFilterInternal (line 43) | @Override
method setAuthentication (line 74) | private void setAuthentication(SessionDto sessionDetails) {
method getJwtFromRequest (line 99) | private String getJwtFromRequest(HttpServletRequest request) {
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/OAuth2AuthenticationFailureHandler.java
class OAuth2AuthenticationFailureHandler (line 12) | @Component
method onAuthenticationFailure (line 15) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/OAuth2AuthenticationSuccessHandler.java
class OAuth2AuthenticationSuccessHandler (line 17) | @Component
method onAuthenticationSuccess (line 20) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/UserAuthPrincipal.java
class UserAuthPrincipal (line 13) | public class UserAuthPrincipal implements UserDetails {
method UserAuthPrincipal (line 21) | public UserAuthPrincipal(SessionDto session) {
method getSession (line 26) | public SessionDto getSession() {
method getAuthorities (line 30) | @Override
method getPassword (line 35) | @Override
method getUsername (line 40) | @Override
method isAccountNonExpired (line 45) | @Override
method isAccountNonLocked (line 50) | @Override
method isCredentialsNonExpired (line 55) | @Override
method isEnabled (line 60) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/UserAuthToken.java
class UserAuthToken (line 11) | public class UserAuthToken extends AbstractAuthenticationToken {
method UserAuthToken (line 15) | public UserAuthToken(UserAuthPrincipal userPrincipal) {
method UserAuthToken (line 21) | public UserAuthToken(String authToken, Collection<? extends GrantedAut...
method getCredentials (line 26) | @Override
method getPrincipal (line 31) | @Override
FILE: src/main/java/com/tomo/mcauthentication/infrastructure/util/CookieUtils.java
class CookieUtils (line 11) | public class CookieUtils {
method getCookie (line 13) | public static Optional<Cookie> getCookie(HttpServletRequest request, S...
method addCookie (line 27) | public static void addCookie(HttpServletResponse response, String name...
method updateCookie (line 34) | public static void updateCookie(HttpServletRequest request, HttpServle...
method deleteCookie (line 48) | public static void deleteCookie(HttpServletRequest request, HttpServle...
method serialize (line 62) | public static String serialize(Object object) {
method deserialize (line 67) | public static <T> T deserialize(Cookie cookie, Class<T> cls) {
FILE: src/main/resources/db/migration/V2022_02_02_1124__initial_structure.sql
type mcuser (line 1) | CREATE TABLE mcuser (
type user_registration (line 13) | CREATE TABLE user_registration (
type session (line 31) | create table session (
type user_registration_user_id_uindex (line 45) | CREATE UNIQUE INDEX user_registration_user_id_uindex ON user_registratio...
type stored_event (line 47) | CREATE TABLE stored_event (
FILE: src/test/java/com/tomo/mcauthentication/integration/BaseIntegrationTest.java
class BaseIntegrationTest (line 7) | @RunWith(SpringRunner.class)
FILE: src/test/java/com/tomo/mcauthentication/integration/application/AbstractApplicationServiceTest.java
class AbstractApplicationServiceTest (line 33) | public abstract class AbstractApplicationServiceTest extends BaseIntegra...
method createFormUser (line 71) | protected User createFormUser() {
method createUserRegistration (line 79) | protected UserRegistration createUserRegistration() {
method formLogin (line 89) | protected SessionDto formLogin(){
method createFacbookUser (line 94) | protected User createFacbookUser() {
method createGoogleUser (line 102) | protected User createGoogleUser() {
method oAuth2Principal (line 110) | private OAuth2Principal oAuth2Principal(String anProvider) {
FILE: src/test/java/com/tomo/mcauthentication/integration/application/authentication/EmailLoginCommandHandlerTest.java
class EmailLoginCommandHandlerTest (line 12) | public class EmailLoginCommandHandlerTest extends AbstractApplicationSer...
method testUserFormLogin (line 14) | @Test
method testNewFormUserFailedWhenGoogleUserExists (line 20) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/authentication/FacebookLoginCommandHandlerTest.java
class FacebookLoginCommandHandlerTest (line 12) | public class FacebookLoginCommandHandlerTest extends AbstractApplication...
method testNewFacebookUserCreated (line 14) | @Test
method testNewFacebookUserFailedWhenGoogleUserExists (line 20) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/authentication/GoogleLoginCommandHandlerTest.java
class GoogleLoginCommandHandlerTest (line 12) | public class GoogleLoginCommandHandlerTest extends AbstractApplicationSe...
method testNewGoogleUserCreated (line 14) | @Test
method testNewGoogleUserFailedWhenFacebookUserExists (line 20) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/authentication/LogoutCommandHandlerTest.java
class LogoutCommandHandlerTest (line 16) | public class LogoutCommandHandlerTest extends AbstractApplicationService...
method testLogout (line 24) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/authentication/SessionAuthenticationCommandHandlerTest.java
class SessionAuthenticationCommandHandlerTest (line 15) | public class SessionAuthenticationCommandHandlerTest extends AbstractApp...
method testAuthenticateSession (line 23) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/recovery/CreatePasswordRecoveryCodeCommandHandlerTest.java
class CreatePasswordRecoveryCodeCommandHandlerTest (line 17) | public class CreatePasswordRecoveryCodeCommandHandlerTest extends Abstra...
method testRecoveryCodeCreated (line 22) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/recovery/GetUserRegistrationWithRecoveryCodeQueryHandlerTest.java
class GetUserRegistrationWithRecoveryCodeQueryHandlerTest (line 17) | public class GetUserRegistrationWithRecoveryCodeQueryHandlerTest extends...
method testGetUserRegistrationWithRecoveryCode (line 25) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/recovery/UpdatePasswordWithRecoveryCodeCommandHandlerTest.java
class UpdatePasswordWithRecoveryCodeCommandHandlerTest (line 20) | public class UpdatePasswordWithRecoveryCodeCommandHandlerTest extends Ab...
method testUpdatePasswordWithRecoveryCode (line 28) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/registration/ChangePasswordCommandHandlerTest.java
class ChangePasswordCommandHandlerTest (line 19) | public class ChangePasswordCommandHandlerTest extends AbstractApplicatio...
method testChangePassword (line 24) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/registration/ConfirmUserRegistrationCommandHandlerTest.java
class ConfirmUserRegistrationCommandHandlerTest (line 11) | public class ConfirmUserRegistrationCommandHandlerTest extends AbstractA...
method testConfirmUserRegistration (line 13) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/registration/RegisterNewUserCommandHandlerTest.java
class RegisterNewUserCommandHandlerTest (line 20) | public class RegisterNewUserCommandHandlerTest extends AbstractApplicati...
method testNewUserRegistrationCreated (line 34) | @Test
method testNewUserRegistrationFailedWhenUserExists (line 42) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/users/ChangeUserDetailsCommandHandlerTest.java
class ChangeUserDetailsCommandHandlerTest (line 17) | public class ChangeUserDetailsCommandHandlerTest extends AbstractApplica...
method testChangeUserDetails (line 25) | @Test
FILE: src/test/java/com/tomo/mcauthentication/integration/application/users/GetUserQueryHandlerTest.java
class GetUserQueryHandlerTest (line 14) | public class GetUserQueryHandlerTest extends AbstractApplicationServiceT...
method testGetUser (line 19) | @Test
FILE: src/test/java/com/tomo/mcauthentication/smoke/McAuthenticationApplicationSmokeTest.java
class McAuthenticationApplicationSmokeTest (line 11) | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
method contextLoads (line 17) | @Test
FILE: src/test/java/com/tomo/mcauthentication/testdata/CommandObjectMother.java
class CommandObjectMother (line 10) | public class CommandObjectMother extends StaticFields {
method CommandObjectMother (line 14) | private CommandObjectMother() {
method registerNewUserCommand (line 17) | public static RegisterNewUserCommand registerNewUserCommand() {
method registerNewUserCommandWithFakerEmail (line 21) | public static RegisterNewUserCommand registerNewUserCommandWithFakerEm...
method emailLoginCommand (line 25) | public static EmailLoginCommand emailLoginCommand() {
method facebookLoginCommand (line 29) | public static FacebookLoginCommand facebookLoginCommand() {
method googleLoginCommand (line 33) | public static GoogleLoginCommand googleLoginCommand() {
method createPasswordRecoveryCodeCommand (line 37) | public static CreatePasswordRecoveryCodeCommand createPasswordRecovery...
FILE: src/test/java/com/tomo/mcauthentication/testdata/StaticFields.java
class StaticFields (line 3) | public class StaticFields {
FILE: src/test/java/com/tomo/mcauthentication/unit/application/registration/UserRegistrationCommandHandlerTest.java
class UserRegistrationCommandHandlerTest (line 25) | @ExtendWith(MockitoExtension.class)
method setUp (line 59) | @BeforeEach
method testCreateUserRegister (line 72) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/AbstractUnitTest.java
class AbstractUnitTest (line 9) | @RunWith(MockitoJUnitRunner.StrictStubs.class)
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/UserRegistrationTest.java
class UserRegistrationTest (line 34) | @ExtendWith(MockitoExtension.class)
method setUp (line 65) | @BeforeEach
method after (line 90) | @AfterEach
method testCreateUserRegistration (line 97) | @Order(1)
method testCreateUserFromUserRegistration (line 112) | @Test
method testCreateRecoveryCodeAndRecoverPassword (line 126) | @Test
method testChangePassword (line 164) | @Test
method userRegistration (line 199) | private UserRegistration userRegistration() {
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordRecoveryCodeShouldBeExpiredOrNullTest.java
class PasswordRecoveryCodeShouldBeExpiredOrNullTest (line 13) | public class PasswordRecoveryCodeShouldBeExpiredOrNullTest extends Abstr...
method testRuleIsNotBroken (line 15) | @Test
method testRuleIsBroken (line 24) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordRecoveryCodeShouldNotExpiredTest.java
class PasswordRecoveryCodeShouldNotExpiredTest (line 13) | public class PasswordRecoveryCodeShouldNotExpiredTest extends AbstractUn...
method testRuleIsNotBroken (line 15) | @Test
method testRuleIsBroken (line 22) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordsMustMatchTest.java
class PasswordsMustMatchTest (line 10) | public class PasswordsMustMatchTest extends AbstractUnitTest {
method testRuleIsNotBroken (line 12) | @Test
method testRuleIsBroken (line 17) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/RecoveryCodeMustMatchTest.java
class RecoveryCodeMustMatchTest (line 10) | public class RecoveryCodeMustMatchTest extends AbstractUnitTest {
method testRuleIsNotBroken (line 12) | @Test
method testRuleIsBroken (line 17) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationCannotBeConfirmedAfterExpirationTest.java
class UserRegistrationCannotBeConfirmedAfterExpirationTest (line 13) | public class UserRegistrationCannotBeConfirmedAfterExpirationTest extend...
method testRuleIsNotBroken (line 15) | @Test
method testRuleIsBroken (line 24) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationCannotBeConfirmedMoreThanOnceTest.java
class UserRegistrationCannotBeConfirmedMoreThanOnceTest (line 10) | public class UserRegistrationCannotBeConfirmedMoreThanOnceTest {
method testRuleIsNotBroken (line 11) | @Test
method testRuleIsBroken (line 17) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationMustBeConfirmedTest.java
class UserRegistrationMustBeConfirmedTest (line 10) | public class UserRegistrationMustBeConfirmedTest {
method testRuleIsNotBroken (line 12) | @Test
method testRuleIsBroken (line 17) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationMustBeUniqueTest.java
class UserRegistrationMustBeUniqueTest (line 14) | public class UserRegistrationMustBeUniqueTest extends AbstractUnitTest {
method testRuleIsNotBroken (line 18) | @Test
method testRuleIsBroken (line 24) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/session/rules/SessionCannotBeExpiredWhenRefreshTokenIsMissingTest.java
class SessionCannotBeExpiredWhenRefreshTokenIsMissingTest (line 13) | public class SessionCannotBeExpiredWhenRefreshTokenIsMissingTest extends...
method testRuleIsNotBroken (line 15) | @Test
method testRuleIsBroken (line 29) | @Test
FILE: src/test/java/com/tomo/mcauthentication/unit/domain/user/rules/UserEmailMustBeUniqueTest.java
class UserEmailMustBeUniqueTest (line 15) | public class UserEmailMustBeUniqueTest extends AbstractUnitTest {
method testRuleIsNotBroken (line 19) | @Test
method testRuleIsBroken (line 25) | @Test
FILE: src/test/java/com/tomo/mcauthentication/weblayer/BaseWebLayerTest.java
class BaseWebLayerTest (line 9) | @RunWith(SpringRunner.class)
FILE: src/test/java/com/tomo/mcauthentication/weblayer/springboot/controller/AbstractControllerTest.java
class AbstractControllerTest (line 16) | @AutoConfigureMockMvc
method url (line 28) | protected URI url(String uri) throws URISyntaxException {
method baseHeaders (line 33) | protected HttpHeaders baseHeaders() {
FILE: src/test/java/com/tomo/mcauthentication/weblayer/springboot/controller/RegistrationControllerTest.java
class RegistrationControllerTest (line 18) | public class RegistrationControllerTest extends AbstractControllerTest {
method shouldCreateUserRegistration (line 23) | @Test
Condensed preview — 209 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (293K chars).
[
{
"path": ".github/workflows/maven.yml",
"chars": 860,
"preview": "name: Run tests\non:\n pull_request:\n branches:\n - main\n workflow_dispatch:\n\njobs:\n test:\n runs-on: ubuntu-l"
},
{
"path": ".gitignore",
"chars": 405,
"preview": "HELP.md\ntarget/\n!.mvn/wrapper/maven-wrapper.jar\n!**/src/main/**/target/\n!**/src/test/**/target/\n\n### STS ###\n.apt_genera"
},
{
"path": ".mvn/wrapper/MavenWrapperDownloader.java",
"chars": 4942,
"preview": "/*\n * Copyright 2007-present the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \""
},
{
"path": ".mvn/wrapper/maven-wrapper.properties",
"chars": 218,
"preview": "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip\nwrap"
},
{
"path": "1-init.sql",
"chars": 160,
"preview": "create user mcuser with superuser;\nalter user mcuser with password 'mcuser';\ncreate database mc_authentication with owne"
},
{
"path": "Dockerfile",
"chars": 555,
"preview": "FROM amazoncorretto:11 as base\nWORKDIR /app\nCOPY .mvn/ .mvn\nCOPY mvnw pom.xml ddd_common-v1.0.0.jar ./\nRUN ./mvnw deploy"
},
{
"path": "LICENSE",
"chars": 1073,
"preview": "MIT License\n\nCopyright (c) 2021 Tomislav Landeka\n\nPermission is hereby granted, free of charge, to any person obtaining "
},
{
"path": "README.md",
"chars": 6397,
"preview": "# Microservice for authentication with Domain-Driven Design\nFull Spring Boot authentication microservice with Domain-Dri"
},
{
"path": "docker-compose-ci.yml",
"chars": 808,
"preview": "version: '3.7'\n\nservices:\n\n mc-authentication-db-test:\n container_name: mc-authentication-db-test\n image: postgre"
},
{
"path": "docker-compose.yml",
"chars": 455,
"preview": "version: '3.7'\n\nservices:\n\n mc-authentication_db:\n container_name: mc-authentication_db\n image: postgres:12\n r"
},
{
"path": "mvnw",
"chars": 10070,
"preview": "#!/bin/sh\n# ----------------------------------------------------------------------------\n# Licensed to the Apache Softwa"
},
{
"path": "mvnw.cmd",
"chars": 6608,
"preview": "@REM ----------------------------------------------------------------------------\n@REM Licensed to the Apache Software F"
},
{
"path": "pom.xml",
"chars": 14403,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "src/main/java/com/tomo/mcauthentication/McAuthenticationApplication.java",
"chars": 1125,
"preview": "package com.tomo.mcauthentication;\n\nimport com.tomo.mcauthentication.infrastructure.springboot.configuration.AppProperti"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/BaseMapper.java",
"chars": 407,
"preview": "package com.tomo.mcauthentication.application;\n\nimport org.modelmapper.ModelMapper;\n\npublic class BaseMapper {\n prote"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/McAuthenticationEventHandler.java",
"chars": 1488,
"preview": "package com.tomo.mcauthentication.application;\n\nimport com.tomo.ddd.domain.DomainEvent;\nimport com.tomo.ddd.domain.Domai"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/BaseLoginCommandHandler.java",
"chars": 1205,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.BaseMapper;\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/EmailLoginCommandHandler.java",
"chars": 1934,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.authenticati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/FacebookLoginCommandHandler.java",
"chars": 1865,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.authenticati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/GoogleLoginCommandHandler.java",
"chars": 1851,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.authenticati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/LogoutCommandHandler.java",
"chars": 848,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.authenticati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/SessionAuthenticationCommandHandler.java",
"chars": 1313,
"preview": "package com.tomo.mcauthentication.application.authentication;\n\nimport com.tomo.mcauthentication.application.BaseMapper;\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/BaseLoginCommand.java",
"chars": 403,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport com.tomo.mcauthentication.application.cont"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/EmailLoginCommand.java",
"chars": 674,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport javax.validation.constraints.Email;\nimport"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/FacebookLoginCommand.java",
"chars": 376,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport lombok.Getter;\nimport lombok.NoArgsConstru"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/GoogleLoginCommand.java",
"chars": 372,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport lombok.Getter;\nimport lombok.NoArgsConstru"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/LogoutCommand.java",
"chars": 423,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport com.tomo.mcauthentication.application.cont"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/command/SessionAuthenticationCommand.java",
"chars": 453,
"preview": "package com.tomo.mcauthentication.application.authentication.command;\n\nimport com.tomo.mcauthentication.application.cont"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/dto/RecoveryPasswordDto.java",
"chars": 350,
"preview": "package com.tomo.mcauthentication.application.authentication.dto;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/authentication/dto/SessionDto.java",
"chars": 1436,
"preview": "package com.tomo.mcauthentication.application.authentication.dto;\n\nimport com.tomo.mcauthentication.application.users.dt"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/configuration/AbstractVoidyCommandHandler.java",
"chars": 536,
"preview": "package com.tomo.mcauthentication.application.configuration;\n\nimport com.tomo.mcauthentication.application.contracts.Com"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/configuration/CommandHandler.java",
"chars": 316,
"preview": "package com.tomo.mcauthentication.application.configuration;\n\nimport com.tomo.mcauthentication.application.contracts.Com"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/configuration/QueryHandler.java",
"chars": 309,
"preview": "package com.tomo.mcauthentication.application.configuration;\n\nimport com.tomo.mcauthentication.application.contracts.Que"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/configuration/RequestHandler.java",
"chars": 267,
"preview": "package com.tomo.mcauthentication.application.configuration;\n\nimport com.tomo.mcauthentication.application.contracts.Req"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/BaseCommand.java",
"chars": 127,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic class BaseCommand extends BaseRequest implements Comman"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/BaseQuery.java",
"chars": 121,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic class BaseQuery extends BaseRequest implements Query {}"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/BaseRequest.java",
"chars": 424,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\nimport java.util.UUID;\n\npublic class BaseRequest implements Re"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Command.java",
"chars": 104,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic interface Command extends Request {\n}\n\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Identifiable.java",
"chars": 132,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\nimport java.util.UUID;\n\npublic interface Identifiable {\n\n U"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/McAuthenticationModule.java",
"chars": 258,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\nimport org.springframework.stereotype.Component;\n\n@Component\np"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Query.java",
"chars": 101,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic interface Query extends Request {\n}\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Request.java",
"chars": 108,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic interface Request extends Identifiable {\n}\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Response.java",
"chars": 88,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic interface Response {\n}\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/Voidy.java",
"chars": 101,
"preview": "package com.tomo.mcauthentication.application.contracts;\n\npublic class Voidy implements Response {\n}\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateCommand.java",
"chars": 446,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateQuery.java",
"chars": 480,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthenticateRequest.java",
"chars": 799,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeCommand.java",
"chars": 349,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeQuery.java",
"chars": 407,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/AbstractAuthorizeRequest.java",
"chars": 427,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/Authenticate.java",
"chars": 169,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\npublic interface Authenticate {\n\n String authToken"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/contracts/security/Authorize.java",
"chars": 227,
"preview": "package com.tomo.mcauthentication.application.contracts.security;\n\nimport java.util.List;\n\npublic interface Authorize ex"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/CreatePasswordRecoveryCodeCommandHandler.java",
"chars": 1146,
"preview": "package com.tomo.mcauthentication.application.recovery;\n\nimport com.tomo.mcauthentication.application.recovery.command.C"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/GetUserRegistrationWithRecoveryCodeQueryHandler.java",
"chars": 1952,
"preview": "package com.tomo.mcauthentication.application.recovery;\n\nimport com.tomo.mcauthentication.application.BaseMapper;\nimport"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/PasswordRecoveryCodeCreatedEventHandler.java",
"chars": 2108,
"preview": "package com.tomo.mcauthentication.application.recovery;\n\nimport com.tomo.mcauthentication.application.contracts.McAuthen"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/SendPasswordRecoveryEmailCommandHandler.java",
"chars": 1113,
"preview": "package com.tomo.mcauthentication.application.recovery;\n\nimport com.tomo.mcauthentication.application.configuration.Abst"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/UpdatePasswordWithRecoveryCodeCommandHandler.java",
"chars": 1084,
"preview": "package com.tomo.mcauthentication.application.recovery;\n\nimport com.tomo.mcauthentication.application.recovery.command.U"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/command/CreatePasswordRecoveryCodeCommand.java",
"chars": 500,
"preview": "package com.tomo.mcauthentication.application.recovery.command;\n\nimport com.tomo.mcauthentication.application.contracts."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/command/SendPasswordRecoveryEmailCommand.java",
"chars": 798,
"preview": "package com.tomo.mcauthentication.application.recovery.command;\n\nimport com.tomo.mcauthentication.application.contracts."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/command/UpdatePasswordWithRecoveryCodeCommand.java",
"chars": 780,
"preview": "package com.tomo.mcauthentication.application.recovery.command;\n\nimport com.tomo.mcauthentication.application.contracts."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/recovery/dto/GetUserRegistrationWithRecoveryCodeQuery.java",
"chars": 526,
"preview": "package com.tomo.mcauthentication.application.recovery.dto;\n\nimport com.tomo.mcauthentication.application.contracts.Base"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/ChangePasswordCommandHandler.java",
"chars": 2079,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.configuration."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/ConfirmUserRegistrationCommandHandler.java",
"chars": 1830,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.configuration."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/GetUserRegistrationQueryHandler.java",
"chars": 541,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.configuration."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/NewUserRegisteredEventHandler.java",
"chars": 2085,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.contracts.McAu"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/RegisterNewUserCommandHandler.java",
"chars": 1416,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.configuration."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/SendRegistrationConfirmationEmailCommandHandler.java",
"chars": 1152,
"preview": "package com.tomo.mcauthentication.application.registration;\n\nimport com.tomo.mcauthentication.application.configuration."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/command/ChangePasswordCommand.java",
"chars": 833,
"preview": "package com.tomo.mcauthentication.application.registration.command;\n\nimport com.tomo.mcauthentication.application.contra"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/command/ConfirmUserRegistrationCommand.java",
"chars": 497,
"preview": "package com.tomo.mcauthentication.application.registration.command;\n\nimport com.tomo.mcauthentication.application.contra"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/command/RegisterNewUserCommand.java",
"chars": 1363,
"preview": "package com.tomo.mcauthentication.application.registration.command;\n\nimport com.tomo.mcauthentication.application.contra"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/command/SendRegistrationConfirmationEmailCommand.java",
"chars": 638,
"preview": "package com.tomo.mcauthentication.application.registration.command;\n\nimport com.tomo.mcauthentication.application.contra"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/dto/UserRegistrationDto.java",
"chars": 654,
"preview": "package com.tomo.mcauthentication.application.registration.dto;\n\nimport com.tomo.mcauthentication.application.contracts."
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/registration/query/GetUserRegistrationQuery.java",
"chars": 332,
"preview": "package com.tomo.mcauthentication.application.registration.query;\n\nimport com.tomo.mcauthentication.application.contract"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/users/ChangeUserDetailsCommandHandler.java",
"chars": 1507,
"preview": "package com.tomo.mcauthentication.application.users;\n\nimport com.tomo.mcauthentication.application.configuration.Abstrac"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/users/GetUserQueryHandler.java",
"chars": 1318,
"preview": "package com.tomo.mcauthentication.application.users;\n\nimport com.tomo.mcauthentication.application.BaseMapper;\nimport co"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/users/command/ChangeUserDetailsCommand.java",
"chars": 851,
"preview": "package com.tomo.mcauthentication.application.users.command;\n\nimport com.tomo.mcauthentication.application.contracts.sec"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/users/dto/BaseUserDto.java",
"chars": 506,
"preview": "package com.tomo.mcauthentication.application.users.dto;\n\nimport com.tomo.mcauthentication.application.contracts.Respons"
},
{
"path": "src/main/java/com/tomo/mcauthentication/application/users/query/GetUserQuery.java",
"chars": 607,
"preview": "package com.tomo.mcauthentication.application.users.query;\n\nimport com.tomo.mcauthentication.application.contracts.secur"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/DomainRegistry.java",
"chars": 2430,
"preview": "package com.tomo.mcauthentication.domain;\n\nimport com.tomo.mcauthentication.domain.registration.PasswordService;\nimport "
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/EncryptionService.java",
"chars": 134,
"preview": "package com.tomo.mcauthentication.domain;\n\npublic interface EncryptionService {\n\n String encryptedValue(String aPlain"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Authentication.java",
"chars": 148,
"preview": "package com.tomo.mcauthentication.domain.oauth2;\n\npublic interface OAuth2Authentication {\n OAuth2Principal authentic"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Principal.java",
"chars": 650,
"preview": "package com.tomo.mcauthentication.domain.oauth2;\n\nimport lombok.Getter;\nimport lombok.NoArgsConstructor;\n\n@Getter\n@NoArg"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/oauth2/OAuth2Service.java",
"chars": 1755,
"preview": "package com.tomo.mcauthentication.domain.oauth2;\n\nimport com.tomo.ddd.domain.BusinessRuleValidationException;\nimport com"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/EmailAuthenticationService.java",
"chars": 2778,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\nimport com.tomo.ddd.domain.BusinessRuleValidator;\nimport com.tom"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/PasswordService.java",
"chars": 3635,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\nimport com.tomo.ddd.AssertionConcern;\n\nimport org.springframewor"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistration.java",
"chars": 8837,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\nimport com.tomo.ddd.domain.ConcurrencySafeEntity;\nimport com.tom"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationId.java",
"chars": 558,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\nimport com.tomo.ddd.domain.AbstractId;\n\nimport javax.persistence"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationRepository.java",
"chars": 649,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\nimport com.tomo.ddd.domain.BaseRepository;\nimport com.tomo.mcaut"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/UserRegistrationStatus.java",
"chars": 376,
"preview": "package com.tomo.mcauthentication.domain.registration;\npublic enum\nUserRegistrationStatus {\n WaitingForConfirmation(\""
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/UsersCounter.java",
"chars": 121,
"preview": "package com.tomo.mcauthentication.domain.registration;\n\npublic interface UsersCounter {\n int countUsersWithLogin();\n}"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordChanged.java",
"chars": 523,
"preview": "package com.tomo.mcauthentication.domain.registration.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\n\nimport lombo"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecovered.java",
"chars": 635,
"preview": "package com.tomo.mcauthentication.domain.registration.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\n\nimport lombo"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/events/PasswordRecoveryCodeCreated.java",
"chars": 810,
"preview": "package com.tomo.mcauthentication.domain.registration.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\n\nimport java."
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationConfirmed.java",
"chars": 758,
"preview": "package com.tomo.mcauthentication.domain.registration.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\nimport com.to"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/events/UserRegistrationRequested.java",
"chars": 1113,
"preview": "package com.tomo.mcauthentication.domain.registration.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\nimport com.to"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldBeExpiredOrNull.java",
"chars": 779,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordRecoveryCodeShouldNotExpired.java",
"chars": 725,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/PasswordsMustMatch.java",
"chars": 631,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\n\npublic class Pas"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/RecoveryCodeMustMatch.java",
"chars": 596,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\n\npublic class Rec"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedAfterExpiration.java",
"chars": 694,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\n\nimport java.time"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationCannotBeConfirmedMoreThanOnce.java",
"chars": 684,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeConfirmed.java",
"chars": 727,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/registration/rules/UserRegistrationMustBeUnique.java",
"chars": 830,
"preview": "package com.tomo.mcauthentication.domain.registration.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/JwtTokenProvider.java",
"chars": 3043,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.mcauthentication.domain.session.Session.TokenType;\nim"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/Session.java",
"chars": 2822,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.ddd.domain.DomainEventPublisher;\nimport com.tomo.ddd."
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/SessionAuthenticationService.java",
"chars": 2387,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.ddd.domain.BusinessRuleValidator;\nimport com.tomo.mca"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/SessionId.java",
"chars": 536,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.ddd.domain.AbstractId;\n\nimport javax.persistence.Embe"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/SessionRepository.java",
"chars": 385,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.ddd.domain.BaseRepository;\nimport com.tomo.mcauthenti"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/TokenProvider.java",
"chars": 406,
"preview": "package com.tomo.mcauthentication.domain.session;\n\nimport com.tomo.mcauthentication.domain.users.User;\nimport com.tomo.m"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/events/SessionCreated.java",
"chars": 583,
"preview": "package com.tomo.mcauthentication.domain.session.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\nimport com.tomo.mc"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/session/rule/SessionCannotBeExpiredWhenRefreshTokenIsMissing.java",
"chars": 682,
"preview": "package com.tomo.mcauthentication.domain.session.rule;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.mcauthe"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/EmailLogin.java",
"chars": 136,
"preview": "package com.tomo.mcauthentication.domain.users;\n\npublic class EmailLogin {\n User user;\n String username;\n Strin"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/User.java",
"chars": 2304,
"preview": "package com.tomo.mcauthentication.domain.users;\n\nimport com.tomo.ddd.domain.ConcurrencySafeEntity;\nimport com.tomo.ddd.d"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/UserId.java",
"chars": 604,
"preview": "package com.tomo.mcauthentication.domain.users;\n\nimport com.tomo.ddd.domain.AbstractId;\n\nimport javax.persistence.Embedd"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/UserRepository.java",
"chars": 231,
"preview": "package com.tomo.mcauthentication.domain.users;\n\nimport com.tomo.ddd.domain.BaseRepository;\n\npublic interface UserReposi"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/events/UserCreated.java",
"chars": 772,
"preview": "package com.tomo.mcauthentication.domain.users.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\nimport com.tomo.mcau"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/events/UserNameChanged.java",
"chars": 516,
"preview": "package com.tomo.mcauthentication.domain.users.events;\n\nimport com.tomo.ddd.domain.BaseDomainEvent;\n\nimport lombok.Gette"
},
{
"path": "src/main/java/com/tomo/mcauthentication/domain/users/rules/UserEmailMustBeUnique.java",
"chars": 670,
"preview": "package com.tomo.mcauthentication.domain.users.rules;\n\nimport com.tomo.ddd.domain.BusinessRule;\nimport com.tomo.mcauthen"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/McAuthenticationModuleExecutor.java",
"chars": 1759,
"preview": "package com.tomo.mcauthentication.infrastructure;\n\nimport com.tomo.mcauthentication.application.configuration.CommandHan"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/AbstractOAuth2Authentication.java",
"chars": 1897,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2;\n\nimport com.tomo.mcauthentication.domain.oauth2.OAuth2Prin"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/CustomOAuth2UserService.java",
"chars": 665,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2;\n\nimport org.springframework.security.oauth2.client.userinf"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/FacebookOAuth2Authentication.java",
"chars": 1157,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2;\n\nimport com.tomo.mcauthentication.domain.oauth2.OAuth2Auth"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/GoogleOAuth2Authentication.java",
"chars": 1152,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2;\n\nimport com.tomo.mcauthentication.domain.oauth2.OAuth2Auth"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/FacebookOAuth2UserInfo.java",
"chars": 1057,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2.user;\n\nimport java.util.Map;\n\npublic class FacebookOAuth2Us"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/GoogleOAuth2UserInfo.java",
"chars": 654,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2.user;\n\nimport java.util.Map;\n\npublic class GoogleOAuth2User"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfo.java",
"chars": 526,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2.user;\n\nimport java.util.Map;;\n\npublic abstract class OAuth2"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/http/oauth2/user/OAuth2UserInfoFactory.java",
"chars": 759,
"preview": "package com.tomo.mcauthentication.infrastructure.http.oauth2.user;\n\nimport com.tomo.mcauthentication.domain.users.User;\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/BaseJpaAdapter.java",
"chars": 1047,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.ddd.domain.BaseRepository;\nimport com.tom"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionJpaRepository.java",
"chars": 598,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.ddd.infrastructure.persistence.springdata"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/SessionRepositoryJpaAdapter.java",
"chars": 1054,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.mcauthentication.domain.session.Session;\n"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserJpaRepository.java",
"chars": 432,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.ddd.infrastructure.persistence.springdata"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepository.java",
"chars": 961,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.ddd.infrastructure.persistence.springdata"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRegistrationJpaRepositoryAdapter.java",
"chars": 1639,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.mcauthentication.domain.registration.User"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/persistence/UserRepositoryJpaAdapter.java",
"chars": 781,
"preview": "package com.tomo.mcauthentication.infrastructure.persistence;\n\nimport com.tomo.mcauthentication.domain.users.User;\nimpor"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/ErrorCommandHandlerDecorator.java",
"chars": 667,
"preview": "package com.tomo.mcauthentication.infrastructure.processing;\n\nimport com.tomo.mcauthentication.application.configuration"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingCommandHandlerDecorator.java",
"chars": 659,
"preview": "package com.tomo.mcauthentication.infrastructure.processing;\n\nimport com.tomo.mcauthentication.application.configuration"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/LoggingQueryHandlerDecorator.java",
"chars": 589,
"preview": "package com.tomo.mcauthentication.infrastructure.processing;\n\nimport com.tomo.mcauthentication.application.configuration"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/PipelineBuilder.java",
"chars": 158,
"preview": "package com.tomo.mcauthentication.infrastructure.processing;\n\npublic interface PipelineBuilder<C, R> {\n PipelineBuild"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/AbstractPipelineBuilder.java",
"chars": 1421,
"preview": "package com.tomo.mcauthentication.infrastructure.processing.builder;\n\nimport com.tomo.mcauthentication.application.confi"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/CommandHandlerPipelineBuilder.java",
"chars": 801,
"preview": "package com.tomo.mcauthentication.infrastructure.processing.builder;\n\nimport com.tomo.mcauthentication.application.confi"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/processing/builder/QueryHandlerPipelineBuilder.java",
"chars": 782,
"preview": "package com.tomo.mcauthentication.infrastructure.processing.builder;\n\nimport com.tomo.mcauthentication.application.confi"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/service/MD5EncryptionService.java",
"chars": 1197,
"preview": "package com.tomo.mcauthentication.infrastructure.service;\n\nimport com.tomo.ddd.AssertionConcern;\nimport com.tomo.mcauthe"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/AppConfig.java",
"chars": 6369,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport com.tomo.mcauthentication.application"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/AppProperties.java",
"chars": 2193,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport org.springframework.boot.context.prop"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/GUIProperties.java",
"chars": 296,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport lombok.Getter;\nimport lombok.NoArgsCo"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/MessageProperties.java",
"chars": 843,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport lombok.Getter;\nimport lombok.NoArgsCo"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SecurityConfig.java",
"chars": 1799,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport com.tomo.mcauthentication.infrastruct"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SwaggerConfig.java",
"chars": 715,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport org.springframework.context.annotatio"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/configuration/SwaggerUiWebMvcConfigurer.java",
"chars": 1720,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.configuration;\n\nimport org.springframework.beans.factory.ann"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/AbstractController.java",
"chars": 2426,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.controller;\n\nimport com.tomo.mcauthentication.application.co"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/AuthenticationController.java",
"chars": 3864,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.controller;\n\nimport com.tomo.mcauthentication.application.au"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/RegistrationController.java",
"chars": 2288,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.controller;\n\nimport com.tomo.mcauthentication.application.re"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/RestApiRoutes.java",
"chars": 1199,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.controller;\n\npublic class RestApiRoutes {\n public static "
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/controller/UserController.java",
"chars": 1633,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.controller;\n\nimport com.tomo.mcauthentication.application.us"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/filter/TokenAuthenticationFilter.java",
"chars": 4715,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.filter;\n\nimport com.tomo.mcauthentication.application.authen"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/CurrentUser.java",
"chars": 510,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.security;\n\nimport org.springframework.security.core.annotati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/OAuth2AuthenticationFailureHandler.java",
"chars": 763,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.security;\n\nimport org.springframework.security.core.Authenti"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/OAuth2AuthenticationSuccessHandler.java",
"chars": 1198,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.security;\n\nimport org.springframework.beans.factory.annotati"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/UserAuthPrincipal.java",
"chars": 1456,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.security;\n\nimport com.tomo.mcauthentication.application.auth"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/springboot/security/UserAuthToken.java",
"chars": 1012,
"preview": "package com.tomo.mcauthentication.infrastructure.springboot.security;\n\nimport com.tomo.mcauthentication.domain.users.Use"
},
{
"path": "src/main/java/com/tomo/mcauthentication/infrastructure/util/CookieUtils.java",
"chars": 2458,
"preview": "package com.tomo.mcauthentication.infrastructure.util;\n\nimport org.springframework.util.SerializationUtils;\n\nimport java"
},
{
"path": "src/main/resources/application.yml",
"chars": 2054,
"preview": "server:\n port: 8080\ndebug: true\n\nspring:\n datasource:\n url: jdbc:postgresql://localhost:5432/mc_authentication\n "
},
{
"path": "src/main/resources/db/migration/V2022_02_02_1124__initial_structure.sql",
"chars": 1915,
"preview": "CREATE TABLE mcuser (\n id UUID PRIMARY KEY NOT NULL,\n first_name VARCHAR(255),\n last_"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/1.0.0/ddd_common-1.0.0.jar.md5",
"chars": 32,
"preview": "d6f732badc879e635745ef1ee13673d3"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/1.0.0/ddd_common-1.0.0.jar.sha1",
"chars": 40,
"preview": "49221e5069bd616ba23339076cad6478d3762710"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/1.0.0/ddd_common-1.0.0.pom",
"chars": 392,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apac"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/1.0.0/ddd_common-1.0.0.pom.md5",
"chars": 32,
"preview": "5238d5a53bcbfbe70a6cb87ed493d6f3"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/1.0.0/ddd_common-1.0.0.pom.sha1",
"chars": 40,
"preview": "423681301f4b73b38060c3c069f0141c0b54c660"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/maven-metadata.xml",
"chars": 298,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<metadata>\n <groupId>org.tomo</groupId>\n <artifactId>ddd_common</artifactId>\n "
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/maven-metadata.xml.md5",
"chars": 32,
"preview": "2dfb0c4eb83fb0e21037e00e71ab51cb"
},
{
"path": "src/main/resources/repo/org/tomo/ddd_common/maven-metadata.xml.sha1",
"chars": 40,
"preview": "b984353efb5206ed31336cb8a1508c6453122adb"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/BaseIntegrationTest.java",
"chars": 355,
"preview": "package com.tomo.mcauthentication.integration;\n\nimport org.junit.runner.RunWith;\nimport org.springframework.boot.test.co"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/AbstractApplicationServiceTest.java",
"chars": 5014,
"preview": "package com.tomo.mcauthentication.integration.application;\n\nimport com.tomo.ddd.email.EmailSender;\nimport com.tomo.mcaut"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/authentication/EmailLoginCommandHandlerTest.java",
"chars": 785,
"preview": "package com.tomo.mcauthentication.integration.application.authentication;\n\nimport com.tomo.ddd.domain.BusinessRuleValida"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/authentication/FacebookLoginCommandHandlerTest.java",
"chars": 812,
"preview": "package com.tomo.mcauthentication.integration.application.authentication;\n\nimport com.tomo.ddd.domain.BusinessRuleValida"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/authentication/GoogleLoginCommandHandlerTest.java",
"chars": 807,
"preview": "package com.tomo.mcauthentication.integration.application.authentication;\n\nimport com.tomo.ddd.domain.BusinessRuleValida"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/authentication/LogoutCommandHandlerTest.java",
"chars": 1276,
"preview": "package com.tomo.mcauthentication.integration.application.authentication;\n\nimport com.tomo.ddd.domain.BusinessRuleValida"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/authentication/SessionAuthenticationCommandHandlerTest.java",
"chars": 1278,
"preview": "package com.tomo.mcauthentication.integration.application.authentication;\n\nimport com.tomo.mcauthentication.application."
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/recovery/CreatePasswordRecoveryCodeCommandHandlerTest.java",
"chars": 1242,
"preview": "package com.tomo.mcauthentication.integration.application.recovery;\n\nimport com.tomo.mcauthentication.application.authen"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/recovery/GetUserRegistrationWithRecoveryCodeQueryHandlerTest.java",
"chars": 1588,
"preview": "package com.tomo.mcauthentication.integration.application.recovery;\n\nimport com.tomo.mcauthentication.application.authen"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/recovery/UpdatePasswordWithRecoveryCodeCommandHandlerTest.java",
"chars": 2075,
"preview": "package com.tomo.mcauthentication.integration.application.recovery;\n\nimport com.tomo.mcauthentication.application.authen"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/registration/ChangePasswordCommandHandlerTest.java",
"chars": 1844,
"preview": "package com.tomo.mcauthentication.integration.application.registration;\n\nimport com.tomo.ddd.domain.BusinessRuleValidati"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/registration/ConfirmUserRegistrationCommandHandlerTest.java",
"chars": 575,
"preview": "package com.tomo.mcauthentication.integration.application.registration;\n\nimport com.tomo.mcauthentication.domain.users.U"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/registration/RegisterNewUserCommandHandlerTest.java",
"chars": 1866,
"preview": "package com.tomo.mcauthentication.integration.application.registration;\n\nimport com.tomo.mcauthentication.application.re"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/users/ChangeUserDetailsCommandHandlerTest.java",
"chars": 1650,
"preview": "package com.tomo.mcauthentication.integration.application.users;\n\nimport com.tomo.mcauthentication.application.authentic"
},
{
"path": "src/test/java/com/tomo/mcauthentication/integration/application/users/GetUserQueryHandlerTest.java",
"chars": 933,
"preview": "package com.tomo.mcauthentication.integration.application.users;\n\nimport com.tomo.mcauthentication.application.authentic"
},
{
"path": "src/test/java/com/tomo/mcauthentication/smoke/McAuthenticationApplicationSmokeTest.java",
"chars": 593,
"preview": "package com.tomo.mcauthentication.smoke;\n\nimport com.tomo.mcauthentication.infrastructure.springboot.controller.UserCont"
},
{
"path": "src/test/java/com/tomo/mcauthentication/testdata/CommandObjectMother.java",
"chars": 1596,
"preview": "package com.tomo.mcauthentication.testdata;\n\nimport com.github.javafaker.Faker;\nimport com.tomo.mcauthentication.applica"
},
{
"path": "src/test/java/com/tomo/mcauthentication/testdata/StaticFields.java",
"chars": 561,
"preview": "package com.tomo.mcauthentication.testdata;\n\npublic class StaticFields {\n\n public static final String ACCESS_CODE = \""
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/application/registration/UserRegistrationCommandHandlerTest.java",
"chars": 3025,
"preview": "package com.tomo.mcauthentication.unit.application.registration;\n\nimport com.tomo.mcauthentication.domain.DomainRegistry"
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/AbstractUnitTest.java",
"chars": 478,
"preview": "package com.tomo.mcauthentication.unit.domain;\n\nimport org.junit.jupiter.api.TestInstance;\nimport org.junit.runner.RunWi"
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/UserRegistrationTest.java",
"chars": 8111,
"preview": "package com.tomo.mcauthentication.unit.domain.registration;\n\nimport com.tomo.ddd.domain.DomainEventPublisher;\nimport com"
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordRecoveryCodeShouldBeExpiredOrNullTest.java",
"chars": 1340,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordRecoveryCodeShouldNotExpiredTest.java",
"chars": 1249,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/PasswordsMustMatchTest.java",
"chars": 653,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/RecoveryCodeMustMatchTest.java",
"chars": 665,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationCannotBeConfirmedAfterExpirationTest.java",
"chars": 1328,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationCannotBeConfirmedMoreThanOnceTest.java",
"chars": 923,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationMustBeConfirmedTest.java",
"chars": 856,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
},
{
"path": "src/test/java/com/tomo/mcauthentication/unit/domain/registration/rules/UserRegistrationMustBeUniqueTest.java",
"chars": 1131,
"preview": "package com.tomo.mcauthentication.unit.domain.registration.rules;\n\nimport com.tomo.mcauthentication.domain.registration."
}
]
// ... and 9 more files (download for full content)
About this extraction
This page contains the full source code of the tlandeka/authentication-microservice-with-domain-driven-design GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 209 files (254.6 KB), approximately 62.0k tokens, and a symbol index with 639 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.