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
24890a47
Commit
24890a47
authored
Mar 22, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use reflections to iterate over registered resources
parent
e3772e66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
CTFApplication.java
.../java/com/telephoners/krakyournet/ctf/CTFApplication.java
+9
-10
SolutionsRepository.java
...ers/krakyournet/ctf/repositories/SolutionsRepository.java
+0
-2
No files found.
service/src/main/java/com/telephoners/krakyournet/ctf/CTFApplication.java
View file @
24890a47
package
com
.
telephoners
.
krakyournet
.
ctf
;
import
com.bazaarvoice.dropwizard.webjars.WebJarBundle
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.reflect.ClassPath
;
import
com.google.inject.Guice
;
import
com.google.inject.Injector
;
import
com.telephoners.krakyournet.ctf.auth.ExampleAuthenticator
;
import
com.telephoners.krakyournet.ctf.beans.User
;
import
com.telephoners.krakyournet.ctf.commands.PurgeDatabaseCommand
;
import
com.telephoners.krakyournet.ctf.commands.RegisterTasksCommand
;
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.beans.User
;
import
com.telephoners.krakyournet.ctf.repositories.UsersRepository
;
import
com.telephoners.krakyournet.ctf.resources.*
;
import
io.dropwizard.Application
;
import
io.dropwizard.assets.AssetsBundle
;
import
io.dropwizard.auth.AuthDynamicFeature
;
...
...
@@ -24,6 +25,7 @@ import io.dropwizard.setup.Bootstrap;
import
io.dropwizard.setup.Environment
;
import
org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
;
import
java.io.IOException
;
import
java.util.stream.Stream
;
public
class
CTFApplication
extends
Application
<
ApplicationConfiguration
>
...
...
@@ -42,16 +44,13 @@ public class CTFApplication extends Application<ApplicationConfiguration>
.
forEach
(
bootstrap:
:
addBundle
);
}
private
void
registerResources
(
Environment
environment
)
private
void
registerResources
(
Environment
environment
)
throws
IOException
{
//todo: use reflections to iterate over resources
JerseyEnvironment
jersey
=
environment
.
jersey
();
jersey
.
register
(
injector
.
getInstance
(
TeamsResource
.
class
));
jersey
.
register
(
injector
.
getInstance
(
TasksResource
.
class
));
jersey
.
register
(
injector
.
getInstance
(
ProxyResource
.
class
));
jersey
.
register
(
injector
.
getInstance
(
SolutionsResource
.
class
));
jersey
.
register
(
injector
.
getInstance
(
TaskResource
.
class
));
jersey
.
register
(
injector
.
getInstance
(
UtilResource
.
class
));
final
ClassPath
classPath
=
ClassPath
.
from
(
this
.
getClass
().
getClassLoader
());
ImmutableSet
<
ClassPath
.
ClassInfo
>
resourceClasses
=
classPath
.
getTopLevelClasses
(
"com.telephoners.krakyournet.ctf.resources"
);
resourceClasses
.
stream
()
.
forEach
(
classInfo
->
jersey
.
register
(
injector
.
getInstance
(
classInfo
.
load
())));
}
private
void
registerAuthFeatures
(
Environment
environment
)
...
...
service/src/main/java/com/telephoners/krakyournet/ctf/repositories/SolutionsRepository.java
View file @
24890a47
...
...
@@ -9,9 +9,7 @@ import javax.inject.Inject;
import
javax.inject.Singleton
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
@Singleton
...
...
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