mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:25:49 +00:00
Add SonarQube and change travis
This commit is contained in:
parent
2f50fa5d6a
commit
026fcd0509
29 changed files with 186 additions and 243 deletions
|
@ -10,14 +10,18 @@ before_install:
|
|||
|
||||
jobs:
|
||||
include:
|
||||
- stage: javaformat
|
||||
script: ./mvnw clean spring-javaformat:apply
|
||||
- stage: test
|
||||
script: ./mvnw clean test
|
||||
script: ./mvnw test
|
||||
- stage: verify
|
||||
script: ./mvnw verify
|
||||
- stage: sonar
|
||||
script: ./mvnw verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
||||
notifications:
|
||||
# email: email@provider.com
|
||||
email: pedsf.fullstack@gmail.com
|
||||
|
|
63
pom.xml
63
pom.xml
|
@ -33,7 +33,7 @@
|
|||
<wro4j.version>1.9.0</wro4j.version>
|
||||
<checkstyle.version>8.32</checkstyle.version>
|
||||
|
||||
<jacoco.version>0.8.5</jacoco.version>
|
||||
<jacoco.version>0.8.6</jacoco.version>
|
||||
<junit.version>4.13</junit.version>
|
||||
<lifecycle-mapping.version>1.0.0</lifecycle-mapping.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
|
@ -42,6 +42,26 @@
|
|||
<nohttp-checkstyle.version>0.0.4.RELEASE</nohttp-checkstyle.version>
|
||||
<spring-format.version>0.0.25</spring-format.version>
|
||||
<spring-cloud-starter-security.version>2.2.4.RELEASE</spring-cloud-starter-security.version>
|
||||
|
||||
<!-- =================================================================== -->
|
||||
<!-- SONARQUBE -->
|
||||
<!-- Set environment values in your computer and in Travis-CI -->
|
||||
<!-- =================================================================== -->
|
||||
<sonar.projectKey>${env.SONAR_PETCLINIC_PROJECTKEY}</sonar.projectKey>
|
||||
<sonar.organization>${env.SONAR_ORGANIZATION}</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
<sonar.login>${env.SONAR_PETCLINIC_TOKEN}</sonar.login>
|
||||
<sonar.language>java</sonar.language>
|
||||
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
|
||||
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
|
||||
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
|
||||
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml,../target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
|
||||
<sonar.coverage.exclusions>
|
||||
org/springframework/samples/petclinic/common/*.java,
|
||||
org/springframework/samples/petclinic/dto/*.java,
|
||||
org/springframework/samples/petclinic/model/*.java
|
||||
org/springframework/samples/petclinic/repository/*.java
|
||||
</sonar.coverage.exclusions>
|
||||
</properties>
|
||||
|
||||
<!-- ===================================================================== -->
|
||||
|
@ -253,6 +273,21 @@
|
|||
<!-- BUILD -->
|
||||
<!-- ===================================================================== -->
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
<version>3.6.0.1398</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.spring.javaformat</groupId>
|
||||
|
@ -322,10 +357,33 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- ==================================================== Jacoco -->
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prepare-and-report</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>report-aggregate</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>report-aggregate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/../target/site/jacoco-aggregate</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--plugin>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -340,7 +398,7 @@
|
|||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin-->
|
||||
|
||||
<!-- Spring Boot Actuator displays build-related information if a git.properties
|
||||
file is present at the classpath -->
|
||||
|
@ -561,6 +619,7 @@
|
|||
</pluginManagement>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
45
readme.md
45
readme.md
|
@ -26,7 +26,6 @@ Or you can run it from Maven directly using the Spring Boot Maven plugin. If you
|
|||
## In case you find a bug/suggested improvement for Spring Petclinic
|
||||
Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues
|
||||
|
||||
|
||||
## Database configuration
|
||||
|
||||
In its default configuration, Petclinic uses an in-memory database (H2) which
|
||||
|
@ -43,6 +42,50 @@ docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PAS
|
|||
|
||||
Further documentation is provided [here](https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt).
|
||||
|
||||
## Email configuration for Mailtrap
|
||||
Open an account on https://mailtrap.io to see email exchanges.
|
||||
Set environment variables for Mailtrap connection :
|
||||
- SPRING_MAIL_USERNAME
|
||||
- SPRING_MAIL_PASSWORD
|
||||
|
||||
Theses values are used in application.properties.
|
||||
|
||||
## Oauth2 configuration for login with Google, Facebook and Github
|
||||
Open an API account on the provider you want to add.
|
||||
Set the environment variable corresponding.
|
||||
- OAUTH2_GOOGLE_CLIENT_ID
|
||||
- OAUTH2_GOOGLE_CLIENT_SECRET
|
||||
- OAUTH2_GITHUB_CLIENT_ID
|
||||
- OAUTH2_GITHUB_CLIENT_SECRET
|
||||
- OAUTH2_FACEBOOK_CLIENT_ID
|
||||
- OAUTH2_FACEBOOK_CLIENT_SECRET
|
||||
|
||||
Theses values are used in oauth2.properties.
|
||||
Decomment corresponding lines in src/main/resources/oauth2.properties for using it on your project.
|
||||
|
||||
## SonarQube configuration
|
||||
Open an account on https://sonarcloud.io.
|
||||
Link SonarQube to your repository on GitHub, GitLab...
|
||||
Start a new project for spring-petclinic.
|
||||
Setup manually the configuration for your project with Maven and set values in your environment for :
|
||||
- SONAR_PETCLINIC_PROJECTKEY
|
||||
- SONAR_ORGANIZATION
|
||||
- SONAR_PETCLINIC_TOKEN
|
||||
|
||||
Theses values are used in lines below from pom.xml.
|
||||
|
||||
```
|
||||
<sonar.projectKey>${env.SONAR_PETCLINIC_PROJECTKEY}</sonar.projectKey>
|
||||
<sonar.organization>${env.SONAR_ORGANIZATION}</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
<sonar.login>${env.SONAR_PETCLINIC_TOKEN}</sonar.login>
|
||||
```
|
||||
|
||||
## Travis-CI Configuration
|
||||
Open an account on https://travis-ci.org
|
||||
Link Travis-CI to your repository on GitHub, GitLab...
|
||||
Set environment variable in your Travis-CI project for Mailtrap, Oauth2 and SonarQube.
|
||||
|
||||
## Working with Petclinic in your IDE
|
||||
|
||||
### Prerequisites
|
||||
|
|
|
@ -37,14 +37,14 @@ public final class CommonAttribute {
|
|||
|
||||
public static final String PET = "pet";
|
||||
|
||||
public static final String SELECTIONS = "selections";
|
||||
|
||||
public static final String PET_BIRTH_DATE = "birthDate";
|
||||
|
||||
public static final String PET_NAME = "name";
|
||||
|
||||
public static final String PET_TYPE = "type";
|
||||
|
||||
public static final String SELECTIONS = "selections";
|
||||
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
public static final String URLS = "urls";
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.dto.business;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
@ -30,6 +32,8 @@ import java.util.*;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class OwnerDTO extends PersonDTO {
|
||||
|
||||
@NotEmpty
|
||||
|
@ -44,30 +48,6 @@ public class OwnerDTO extends PersonDTO {
|
|||
|
||||
private Set<PetDTO> pets;
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return this.telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
protected Set<PetDTO> getPetsInternal() {
|
||||
if (this.pets == null) {
|
||||
this.pets = new HashSet<>();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.dto.business;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -28,6 +30,8 @@ import java.util.*;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class PetDTO extends NamedDTO {
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
|
@ -39,30 +43,6 @@ public class PetDTO extends NamedDTO {
|
|||
|
||||
private Set<VisitDTO> visits = new LinkedHashSet<>();
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return this.birthDate;
|
||||
}
|
||||
|
||||
public PetTypeDTO getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(PetTypeDTO type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public OwnerDTO getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(OwnerDTO owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
protected Set<VisitDTO> getVisitsInternal() {
|
||||
if (this.visits == null) {
|
||||
this.visits = new HashSet<>();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.dto.business;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.samples.petclinic.dto.common.BaseDTO;
|
||||
import org.springframework.samples.petclinic.model.business.Visit;
|
||||
|
@ -27,6 +29,8 @@ import java.time.LocalDate;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class VisitDTO extends BaseDTO {
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
|
@ -44,30 +48,6 @@ public class VisitDTO extends BaseDTO {
|
|||
this.date = LocalDate.now();
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getPetId() {
|
||||
return this.petId;
|
||||
}
|
||||
|
||||
public void setPetId(Integer petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.dto.common;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -23,30 +26,14 @@ import java.io.Serializable;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class BaseDTO implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return this.id == null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public boolean equals(Object o) { if (this == o) return true;
|
||||
*
|
||||
* if (!(o instanceof BaseDTO)) return false;
|
||||
*
|
||||
* BaseDTO baseDTO = (BaseDTO) o;
|
||||
*
|
||||
* return new EqualsBuilder().append(getId(), baseDTO.getId()).isEquals(); }
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package org.springframework.samples.petclinic.dto.common;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
|
@ -25,6 +25,8 @@ import javax.validation.constraints.NotEmpty;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class PersonDTO extends BaseDTO {
|
||||
|
||||
@NotEmpty
|
||||
|
@ -33,22 +35,6 @@ public class PersonDTO extends BaseDTO {
|
|||
@NotEmpty
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
|
@ -3,10 +3,8 @@ package org.springframework.samples.petclinic.dto.common;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
import org.springframework.samples.petclinic.common.CommonParameter;
|
||||
import org.springframework.samples.petclinic.model.common.Role;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
|
|
@ -29,6 +29,8 @@ import javax.persistence.Table;
|
|||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
@ -43,7 +45,9 @@ import org.springframework.samples.petclinic.model.common.Person;
|
|||
* @author Sam Brannen
|
||||
* @author Michael Isvy
|
||||
*/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "Owner")
|
||||
@Table(name = "owners")
|
||||
public class Owner extends Person {
|
||||
|
||||
|
@ -63,30 +67,6 @@ public class Owner extends Person {
|
|||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
||||
private Set<Pet> pets;
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getTelephone() {
|
||||
return this.telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
protected Set<Pet> getPetsInternal() {
|
||||
if (this.pets == null) {
|
||||
this.pets = new HashSet<>();
|
||||
|
|
|
@ -31,6 +31,8 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.support.MutableSortDefinition;
|
||||
import org.springframework.beans.support.PropertyComparator;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -43,7 +45,9 @@ import org.springframework.samples.petclinic.model.common.NamedEntity;
|
|||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "Pet")
|
||||
@Table(name = "pets")
|
||||
public class Pet extends NamedEntity {
|
||||
|
||||
|
@ -62,30 +66,6 @@ public class Pet extends NamedEntity {
|
|||
@Transient
|
||||
private Set<Visit> visits = new LinkedHashSet<>();
|
||||
|
||||
public void setBirthDate(LocalDate birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public LocalDate getBirthDate() {
|
||||
return this.birthDate;
|
||||
}
|
||||
|
||||
public PetType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(PetType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public void setOwner(Owner owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
protected Set<Visit> getVisitsInternal() {
|
||||
if (this.visits == null) {
|
||||
this.visits = new HashSet<>();
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.springframework.samples.petclinic.model.common.Person;
|
|||
* @author Sam Brannen
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Entity
|
||||
@Entity(name = "Vet")
|
||||
@Table(name = "vets")
|
||||
public class Vet extends Person {
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ import javax.persistence.Table;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Entity(name = "AuthProvider")
|
||||
@Table(name = "auth_providers")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity(name = "AuthProvider")
|
||||
@Table(name = "auth_providers")
|
||||
public class AuthProvider extends NamedEntity {
|
||||
|
||||
public AuthProvider(Integer id, String name) {
|
||||
|
|
|
@ -21,12 +21,12 @@ import java.util.UUID;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Entity(name = "Credential")
|
||||
@Table(name = "credentials")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "Credential")
|
||||
@Table(name = "credentials")
|
||||
public class Credential extends BaseEntity {
|
||||
|
||||
private static final int TOKEN_EXPIRATION = 60 * 24;
|
||||
|
|
|
@ -11,12 +11,12 @@ import java.io.Serializable;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
@Entity
|
||||
@Table(name = "privileges")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "Privilege")
|
||||
@Table(name = "privileges")
|
||||
public class Privilege implements Serializable {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -18,12 +18,12 @@ import java.util.HashSet;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "roles")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity(name = "Role")
|
||||
@Table(name = "roles")
|
||||
public class Role implements Serializable {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -2,8 +2,6 @@ package org.springframework.samples.petclinic.model.common;
|
|||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.springframework.samples.petclinic.common.CommonError;
|
||||
import org.springframework.samples.petclinic.common.CommonParameter;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
@ -22,10 +20,10 @@ import java.util.*;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(name = "User")
|
||||
@Table(name = "users")
|
||||
public class User extends Person implements Serializable, UserDetails {
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.springframework.samples.petclinic.model.common;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +10,8 @@ import java.time.LocalDate;
|
|||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WebSocketMessage {
|
||||
|
||||
public static final String ALERT = "alert";
|
||||
|
@ -39,36 +44,4 @@ public class WebSocketMessage {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.springframework.data.jpa.repository.Query;
|
|||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.samples.petclinic.model.common.Credential;
|
||||
import org.springframework.samples.petclinic.model.common.User;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.springframework.samples.petclinic.model.common.AuthProvider;
|
|||
import org.springframework.samples.petclinic.model.common.Credential;
|
||||
import org.springframework.samples.petclinic.repository.AuthProviderRepository;
|
||||
import org.springframework.samples.petclinic.repository.CredentialRepository;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -22,16 +21,12 @@ public class CredentialService {
|
|||
|
||||
private final CredentialRepository credentialRepository;
|
||||
|
||||
private final BCryptPasswordEncoder bCryptPasswordEncoder;
|
||||
|
||||
private final AuthProviderRepository authProviderRepository;
|
||||
|
||||
private final ModelMapper modelMapper = new ModelMapper();
|
||||
|
||||
public CredentialService(CredentialRepository credentialRepository, BCryptPasswordEncoder bCryptPasswordEncoder,
|
||||
AuthProviderRepository authProviderRepository) {
|
||||
public CredentialService(CredentialRepository credentialRepository, AuthProviderRepository authProviderRepository) {
|
||||
this.credentialRepository = credentialRepository;
|
||||
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
|
||||
this.authProviderRepository = authProviderRepository;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,11 @@ import javax.mail.internet.MimeMessage;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Simple Service to send email from PetClinic to users.
|
||||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("EmailService")
|
||||
public class EmailService {
|
||||
|
|
|
@ -73,9 +73,7 @@ public class PrivilegeService implements BaseService<Privilege, PrivilegeDTO> {
|
|||
Collection<Privilege> privileges = privilegeRepository.findAll();
|
||||
List<PrivilegeDTO> privilegeDTOS = new ArrayList<>();
|
||||
|
||||
privileges.forEach(privilege -> {
|
||||
privilegeDTOS.add(entityToDTO(privilege));
|
||||
});
|
||||
privileges.forEach(privilege -> privilegeDTOS.add(entityToDTO(privilege)));
|
||||
|
||||
return privilegeDTOS;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.springframework.samples.petclinic.service.common;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
@ -8,7 +7,12 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Simple Service between AuthProvider entity and AuthProviderDTO Data Transfert Object.
|
||||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
|
||||
@Service("SecurityService")
|
||||
public class SecurityServiceImpl implements SecurityService {
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.springframework.samples.petclinic.service.common;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.samples.petclinic.dto.common.UserDTO;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
@ -9,7 +8,11 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
/**
|
||||
* Simple Service to get UserDetails for authentification from UserService.
|
||||
*
|
||||
* @author Paul-Emmanuel DOS SANTOS FACAO
|
||||
*/
|
||||
@Service("UserDetailsService")
|
||||
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
|
|
|
@ -81,9 +81,7 @@ public class UserService implements BaseService<User, UserDTO> {
|
|||
Collection<User> users = userRepository.findAll();
|
||||
List<UserDTO> userDTOS = new ArrayList<>();
|
||||
|
||||
users.forEach(user -> {
|
||||
userDTOS.add(entityToDTO(user));
|
||||
});
|
||||
users.forEach(user -> userDTOS.add(entityToDTO(user)));
|
||||
|
||||
return userDTOS;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,10 @@
|
|||
spring.security.oauth2.client.registration.google.client-id=${OAUTH2_GOOGLE_CLIENT_ID}
|
||||
spring.security.oauth2.client.registration.google.client-secret=${OAUTH2_GOOGLE_CLIENT_SECRET}
|
||||
|
||||
#spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
||||
#spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
||||
spring.security.oauth2.client.registration.github.client-id=d3e47fc2ddd966fa4352
|
||||
spring.security.oauth2.client.registration.github.client-secret=3bc0f6b8332f93076354c2a5bada2f5a05aea60d
|
||||
spring.security.oauth2.client.registration.github.client-id=${OAUTH2_GITHUB_CLIENT_ID}
|
||||
spring.security.oauth2.client.registration.github.client-secret=${OAUTH2_GITHUB_CLIENT_SECRET}
|
||||
|
||||
#spring.security.oauth2.client.registration.facebook.client-id=${OAUTH2_FACEBOOK_CLIENT_ID}
|
||||
#spring.security.oauth2.client.registration.facebook.client-secret=${OAUTH2_FACEBOOK_CLIENT_SECRET}
|
||||
spring.security.oauth2.client.registration.facebook.client-id=121189305185277
|
||||
spring.security.oauth2.client.registration.facebook.client-secret=42ffe5aa7379e8326387e0fe16f34132
|
||||
|
||||
#spring.security.oauth2.client.registration.twitter.client-id=YrtJmnJJjpxEH3289eVyFxCNt
|
||||
#spring.security.oauth2.client.registration.twitter.client-secret=aMMFcgJlGpSKvAuiwBgWSXCzjzcOezLgGZtkdmGISUPk7CIzcB
|
||||
|
||||
#spring.security.oauth2.client.registration.linkedin.client-id=121189305185277
|
||||
#spring.security.oauth2.client.registration.linkedin.client-secret=42ffe5aa7379e8326387e0fe16f34132
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class CredentialServiceIntegrationTest {
|
|||
void beforeEach() {
|
||||
allCredentials = credentialRepository.findAll();
|
||||
|
||||
credentialService = new CredentialService(credentialRepository, bCryptPasswordEncoder, authProviderRepository);
|
||||
credentialService = new CredentialService(credentialRepository, authProviderRepository);
|
||||
authProvider = new AuthProvider(PROVIDER_TEST_ID, PROVIDER_TEST_NAME);
|
||||
credential = new Credential(PROVIDER_TEST_ID, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credential.setToken(TOKEN_TEST);
|
||||
|
|
|
@ -59,7 +59,7 @@ class CredentialServiceTest {
|
|||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
credentialService = new CredentialService(credentialRepository, bCryptPasswordEncoder, authProviderRepository);
|
||||
credentialService = new CredentialService(credentialRepository, authProviderRepository);
|
||||
authProvider = new AuthProvider(PROVIDER_TEST_ID, PROVIDER_TEST_NAME);
|
||||
credential = new Credential(PROVIDER_TEST_ID, EMAIL_TEST, PASSWORD_TEST, true);
|
||||
credential.setToken(TOKEN_TEST);
|
||||
|
|
Loading…
Reference in a new issue