generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from it-at-m/174-bereitstellung-datenstrukturen
174 bereitstellung datenstrukturen
- Loading branch information
Showing
27 changed files
with
1,648 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...va/de/muenchen/oss/wahllokalsystem/authservice/configuration/EncryptionConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.configuration; | ||
|
||
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ServiceIDFormatter; | ||
import de.muenchen.oss.wahllokalsystem.wls.common.security.EncryptionBuilder; | ||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import javax.crypto.NoSuchPaddingException; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class EncryptionConfiguration { | ||
|
||
@Bean | ||
public EncryptionBuilder encryptionBuilder(@Value("{serviceauth.crypto.key}") final String cryptoKey, final ServiceIDFormatter serviceIDFormatter) | ||
throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException { | ||
return new EncryptionBuilder(cryptoKey.getBytes(), serviceIDFormatter); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...h-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/Authority.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.JoinTable; | ||
import jakarta.persistence.ManyToMany; | ||
import java.util.Set; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.hibernate.annotations.NaturalId; | ||
|
||
@Entity | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class Authority extends BaseEntity { | ||
|
||
@ToString.Exclude | ||
@NaturalId | ||
private String authority; | ||
|
||
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.REFRESH }, fetch = FetchType.EAGER) | ||
@JoinTable( | ||
name = "secauthorities_secpermissions", joinColumns = @JoinColumn(name = "authority_oid"), inverseJoinColumns = @JoinColumn(name = "permission_oid") | ||
) | ||
private Set<Permission> permissions; | ||
|
||
@ManyToMany(mappedBy = "authorities", cascade = CascadeType.ALL) | ||
private Set<User> users; | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/AuthorityRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface AuthorityRepository extends CrudRepository<Authority, UUID> { | ||
|
||
Optional<Authority> findByAuthority(String authority); | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...ervice/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/LoginAttempt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.hibernate.annotations.NaturalId; | ||
|
||
@Entity | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class LoginAttempt extends BaseEntity { | ||
|
||
@NaturalId | ||
@NotNull | ||
@Pattern(regexp = "[a-zA-Z0-9_\\.-]*") | ||
@Size(min = 1) | ||
@ToString.Include | ||
private String username; | ||
|
||
@NotNull | ||
@ToString.Include | ||
private int attempts; | ||
|
||
@ToString.Include | ||
private LocalDateTime lastModified; | ||
} |
11 changes: 11 additions & 0 deletions
11
.../main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/LoginAttemptRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface LoginAttemptRepository extends CrudRepository<LoginAttempt, UUID> { | ||
|
||
Optional<LoginAttempt> findByUsername(String username); | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/Permission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class Permission extends BaseEntity { | ||
|
||
@ToString.Include | ||
private String permission; | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/PermissionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface PermissionRepository extends CrudRepository<Permission, UUID> { | ||
|
||
Optional<Permission> findByPermission(String permission); | ||
} |
77 changes: 77 additions & 0 deletions
77
wls-auth-service/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.JoinTable; | ||
import jakarta.persistence.ManyToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import java.time.LocalDate; | ||
import java.util.Set; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.hibernate.annotations.NaturalId; | ||
|
||
@Entity | ||
@Table(name = "Wlsuser") //user as table name is already in use by h2 | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@ToString(onlyExplicitlyIncluded = true) | ||
public class User extends BaseEntity { | ||
|
||
@NaturalId | ||
@NotNull | ||
@Size(min = 1) | ||
@ToString.Include | ||
private String username; | ||
|
||
@ToString.Include | ||
private String password; | ||
|
||
@ToString.Include | ||
private String email; | ||
|
||
@ToString.Include | ||
private boolean userEnabled; | ||
|
||
@ToString.Include | ||
private boolean accountNonLocked; | ||
|
||
@ToString.Include | ||
private String wahltagID; | ||
|
||
@ToString.Include | ||
private LocalDate wahltag; | ||
|
||
@ToString.Include | ||
private String wahlbezirkID; | ||
|
||
@ToString.Include | ||
private String wahlbezirkNummer; | ||
|
||
@ToString.Include | ||
@Enumerated(EnumType.STRING) | ||
private Wahlbezirksart wahlbezirksArt; | ||
|
||
@ToString.Include | ||
private String pin; | ||
|
||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST) | ||
@JoinTable(name = "Secusers_Secauthorities", joinColumns = { @JoinColumn(name = "user_oid") }, inverseJoinColumns = { @JoinColumn(name = "authority_oid") }) | ||
private Set<Authority> authorities; | ||
|
||
@ToString.Include | ||
private String wbid_wahlnummer; | ||
} |
22 changes: 22 additions & 0 deletions
22
...vice/src/main/java/de/muenchen/oss/wahllokalsystem/authservice/domain/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.muenchen.oss.wahllokalsystem.authservice.domain; | ||
|
||
import java.util.Collection; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface UserRepository { | ||
|
||
Optional<User> findByUsername(final String username); | ||
|
||
Collection<User> findByWahltagID(final String wahltagID); | ||
|
||
Optional<User> findById(final UUID oid); | ||
|
||
boolean exists(final String username); | ||
|
||
User save(final User user); | ||
|
||
Iterable<User> saveAll(final Iterable<User> users); | ||
|
||
void deleteUsersByWahltagID(final String wahltagid); | ||
} |
Oops, something went wrong.