Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
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
openSource
apollo
Commits
429792a4
Commit
429792a4
authored
Apr 19, 2016
by
Yiming Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support auth in RestTemplateFactory
parent
fd08a717
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
67 additions
and
14 deletions
+67
-14
AppController.java
...m/ctrip/apollo/adminservice/controller/AppController.java
+1
-1
ClusterController.java
...rip/apollo/adminservice/controller/ClusterController.java
+1
-1
ItemController.java
.../ctrip/apollo/adminservice/controller/ItemController.java
+1
-1
ItemSetController.java
...rip/apollo/adminservice/controller/ItemSetController.java
+1
-1
NamespaceController.java
...p/apollo/adminservice/controller/NamespaceController.java
+1
-1
ReleaseController.java
...rip/apollo/adminservice/controller/ReleaseController.java
+1
-1
pom.xml
apollo-common/pom.xml
+4
-0
ActiveUser.java
...rc/main/java/com/ctrip/apollo/common/auth/ActiveUser.java
+1
-1
RestTemplateFactory.java
...ava/com/ctrip/apollo/common/auth/RestTemplateFactory.java
+41
-0
API.java
...portal/src/main/java/com/ctrip/apollo/portal/api/API.java
+3
-1
SamplePortalApplication.java
...c/test/java/com/ctrip/apollo/SamplePortalApplication.java
+11
-0
application.yml
apollo-portal/src/test/resources/application.yml
+1
-6
No files found.
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppController.java
View file @
429792a4
...
...
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.ctrip.apollo.biz.entity.App
;
import
com.ctrip.apollo.biz.service.AdminService
;
import
com.ctrip.apollo.biz.service.AppService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.common.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.AppDTO
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
...
...
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ClusterController.java
View file @
429792a4
...
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.service.ClusterService
;
import
com.ctrip.apollo.biz.service.ViewService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.common.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.ClusterDTO
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
...
...
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ItemController.java
View file @
429792a4
...
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.ctrip.apollo.biz.entity.Item
;
import
com.ctrip.apollo.biz.service.ItemService
;
import
com.ctrip.apollo.biz.service.ViewService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.common.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
...
...
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ItemSetController.java
View file @
429792a4
...
...
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.apollo.biz.service.ItemSetService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
@RestController
...
...
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/NamespaceController.java
View file @
429792a4
...
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.ctrip.apollo.biz.entity.Namespace
;
import
com.ctrip.apollo.biz.service.NamespaceService
;
import
com.ctrip.apollo.biz.service.ViewService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.common.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
...
...
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ReleaseController.java
View file @
429792a4
...
...
@@ -14,7 +14,7 @@ import com.ctrip.apollo.biz.entity.Release;
import
com.ctrip.apollo.biz.service.ConfigService
;
import
com.ctrip.apollo.biz.service.ReleaseService
;
import
com.ctrip.apollo.biz.service.ViewService
;
import
com.ctrip.apollo.common.
controller
.ActiveUser
;
import
com.ctrip.apollo.common.
auth
.ActiveUser
;
import
com.ctrip.apollo.common.utils.BeanUtils
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.ctrip.apollo.core.exception.NotFoundException
;
...
...
apollo-common/pom.xml
View file @
429792a4
...
...
@@ -39,6 +39,10 @@
<artifactId>
spring-data-commons
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
</dependency>
...
...
apollo-common/src/main/java/com/ctrip/apollo/common/
controller
/ActiveUser.java
→
apollo-common/src/main/java/com/ctrip/apollo/common/
auth
/ActiveUser.java
View file @
429792a4
package
com
.
ctrip
.
apollo
.
common
.
controller
;
package
com
.
ctrip
.
apollo
.
common
.
auth
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
...
...
apollo-common/src/main/java/com/ctrip/apollo/common/auth/RestTemplateFactory.java
0 → 100644
View file @
429792a4
package
com
.
ctrip
.
apollo
.
common
.
auth
;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.UsernamePasswordCredentials
;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
@Component
public
class
RestTemplateFactory
implements
FactoryBean
<
RestTemplate
>,
InitializingBean
{
private
RestTemplate
restTemplate
;
public
RestTemplate
getObject
()
{
return
restTemplate
;
}
public
Class
<
RestTemplate
>
getObjectType
()
{
return
RestTemplate
.
class
;
}
public
boolean
isSingleton
()
{
return
true
;
}
public
void
afterPropertiesSet
()
{
BasicCredentialsProvider
credentialsProvider
=
new
BasicCredentialsProvider
();
credentialsProvider
.
setCredentials
(
AuthScope
.
ANY
,
new
UsernamePasswordCredentials
(
"apollo"
,
""
));
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
setDefaultCredentialsProvider
(
credentialsProvider
).
build
();
restTemplate
=
new
RestTemplate
(
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
}
}
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/API.java
View file @
429792a4
...
...
@@ -12,7 +12,8 @@ public class API {
@Autowired
protected
ServiceLocator
serviceLocator
;
protected
RestTemplate
restTemplate
=
new
RestTemplate
();
@Autowired
protected
RestTemplate
restTemplate
;
public
String
getAdminServiceHost
(
Env
env
)
{
// 本地测试用
...
...
@@ -24,4 +25,5 @@ public class API {
}
return
""
;
}
}
apollo-portal/src/test/java/com/ctrip/apollo/SamplePortalApplication.java
0 → 100644
View file @
429792a4
package
com
.
ctrip
.
apollo
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
@SpringBootApplication
public
class
SamplePortalApplication
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
SamplePortalApplication
.
class
).
run
(
args
);
}
}
apollo-portal/src/test/resources/application.yml
View file @
429792a4
...
...
@@ -4,11 +4,6 @@ server:
spring
:
application
:
name
:
apollo-portal
datasource
:
url
:
jdbc:h2:mem:~/fxapolloportaldb
jpa
:
hibernate
:
naming_strategy
:
org.hibernate.cfg.EJB3NamingStrategy
logging
:
level
:
...
...
@@ -20,4 +15,4 @@ ctrip:
apollo
:
portal
:
env
:
dev
env
:
local
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