Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
verteilte-systeme-bsc-ai-examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
verteilte-systeme-bsc-ai-examples
Commits
2085e765
Commit
2085e765
authored
7 years ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
initial ssl version of rest server
parent
f8c5e507
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
VerteilteSysteme-Examples/build/keystore_server
+0
-0
0 additions, 0 deletions
VerteilteSysteme-Examples/build/keystore_server
VerteilteSysteme-Examples/src/verteiltesysteme/rest/RESTSSLServer.java
+47
-0
47 additions, 0 deletions
...eme-Examples/src/verteiltesysteme/rest/RESTSSLServer.java
with
47 additions
and
0 deletions
VerteilteSysteme-Examples/build/keystore_server
0 → 100644
+
0
−
0
View file @
2085e765
File added
This diff is collapsed.
Click to expand it.
VerteilteSysteme-Examples/src/verteiltesysteme/rest/RESTSSLServer.java
0 → 100644
+
47
−
0
View file @
2085e765
/* Beispiel angelehnt an http://www.torsten-horn.de/techdocs/jee-rest.htm */
package
verteiltesysteme.rest
;
import
java.io.IOException
;
import
java.net.URI
;
import
org.glassfish.grizzly.http.server.HttpServer
;
import
org.glassfish.grizzly.ssl.SSLContextConfigurator
;
import
org.glassfish.grizzly.ssl.SSLEngineConfigurator
;
import
org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory
;
import
org.glassfish.jersey.server.ResourceConfig
;
public
class
RESTSSLServer
{
private
static
final
String
KEYSTORE_SERVER_FILE
=
"./build/keystore_server"
;
private
static
final
String
KEYSTORE_SERVER_PWD
=
"notsecure"
;
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
String
baseUrl
=
(
args
.
length
>
0
)
?
args
[
0
]
:
"http://localhost:36040"
;
// Grizzly ssl configuration
SSLContextConfigurator
sslContext
=
new
SSLContextConfigurator
();
// set up security context
sslContext
.
setKeyStoreFile
(
KEYSTORE_SERVER_FILE
);
// contains server keypair
sslContext
.
setKeyStorePass
(
KEYSTORE_SERVER_PWD
);
// keytool -genkey -keystore ./keystore_server -alias serverKey -dname "CN=localhost, OU=VertSys, O=HS-Fulda, L=Fulda, ST=Hessen, C=DE"
final
HttpServer
server
=
GrizzlyHttpServerFactory
.
createHttpServer
(
URI
.
create
(
baseUrl
),
new
ResourceConfig
(
RESTToUpperCaseService
.
class
,
RESTToLowerCaseService
.
class
),
true
,
new
SSLEngineConfigurator
(
sslContext
).
setClientMode
(
false
).
setNeedClientAuth
(
false
)
);
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
server
.
shutdownNow
();
}
}
)
);
server
.
start
();
System
.
out
.
println
(
"Grizzly-HTTP-Server gestartet"
);
System
.
out
.
println
(
"Stoppen des Grizzly-HTTP-Servers mit: Strg+C\n"
);
System
.
out
.
println
(
"RESTful Web Service URL: "
+
baseUrl
+
RESTToUpperCaseService
.
webContextPath
);
System
.
out
.
println
(
"RESTful Web Service URL: "
+
baseUrl
+
RESTToLowerCaseService
.
webContextPath
);
Thread
.
currentThread
().
join
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment