-
Notifications
You must be signed in to change notification settings - Fork 1
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 #824 from dickschoeller/security
Security
- Loading branch information
Showing
177 changed files
with
8,029 additions
and
2,582 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
76 changes: 76 additions & 0 deletions
76
gedbrowser-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/users/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,76 @@ | ||
package org.schoellerfamily.gedbrowser.datamodel.users; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
*/ | ||
public interface User { | ||
/** | ||
* @return the user name | ||
*/ | ||
String getUsername(); | ||
|
||
/** | ||
* @param username the user name | ||
*/ | ||
void setUsername(String username); | ||
|
||
/** | ||
* @return the user's first name | ||
*/ | ||
String getFirstname(); | ||
|
||
/** | ||
* @param firstname the first name | ||
*/ | ||
void setFirstname(String firstname); | ||
|
||
/** | ||
* @return the user's last name | ||
*/ | ||
String getLastname(); | ||
|
||
/** | ||
* @param lastname the last name | ||
*/ | ||
void setLastname(String lastname); | ||
|
||
/** | ||
* @return the user's email address | ||
*/ | ||
String getEmail(); | ||
|
||
/** | ||
* @param email the email address | ||
*/ | ||
void setEmail(String email); | ||
|
||
/** | ||
* @return the user's password | ||
*/ | ||
String getPassword(); | ||
|
||
/** | ||
* @param password the password | ||
*/ | ||
void setPassword(String password); | ||
|
||
/** | ||
* The roles supported are user and admin. | ||
* | ||
* @return the set of roles for this user | ||
*/ | ||
UserRoleName[] getRoles(); | ||
|
||
/** | ||
* @param role the role to add to the role set | ||
*/ | ||
void addRole(String role); | ||
|
||
/** | ||
* Check if the user has a particular role. | ||
* | ||
* @param role role that we are looking for | ||
* @return true if the user has the role | ||
*/ | ||
boolean hasRole(UserRoleName role); | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/users/UserRoleName.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,18 @@ | ||
package org.schoellerfamily.gedbrowser.datamodel.users; | ||
|
||
/** | ||
* Roles. Any access without roles is read-only and limited data | ||
* visibility. | ||
* | ||
* @author Dick Schoeller | ||
*/ | ||
public enum UserRoleName { | ||
/** | ||
* The role associated with logged in user capabilities. | ||
*/ | ||
USER, | ||
/** | ||
* The role associated with administrator capabilities. | ||
*/ | ||
ADMIN | ||
} |
43 changes: 43 additions & 0 deletions
43
gedbrowser-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/users/Users.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,43 @@ | ||
package org.schoellerfamily.gedbrowser.datamodel.users; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
* | ||
* @param <T> the contained type | ||
*/ | ||
public interface Users<T extends User> extends Iterable<T> { | ||
/** | ||
* @param user the user to add | ||
* @return that user | ||
*/ | ||
T add(T user); | ||
|
||
/** | ||
* @param user the user to remove | ||
* @return that user | ||
*/ | ||
T remove(T user); | ||
|
||
/** | ||
* @param username the username of the user we are getting | ||
* @return that user | ||
*/ | ||
T get(String username); | ||
|
||
/** | ||
* Resets to an empty set. | ||
*/ | ||
void clear(); | ||
|
||
/** | ||
* @return the iterator for the value collection | ||
*/ | ||
Iterator<T> iterator(); | ||
|
||
/** | ||
* @return the iterator for the value collection | ||
*/ | ||
int size(); | ||
} |
63 changes: 63 additions & 0 deletions
63
...ser-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/users/UsersImpl.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,63 @@ | ||
package org.schoellerfamily.gedbrowser.datamodel.users; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Dick Schoeller | ||
* | ||
* @param <T> the contained type | ||
*/ | ||
public final class UsersImpl<T extends User> implements Users<T> { | ||
/** Holds the known users. */ | ||
private final Map<String, T> users = new HashMap<>(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public T add(final T user) { | ||
return users.put(user.getUsername(), user); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public T remove(final User user) { | ||
return users.remove(user.getUsername()); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public T get(final String username) { | ||
return users.get(username); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void clear() { | ||
users.clear(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Iterator<T> iterator() { | ||
return users.values().iterator(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int size() { | ||
return users.values().size(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...-datamodel/src/main/java/org/schoellerfamily/gedbrowser/datamodel/users/package-info.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,5 @@ | ||
/** | ||
* Copyright 2019 Richard Schoeller | ||
* Data model to describe users. | ||
*/ | ||
package org.schoellerfamily.gedbrowser.datamodel.users; |
18 changes: 18 additions & 0 deletions
18
gedbrowser-reader/src/main/java/org/schoellerfamily/gedbrowser/users/UserFactory.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,18 @@ | ||
package org.schoellerfamily.gedbrowser.users; | ||
|
||
import org.schoellerfamily.gedbrowser.datamodel.users.User; | ||
|
||
/** | ||
* Factory interface for creating User objects. Implementations will generally | ||
* be injected to situations that need to create them as a lambda. | ||
* | ||
* @author Dick Schoeller | ||
* | ||
* @param <T> the created type | ||
*/ | ||
public interface UserFactory<T extends User> { | ||
/** | ||
* @return the built user | ||
*/ | ||
T createUser(); | ||
} |
18 changes: 18 additions & 0 deletions
18
gedbrowser-reader/src/main/java/org/schoellerfamily/gedbrowser/users/UsersFactory.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,18 @@ | ||
package org.schoellerfamily.gedbrowser.users; | ||
|
||
import org.schoellerfamily.gedbrowser.datamodel.users.Users; | ||
|
||
/** | ||
* Factory interface for creating Users objects. Implementations will | ||
* generally be injected to situations that need to create them as a lambda. | ||
* | ||
* @author Dick Schoeller | ||
* | ||
* @param <T> the created type | ||
*/ | ||
public interface UsersFactory<T extends Users<?>> { | ||
/** | ||
* @return the object that manages a collection of users | ||
*/ | ||
T createUsers(); | ||
} |
Oops, something went wrong.