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
2e7589af
Commit
2e7589af
authored
Nov 11, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
c51c80c1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
45 deletions
+44
-45
CTFApplication.java
.../java/com/telephoners/krakyournet/ctf/CTFApplication.java
+19
-0
Team.java
...main/java/com/telephoners/krakyournet/ctf/beans/Team.java
+8
-26
User.java
...main/java/com/telephoners/krakyournet/ctf/beans/User.java
+13
-14
ApplicationModule.java
...elephoners/krakyournet/ctf/modules/ApplicationModule.java
+2
-1
Repository.java
.../telephoners/krakyournet/ctf/repositories/Repository.java
+2
-4
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/CTFApplication.java
View file @
2e7589af
...
...
@@ -5,6 +5,9 @@ import com.google.common.collect.ImmutableSet;
import
com.google.common.reflect.ClassPath
;
import
com.google.inject.Guice
;
import
com.google.inject.Injector
;
import
com.google.inject.Key
;
import
com.google.inject.TypeLiteral
;
import
com.telephoners.krakyournet.ctf.beans.Team
;
import
com.telephoners.krakyournet.ctf.beans.User
;
import
com.telephoners.krakyournet.ctf.commands.PurgeDatabaseCommand
;
import
com.telephoners.krakyournet.ctf.commands.RegisterTasksCommand
;
...
...
@@ -12,6 +15,7 @@ import com.telephoners.krakyournet.ctf.commands.RegisterTeamsCommand;
import
com.telephoners.krakyournet.ctf.core.ApplicationConfiguration
;
import
com.telephoners.krakyournet.ctf.logging.LoggingFilter
;
import
com.telephoners.krakyournet.ctf.modules.ApplicationModule
;
import
com.telephoners.krakyournet.ctf.repositories.Repository
;
import
io.dropwizard.Application
;
import
io.dropwizard.assets.AssetsBundle
;
import
io.dropwizard.auth.AuthValueFactoryProvider
;
...
...
@@ -22,6 +26,7 @@ import org.ektorp.CouchDbConnector;
import
org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.stream.Stream
;
public
class
CTFApplication
extends
Application
<
ApplicationConfiguration
>
...
...
@@ -70,6 +75,20 @@ public class CTFApplication extends Application<ApplicationConfiguration>
CouchDbConnector
connector
=
injector
.
getInstance
(
CouchDbConnector
.
class
);
Team
team
=
new
Team
();
team
.
setName
(
"asdf"
);
team
.
setDescription
(
"sadf"
);
User
user
=
new
User
(
"asdf"
,
"asdf"
,
"asdffg"
,
false
);
Repository
<
Team
>
teamRepository
=
injector
.
getInstance
(
Key
.
get
(
new
TypeLiteral
<
Repository
<
Team
>>(){}));
Repository
<
User
>
userRepository
=
injector
.
getInstance
(
Key
.
get
(
new
TypeLiteral
<
Repository
<
User
>>(){}));
teamRepository
.
add
(
team
);
List
<
Team
>
all1
=
teamRepository
.
getAll
();
userRepository
.
add
(
user
);
List
<
User
>
all
=
userRepository
.
getAll
();
registerAdmins
(
applicationConfiguration
);
registerResources
(
environment
);
registerAuthFeatures
(
environment
);
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/beans/Team.java
View file @
2e7589af
package
com
.
telephoners
.
krakyournet
.
ctf
.
beans
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
org.ektorp.support.CouchDbDocument
;
import
java.util.List
;
public
class
Team
extends
CouchDbDocument
{
private
String
name
;
private
String
description
;
private
List
<
User
>
members
;
@JsonCreator
public
Team
(
@JsonProperty
(
"name"
)
String
name
,
@JsonProperty
(
"description"
)
String
description
,
@JsonProperty
(
"members"
)
List
<
User
>
members
)
{
this
.
name
=
name
;
this
.
description
=
description
;
this
.
members
=
members
;
}
public
Team
()
{
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
List
<
User
>
getMembers
()
{
return
members
;
}
}
service/src/main/java/com/telephoners/krakyournet/ctf/beans/User.java
View file @
2e7589af
package
com
.
telephoners
.
krakyournet
.
ctf
.
beans
;
import
org.ektorp.docref.DocumentReferences
;
import
org.ektorp.support.CouchDbDocument
;
import
java.security.Principal
;
...
...
@@ -14,16 +13,16 @@ public class User extends CouchDbDocument implements Principal
private
String
email
;
private
boolean
admin
=
false
;
@DocumentReferences
//todo: make sure it works
private
Team
team
;
//
@DocumentReferences //todo: make sure it works
//
private Team team;
public
User
(
String
name
,
String
password
,
String
email
,
boolean
admin
,
Team
team
)
public
User
(
String
name
,
String
password
,
String
email
,
boolean
admin
/*Team team*/
)
{
this
.
name
=
name
;
this
.
password
=
password
;
this
.
email
=
email
;
this
.
admin
=
admin
;
this
.
team
=
team
;
//
this.team = team;
}
@Override
...
...
@@ -67,13 +66,13 @@ public class User extends CouchDbDocument implements Principal
this
.
admin
=
admin
;
}
public
Team
getTeam
()
{
return
team
;
}
public
void
setTeam
(
Team
team
)
{
this
.
team
=
team
;
}
//
public Team getTeam()
//
{
//
return team;
//
}
//
//
public void setTeam(Team team)
//
{
//
this.team = team;
//
}
}
service/src/main/java/com/telephoners/krakyournet/ctf/modules/ApplicationModule.java
View file @
2e7589af
...
...
@@ -3,6 +3,7 @@ package com.telephoners.krakyournet.ctf.modules;
import
com.google.inject.AbstractModule
;
import
com.google.inject.Provides
;
import
com.google.inject.TypeLiteral
;
import
com.telephoners.krakyournet.ctf.beans.Team
;
import
com.telephoners.krakyournet.ctf.beans.User
;
import
com.telephoners.krakyournet.ctf.core.ApplicationConfiguration
;
import
org.ektorp.CouchDbConnector
;
...
...
@@ -28,9 +29,9 @@ public class ApplicationModule extends AbstractModule
protected
void
configure
()
{
bind
(
ApplicationConfiguration
.
class
).
toInstance
(
applicationConfiguration
);
//todo: temporary
bind
(
new
TypeLiteral
<
Class
<
User
>>(){}).
toInstance
(
User
.
class
);
bind
(
new
TypeLiteral
<
Class
<
Team
>>(){}).
toInstance
(
Team
.
class
);
}
@Provides
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/Repository.java
View file @
2e7589af
...
...
@@ -5,13 +5,11 @@ import org.ektorp.CouchDbConnector;
import
org.ektorp.support.CouchDbDocument
;
import
org.ektorp.support.CouchDbRepositorySupport
;
import
javax.inject.Singleton
;
@Singleton
//@Singleton
public
class
Repository
<
T
extends
CouchDbDocument
>
extends
CouchDbRepositorySupport
<
T
>
{
@Inject
p
rotected
Repository
(
final
Class
<
T
>
type
,
final
CouchDbConnector
connector
)
p
ublic
Repository
(
final
Class
<
T
>
type
,
final
CouchDbConnector
connector
)
{
super
(
type
,
connector
);
}
...
...
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