Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CTF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grzegorz
CTF
Commits
96f4808c
Commit
96f4808c
authored
Feb 22, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first try to use morphia - general refactor
parent
97ce89d6
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
145 additions
and
217 deletions
+145
-217
configuration.yml
service/configuration.yml
+30
-30
CTFApplication.java
service/src/main/java/CTFApplication.java
+37
-12
DBConnector.java
service/src/main/java/database/DBConnector.java
+0
-10
MongoDBConnector.java
service/src/main/java/database/MongoDBConnector.java
+0
-62
Team.java
service/src/main/java/objects/Team.java
+20
-39
User.java
service/src/main/java/objects/User.java
+18
-19
SolutionsRepository.java
service/src/main/java/repositories/SolutionsRepository.java
+9
-9
TasksRepository.java
service/src/main/java/repositories/TasksRepository.java
+12
-13
TeamsRepository.java
service/src/main/java/repositories/TeamsRepository.java
+12
-15
UsersRepository.java
service/src/main/java/repositories/UsersRepository.java
+7
-8
No files found.
service/configuration.yml
View file @
96f4808c
...
...
@@ -17,37 +17,37 @@ testsTemporary:
teams
:
-
name
:
"
misiaczki"
description
:
"
misiaczki
opis"
members
:
-
name
:
"
gpietrus1"
password
:
"
41b450e73c974fca46911eba84e114f2"
#gpietrus md5
email
:
"
gpietrusza@gmail.com"
-
name
:
"
mehow1"
password
:
"
c4d24515428cb3ad50e7840be8718f23"
#mehos123 md5
email
:
"
mehow@gmail.com"
-
name
:
"
rosiu1"
password
:
"
188ed9df2dac8e10f5c5fd2e02383765"
#rosiu321 md5
email
:
"
rosiu@gmail.com"
#
members:
#
- name: "gpietrus1"
#
password: "41b450e73c974fca46911eba84e114f2" #gpietrus md5
#
email: "gpietrusza@gmail.com"
#
- name: "mehow1"
#
password: "c4d24515428cb3ad50e7840be8718f23" #mehos123 md5
#
email: "mehow@gmail.com"
#
- name: "rosiu1"
#
password: "188ed9df2dac8e10f5c5fd2e02383765" #rosiu321 md5
#
email: "rosiu@gmail.com"
-
name
:
"
prosiaczki"
description
:
"
prosiaczki
opis"
members
:
-
name
:
"
gpietrus2"
password
:
"
41b450e73c974fca46911eba84e114f2"
#gpietrus md5
email
:
"
gpietrusza@gmail.com"
-
name
:
"
mehow2"
password
:
"
c4d24515428cb3ad50e7840be8718f23"
#mehos123 md5
email
:
"
mehow@gmail.com"
-
name
:
"
rosiu2"
password
:
"
188ed9df2dac8e10f5c5fd2e02383765"
#rosiu321 md5
email
:
"
rosiu@gmail.com"
#
members:
#
- name: "gpietrus2"
#
password: "41b450e73c974fca46911eba84e114f2" #gpietrus md5
#
email: "gpietrusza@gmail.com"
#
- name: "mehow2"
#
password: "c4d24515428cb3ad50e7840be8718f23" #mehos123 md5
#
email: "mehow@gmail.com"
#
- name: "rosiu2"
#
password: "188ed9df2dac8e10f5c5fd2e02383765" #rosiu321 md5
#
email: "rosiu@gmail.com"
-
name
:
"
dupeczki"
description
:
"
dupeczki
opis"
members
:
-
name
:
"
gpietrus3"
password
:
"
41b450e73c974fca46911eba84e114f2"
#gpietrus md5
email
:
"
gpietrusza@gmail.com"
-
name
:
"
mehow3"
password
:
"
c4d24515428cb3ad50e7840be8718f23"
#mehos123 md5
email
:
"
mehow@gmail.com"
-
name
:
"
rosiu3"
password
:
"
188ed9df2dac8e10f5c5fd2e02383765"
#rosiu321 md5
email
:
"
rosiu@gmail.com"
#
members:
#
- name: "gpietrus3"
#
password: "41b450e73c974fca46911eba84e114f2" #gpietrus md5
#
email: "gpietrusza@gmail.com"
#
- name: "mehow3"
#
password: "c4d24515428cb3ad50e7840be8718f23" #mehos123 md5
#
email: "mehow@gmail.com"
#
- name: "rosiu3"
#
password: "188ed9df2dac8e10f5c5fd2e02383765" #rosiu321 md5
#
email: "rosiu@gmail.com"
service/src/main/java/CTFApplication.java
View file @
96f4808c
...
...
@@ -7,9 +7,9 @@ import com.google.common.base.Optional;
import
com.google.inject.AbstractModule
;
import
com.google.inject.Guice
;
import
com.google.inject.Injector
;
import
com.mongodb.MongoClient
;
import
core.ApplicationConfiguration
;
import
core.TaskType
;
import
database.MongoDBConnector
;
import
io.dropwizard.Application
;
import
io.dropwizard.assets.AssetsBundle
;
import
io.dropwizard.auth.*
;
...
...
@@ -19,13 +19,18 @@ import io.dropwizard.setup.Bootstrap;
import
io.dropwizard.setup.Environment
;
import
objects.Flag
;
import
objects.Task
;
import
objects.Team
;
import
objects.User
;
import
org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
;
import
org.mongodb.morphia.Datastore
;
import
org.mongodb.morphia.Morphia
;
import
repositories.SolutionsRepository
;
import
repositories.TasksRepository
;
import
repositories.TeamsRepository
;
import
repositories.UsersRepository
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Stream
;
...
...
@@ -34,6 +39,8 @@ import java.util.stream.Stream;
*/
public
class
CTFApplication
extends
Application
<
ApplicationConfiguration
>
{
private
Morphia
morphia
;
private
Datastore
datastore
;
private
UsersRepository
usersRepository
;
//todo: refactor to injects
private
TasksRepository
tasksRepository
;
//todo: refactor to injects
...
...
@@ -46,17 +53,34 @@ public class CTFApplication extends Application<ApplicationConfiguration> {
.
forEach
(
bootstrap:
:
addBundle
);
}
private
void
initializeMorhpia
()
{
morphia
=
new
Morphia
();
morphia
.
mapPackage
(
"objects.Team"
);
datastore
=
morphia
.
createDatastore
(
new
MongoClient
(),
"db"
);
//todo: db name from conf
datastore
.
ensureIndexes
();
}
@Override
public
void
run
(
ApplicationConfiguration
applicationConfiguration
,
Environment
environment
)
throws
Exception
{
MongoDBConnector
dbConnector
=
new
MongoDBConnector
(
applicationConfiguration
);
dbConnector
.
connect
();
Injector
injector
=
createInjector
(
applicationConfiguration
,
d
bConnector
);
initializeMorhpia
();
Injector
injector
=
createInjector
(
applicationConfiguration
,
d
atastore
);
//REGISTER TEAMS
TeamsRepository
teamsRepository
=
new
TeamsRepository
(
d
bConnector
);
TeamsRepository
teamsRepository
=
new
TeamsRepository
(
d
atastore
);
teamsRepository
.
clean
();
applicationConfiguration
.
getTeams
().
forEach
(
teamsRepository:
:
add
);
User
user
=
new
User
(
"gumis1"
,
"gumis"
,
"gumis@gumis.pl"
);
datastore
.
save
(
user
);
ArrayList
<
User
>
objects
=
new
ArrayList
<>();
objects
.
add
(
user
);
Team
gumisie
=
new
Team
(
"gumisie"
,
"gumisie desc"
,
objects
);
datastore
.
save
(
gumisie
);
// applicationConfiguration.getTeams().forEach(teamsRepository::add);
//todo: users should be saved first
List
<
Team
>
all
=
teamsRepository
.
getAll
();
//GENERATE TASKS
tasksRepository
.
clean
();
...
...
@@ -89,6 +113,7 @@ public class CTFApplication extends Application<ApplicationConfiguration> {
environment
.
jersey
().
register
(
RolesAllowedDynamicFeature
.
class
);
//If you want to use @Auth to inject a custom Principal type into your resource
environment
.
jersey
().
register
(
new
AuthValueFactoryProvider
.
Binder
<>(
User
.
class
));
}
//todo: move to seperate class
...
...
@@ -119,17 +144,17 @@ public class CTFApplication extends Application<ApplicationConfiguration> {
}
//todo: inject dbonnector
private
Injector
createInjector
(
ApplicationConfiguration
applicationConfiguration
,
MongoDBConnector
dbConnector
)
{
private
Injector
createInjector
(
ApplicationConfiguration
applicationConfiguration
,
Datastore
datastore
)
{
return
Guice
.
createInjector
(
new
AbstractModule
()
{
@Override
protected
void
configure
()
{
bind
(
ApplicationConfiguration
.
class
).
toInstance
(
applicationConfiguration
);
bind
(
MongoDBConnector
.
class
).
toInstance
(
dbConnector
);
TeamsRepository
teamsRepository
=
new
TeamsRepository
(
dbConnector
);
usersRepository
=
new
UsersRepository
(
dbConnector
,
teamsRepository
);
SolutionsRepository
solutionsRepository
=
new
SolutionsRepository
(
dbConnector
);
tasksRepository
=
new
TasksRepository
(
applicationConfiguration
,
dbConnector
,
teamsRepository
,
solutionsRepository
);
//todo: refactor?
TeamsRepository
teamsRepository
=
new
TeamsRepository
(
datastore
);
usersRepository
=
new
UsersRepository
(
datastore
,
teamsRepository
);
SolutionsRepository
solutionsRepository
=
new
SolutionsRepository
(
datastore
);
tasksRepository
=
new
TasksRepository
(
applicationConfiguration
,
datastore
,
teamsRepository
,
solutionsRepository
);
bind
(
TeamsRepository
.
class
).
toInstance
(
teamsRepository
);
bind
(
TasksRepository
.
class
).
toInstance
(
tasksRepository
);
...
...
service/src/main/java/database/DBConnector.java
deleted
100644 → 0
View file @
97ce89d6
package
database
;
/**
* Created by gpietrus on 20.02.2016.
*/
public
interface
DBConnector
{
public
void
connect
();
public
void
disconnect
();
public
void
databaseCleanup
();
}
service/src/main/java/database/MongoDBConnector.java
deleted
100644 → 0
View file @
97ce89d6
package
database
;
import
com.mongodb.MongoClient
;
import
com.mongodb.client.MongoDatabase
;
import
core.ApplicationConfiguration
;
import
org.bson.BsonDocument
;
import
org.bson.Document
;
import
java.util.ArrayList
;
import
java.util.Map
;
/**
* Created by gpietrus on 20.02.2016.
*/
public
class
MongoDBConnector
implements
DBConnector
{
private
ApplicationConfiguration
applicationConfiguration
;
private
MongoClient
mongoClient
;
private
MongoDatabase
database
;
public
MongoDBConnector
(
ApplicationConfiguration
applicationConfiguration
)
{
this
.
applicationConfiguration
=
applicationConfiguration
;
}
@Override
public
void
connect
()
{
//todo: get from configuration file
mongoClient
=
new
MongoClient
(
applicationConfiguration
.
getDbHost
(),
applicationConfiguration
.
getDbPort
());
this
.
database
=
mongoClient
.
getDatabase
(
applicationConfiguration
.
getDbName
()
);
}
@Override
public
void
disconnect
()
{
}
@Override
public
void
databaseCleanup
()
{
}
public
ArrayList
<
Document
>
getCollection
(
String
collectionName
)
{
return
database
.
getCollection
(
collectionName
).
find
().
into
(
new
ArrayList
<>());
}
public
void
getDocument
(
String
collectionName
,
Map
criteria
)
{
BsonDocument
bsonDocument
=
new
BsonDocument
();
bsonDocument
.
putAll
(
criteria
);
database
.
getCollection
(
collectionName
).
find
(
bsonDocument
);
}
public
void
addDocument
(
String
collectionName
,
Document
document
)
{
database
.
getCollection
(
collectionName
).
insertOne
(
document
);
}
public
void
removeCollection
(
String
collectionName
)
{
database
.
getCollection
(
collectionName
).
drop
();
}
}
service/src/main/java/objects/Team.java
View file @
96f4808c
...
...
@@ -2,40 +2,25 @@ package objects;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.google.common.collect.ImmutableMap
;
import
org.bson.Document
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
org.mongodb.morphia.annotations.Reference
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* Created by gpietrus on 20.02.2016.
*/
@Entity
(
"teams"
)
public
class
Team
{
@Id
private
ObjectId
id
;
private
String
name
;
private
String
description
;
private
List
<
User
>
members
;
public
static
Team
fromDocument
(
Document
document
)
{
return
new
Team
(
document
.
get
(
"name"
).
toString
(),
document
.
get
(
"description"
).
toString
(),
((
ArrayList
<
Document
>)
document
.
get
(
"members"
))
//todo
.
stream
()
.
map
(
User:
:
fromDocument
)
.
collect
(
Collectors
.
toList
())
);
//todo: refactor mapping
}
public
List
<
User
>
getMembers
()
{
return
members
;
}
public
void
setMembers
(
List
members
)
{
this
.
members
=
members
;
}
@Reference
private
List
<
User
>
members
;
@JsonCreator
public
Team
(
@JsonProperty
(
"name"
)
String
name
,
...
...
@@ -46,6 +31,17 @@ public class Team {
this
.
members
=
members
;
}
public
Team
()
{
}
public
ObjectId
getId
()
{
return
id
;
}
public
void
setId
(
ObjectId
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
...
...
@@ -62,19 +58,4 @@ public class Team {
this
.
description
=
description
;
}
//todo: refactor mapping
public
Map
<
String
,
Object
>
toMap
()
{
//todo: refacotr mapping
List
<
Object
>
membersList
=
members
.
stream
()
.
map
(
User:
:
toMap
)
.
collect
(
Collectors
.
toList
());
return
ImmutableMap
.<
String
,
Object
>
builder
()
.
put
(
"name"
,
name
)
.
put
(
"description"
,
description
)
.
put
(
"members"
,
membersList
)
.
build
();
}
}
service/src/main/java/objects/User.java
View file @
96f4808c
...
...
@@ -2,26 +2,23 @@ package objects;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.google.common.collect.ImmutableMap
;
import
org.bson.Document
;
import
org.bson.types.ObjectId
;
import
org.mongodb.morphia.annotations.Entity
;
import
org.mongodb.morphia.annotations.Id
;
import
java.security.Principal
;
import
java.util.Map
;
/**
* Created by gpietrus on 16.02.16.
*/
@Entity
(
"users"
)
public
class
User
implements
Principal
{
@Id
private
ObjectId
id
;
private
String
name
;
private
String
password
;
private
String
email
;
public
static
User
fromDocument
(
Document
document
)
{
return
new
User
(
document
.
get
(
"name"
).
toString
(),
document
.
get
(
"password"
).
toString
(),
document
.
get
(
"password"
).
toString
()
);
}
@JsonCreator
public
User
(
@JsonProperty
(
"name"
)
String
name
,
...
...
@@ -32,6 +29,18 @@ public class User implements Principal {
this
.
email
=
email
;
}
public
User
()
{
}
public
ObjectId
getId
()
{
return
id
;
}
public
void
setId
(
ObjectId
id
)
{
this
.
id
=
id
;
}
@Override
public
String
getName
()
{
return
name
;
}
...
...
@@ -55,14 +64,4 @@ public class User implements Principal {
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
//todo: refactor mapping
public
Map
<
String
,
Object
>
toMap
()
{
return
ImmutableMap
.<
String
,
Object
>
builder
()
.
put
(
"name"
,
name
)
.
put
(
"password"
,
password
)
.
build
();
}
//todo: contructor fromMap
}
service/src/main/java/repositories/SolutionsRepository.java
View file @
96f4808c
package
repositories
;
import
database.MongoDBConnector
;
import
objects.Solution
;
import
org.
bson.Document
;
import
org.
mongodb.morphia.Datastore
;
import
javax.inject.Inject
;
import
java.util.List
;
...
...
@@ -14,11 +13,11 @@ import java.util.stream.Collectors;
* Created by gpietrus on 20.02.2016.
*/
public
class
SolutionsRepository
implements
Repository
{
private
MongoDBConnector
mongoDBConnector
;
private
Datastore
datastore
;
@Inject
public
SolutionsRepository
(
MongoDBConnector
mongoDBConnector
)
{
this
.
mongoDBConnector
=
mongoDBConnector
;
public
SolutionsRepository
(
Datastore
datastore
)
{
this
.
datastore
=
datastore
;
}
// public void get(UUID uuid) {
...
...
@@ -26,10 +25,11 @@ public class SolutionsRepository implements Repository {
// }
public
List
<
Solution
>
getAll
()
{
return
mongoDBConnector
.
getCollection
(
"solutions"
)
return
null
;
//todo
/* return mongoDBConnector.getCollection("solutions")
.stream()
.map(Solution::new)
.
collect
(
Collectors
.
toList
());
.collect(Collectors.toList());
*/
//todo: revert
}
public
void
add
(
Solution
solution
)
{
//todo
...
...
@@ -39,11 +39,11 @@ public class SolutionsRepository implements Repository {
(
Function
<
Map
.
Entry
<
String
,
String
>,
String
>)
Map
.
Entry
::
getKey
,
(
Function
<
Map
.
Entry
<
String
,
String
>,
Object
>)
Map
.
Entry
::
getValue
));
mongoDBConnector
.
addDocument
(
"solutions"
,
new
Document
(
retypedMap
));
// mongoDBConnector.addDocument("solutions", new Document(retypedMap)); //todo: revert
}
public
void
clean
()
{
mongoDBConnector
.
removeCollection
(
"solutions"
);
// mongoDBConnector.removeCollection("solutions"); //todo: revert
}
}
...
...
service/src/main/java/repositories/TasksRepository.java
View file @
96f4808c
package
repositories
;
import
core.ApplicationConfiguration
;
import
database.MongoDBConnector
;
import
objects.Solution
;
import
objects.Task
;
import
org.apache.commons.codec.binary.Hex
;
import
org.
bson.Document
;
import
org.
mongodb.morphia.Datastore
;
import
javax.inject.Inject
;
import
java.security.MessageDigest
;
...
...
@@ -22,16 +20,16 @@ import java.util.stream.Collectors;
public
class
TasksRepository
implements
Repository
{
private
ApplicationConfiguration
applicationConfiguration
;
private
MongoDBConnector
mongoDBConnector
;
private
Datastore
datastore
;
private
TeamsRepository
teamsRepository
;
private
SolutionsRepository
solutionsRepository
;
private
String
salt
=
"SECURE_SALT"
;
//todo
@Inject
public
TasksRepository
(
ApplicationConfiguration
applicationConfiguration
,
MongoDBConnector
mongoDBConnector
,
public
TasksRepository
(
ApplicationConfiguration
applicationConfiguration
,
Datastore
datastore
,
TeamsRepository
teamsRepository
,
SolutionsRepository
solutionsRepository
)
{
this
.
applicationConfiguration
=
applicationConfiguration
;
this
.
mongoDBConnector
=
mongoDBConnector
;
this
.
datastore
=
datastore
;
this
.
teamsRepository
=
teamsRepository
;
this
.
solutionsRepository
=
solutionsRepository
;
}
...
...
@@ -41,18 +39,19 @@ public class TasksRepository implements Repository {
}
public
List
<
Task
>
getAll
()
{
return
mongoDBConnector
.
getCollection
(
"tasks"
)
.
stream
()
.
map
(
Task:
:
new
)
.
collect
(
Collectors
.
toList
());
return
null
;
//todo
// return mongoDBConnector.getCollection("tasks")
// .stream()
// .map(Task::new)
// .collect(Collectors.toList());
}
public
void
add
(
Task
task
)
{
mongoDBConnector
.
addDocument
(
"tasks"
,
new
Document
(
task
.
toMap
()));
// mongoDBConnector.addDocument("tasks", new Document(task.toMap())); //todo
}
public
void
clean
()
{
mongoDBConnector
.
removeCollection
(
"tasks"
);
// mongoDBConnector.removeCollection("tasks"); //todo
}
public
Map
<
String
,
Task
>
getUserFlagsHashes
(
String
username
)
{
...
...
@@ -77,7 +76,7 @@ public class TasksRepository implements Repository {
private
void
acceptSolution
(
String
username
,
Task
task
)
{
//todo: getname, of get id?
solutionsRepository
.
add
(
new
Solution
(
teamsRepository
.
getTeamByUser
(
username
).
getName
(),
task
.
getName
()));
// solutionsRepository.add(new Solution(teamsRepository.getTeamByUser(username).getName(), task.getName())); //tidod
}
private
boolean
compareHash
(
String
hash
,
String
username
)
throws
Exception
{
...
...
service/src/main/java/repositories/TeamsRepository.java
View file @
96f4808c
package
repositories
;
import
database.MongoDBConnector
;
import
objects.Team
;
import
objects.User
;
import
org.bson.Document
;
import
org.mongodb.morphia.Datastore
;
import
javax.inject.Inject
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
/**
* Created by gpietrus on 20.02.2016.
*/
public
class
TeamsRepository
implements
Repository
{
private
MongoDBConnector
mongoDBConnector
;
private
Datastore
datastore
;
@Inject
public
TeamsRepository
(
MongoDBConnector
mongoDBConnector
)
{
this
.
mongoDBConnector
=
mongoDBConnector
;
public
TeamsRepository
(
Datastore
datastore
)
{
this
.
datastore
=
datastore
;
}
public
Team
getTeamByUser
(
String
username
)
{
return
getAll
().
stream
()
return
null
;
/* return getAll().stream()
.filter(team -> team.getMembers().stream()
.map(User::getName)
.collect(Collectors.toList())
.contains(username))
.findFirst()
.
get
();
.get();
*/
}
public
void
get
(
UUID
uuid
)
{
}
//todo: move this to inteface!!!
public
List
<
Team
>
getAll
()
{
return
mongoDBConnector
.
getCollection
(
"teams"
)
.
stream
()
.
map
(
Team:
:
fromDocument
)
.
collect
(
Collectors
.
toList
());
return
datastore
.
createQuery
(
Team
.
class
).
asList
();
}
//todo: move to interface
public
void
add
(
Team
team
)
{
mongoDBConnector
.
addDocument
(
"teams"
,
new
Document
(
team
.
toMap
())
);
datastore
.
save
(
team
);
}
public
void
clean
()
{
mongoDBConnector
.
removeCollection
(
"teams"
);
datastore
.
getCollection
(
Team
.
class
).
drop
(
);
}
}
service/src/main/java/repositories/UsersRepository.java
View file @
96f4808c
package
repositories
;
import
database.MongoDBConnector
;
import
io.dropwizard.auth.basic.BasicCredentials
;
import
objects.Team
;
import
objects.User
;
import
org.
apache.commons.codec.binary.Hex
;
import
org.
mongodb.morphia.Datastore
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Collection
;
import
java.util.Optional
;
/**
...
...
@@ -16,13 +13,13 @@ import java.util.Optional;
*/
public
class
UsersRepository
implements
Repository
{
private
MongoDBConnector
mongoDBConnector
;
private
Datastore
datastore
;
private
TeamsRepository
teamsRepository
;
private
MessageDigest
messageDigest
;
public
UsersRepository
(
MongoDBConnector
mongoDBConnector
,
public
UsersRepository
(
Datastore
datastore
,
TeamsRepository
teamsRepository
)
{
this
.
mongoDBConnector
=
mongoDBConnector
;
this
.
datastore
=
datastore
;
this
.
teamsRepository
=
teamsRepository
;
try
{
messageDigest
=
MessageDigest
.
getInstance
(
"MD5"
);
//todo
...
...
@@ -42,6 +39,8 @@ public class UsersRepository implements Repository {
// }
public
Optional
<
User
>
authenticateUser
(
BasicCredentials
basicCredentials
)
{
return
null
;
/*
Optional<User> userOptional = teamsRepository.getAll()
.stream()
.map(Team::getMembers)
...
...
@@ -52,7 +51,7 @@ public class UsersRepository implements Repository {
Hex.encodeHexString(messageDigest.digest(basicCredentials.getPassword().getBytes()))); //todo
})
.findFirst();
return
userOptional
;
return userOptional;
*/
}
// public void get(UUID uuid) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment