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
37e4655a
Commit
37e4655a
authored
Feb 22, 2016
by
Grzegorz Pietrusza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy pass user header
parent
8b9ef287
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
ProxyResource.java
service/src/main/java/api/ProxyResource.java
+19
-2
No files found.
service/src/main/java/api/ProxyResource.java
View file @
37e4655a
package
api
;
import
io.dropwizard.auth.Auth
;
import
objects.User
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
...
...
@@ -19,8 +21,8 @@ import java.io.InputStream;
*/
@Path
(
value
=
"/proxy/task"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
class
ProxyResource
{
public
class
ProxyResource
{
/*
@GET
@Path("{task_id}/{path: .*}")
@Produces("text/html; charset=UTF-8")
...
...
@@ -32,4 +34,19 @@ public class ProxyResource
HttpEntity entity = execute.getEntity();
return entity.getContent();
}
*/
@GET
@Path
(
"{task_id}/{path: .*}"
)
@Produces
(
"text/html; charset=UTF-8"
)
public
InputStream
task1
(
@Auth
User
user
,
final
@PathParam
(
"task_id"
)
String
taskId
,
final
@PathParam
(
"path"
)
String
path
)
throws
IOException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpGet
httpget
=
new
HttpGet
(
"http://192.168.56.101/"
);
// HttpGet httpget = new HttpGet("http://http://192.168.56.101/" + taskId + "/" + path);
httpget
.
setHeader
(
"CTF-User"
,
user
.
getName
());
CloseableHttpResponse
execute
=
httpClient
.
execute
(
httpget
);
HttpEntity
entity
=
execute
.
getEntity
();
return
entity
.
getContent
();
}
}
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