Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
portal-backend
Commits
fc65187f
Commit
fc65187f
authored
9 years ago
by
Ludovic Claude
Browse files
Options
Downloads
Patches
Plain Diff
Do not use https anymore to connect to workflow
parent
6fb8725a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/hbp/mip/controllers/MiningApi.java
+2
-29
2 additions, 29 deletions
src/main/java/org/hbp/mip/controllers/MiningApi.java
with
2 additions
and
29 deletions
src/main/java/org/hbp/mip/controllers/MiningApi.java
+
2
−
29
View file @
fc65187f
...
...
@@ -10,13 +10,10 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.net.ssl.HttpsURLConnection
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
import
java.io.BufferedReader
;
import
java.io.DataOutputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
@RestController
...
...
@@ -44,9 +41,7 @@ public class MiningApi {
private
static
int
sendPost
(
String
url
,
String
query
,
StringBuilder
resp
)
throws
Exception
{
URL
obj
=
new
URL
(
url
);
HttpsURLConnection
con
=
(
HttpsURLConnection
)
obj
.
openConnection
();
// TODO: Remove this line for security
allowInsecureConnection
(
con
);
HttpURLConnection
con
=
(
HttpURLConnection
)
obj
.
openConnection
();
con
.
setRequestMethod
(
"POST"
);
con
.
addRequestProperty
(
"Content-Type"
,
"application/json"
);
...
...
@@ -80,26 +75,4 @@ public class MiningApi {
return
respCode
;
}
private
static
void
allowInsecureConnection
(
HttpsURLConnection
con
)
{
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
new
X509TrustManager
()
{
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
public
void
checkClientTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
}
public
void
checkServerTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
}
}
};
try
{
SSLContext
sc
=
SSLContext
.
getInstance
(
"SSL"
);
sc
.
init
(
null
,
trustAllCerts
,
new
java
.
security
.
SecureRandom
());
con
.
setSSLSocketFactory
(
sc
.
getSocketFactory
());
}
catch
(
Exception
ignored
)
{
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
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