Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
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
Administrator
browser-backend
Commits
4e6f31b8
Commit
4e6f31b8
authored
Mar 05, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
browser-backend
parent
434151c9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
133 additions
and
137 deletions
+133
-137
BrowserBackendApplication.java
...a/com/edgec/browserbackend/BrowserBackendApplication.java
+2
-0
AccountController.java
.../browserbackend/account/controller/AccountController.java
+1
-7
User.java
...in/java/com/edgec/browserbackend/account/domain/User.java
+0
-20
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+1
-1
OAuth2AuthorizationConfig.java
...browserbackend/auth/config/OAuth2AuthorizationConfig.java
+1
-26
WebSecurityConfig.java
...m/edgec/browserbackend/auth/config/WebSecurityConfig.java
+1
-1
UserController.java
.../edgec/browserbackend/auth/controller/UserController.java
+1
-8
ElasticsearchClient.java
...serbackend/common/commons/client/ElasticsearchClient.java
+74
-74
application.yml
src/main/resources/application.yml
+52
-0
No files found.
src/main/java/com/edgec/browserbackend/BrowserBackendApplication.java
View file @
4e6f31b8
...
@@ -2,8 +2,10 @@ package com.edgec.browserbackend;
...
@@ -2,8 +2,10 @@ package com.edgec.browserbackend;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer
;
@SpringBootApplication
@SpringBootApplication
@EnableAuthorizationServer
public
class
BrowserBackendApplication
{
public
class
BrowserBackendApplication
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
4e6f31b8
...
@@ -30,6 +30,7 @@ import java.util.Enumeration;
...
@@ -30,6 +30,7 @@ import java.util.Enumeration;
import
java.util.List
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"account"
)
public
class
AccountController
{
public
class
AccountController
{
public
static
final
String
WECHAT_PAY_CALLBACK_URL
=
"https://cloudam.cn/accounts/0xwxpaycallback/"
;
public
static
final
String
WECHAT_PAY_CALLBACK_URL
=
"https://cloudam.cn/accounts/0xwxpaycallback/"
;
...
@@ -47,44 +48,37 @@ public class AccountController {
...
@@ -47,44 +48,37 @@ public class AccountController {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountController
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountController
.
class
);
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/precharge/{name}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/precharge/{name}"
,
method
=
RequestMethod
.
POST
)
public
IpChargeResultDto
preCharge
(
@PathVariable
String
name
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
public
IpChargeResultDto
preCharge
(
@PathVariable
String
name
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
return
accountService
.
preCharge
(
name
,
requestDto
);
return
accountService
.
preCharge
(
name
,
requestDto
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/prechargeIp/{name}/{amount}/{money}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/prechargeIp/{name}/{amount}/{money}"
,
method
=
RequestMethod
.
PUT
)
public
IpChargeResultDto
preChargeIp
(
@PathVariable
String
name
,
@PathVariable
int
amount
,
@PathVariable
double
money
)
{
public
IpChargeResultDto
preChargeIp
(
@PathVariable
String
name
,
@PathVariable
int
amount
,
@PathVariable
double
money
)
{
return
accountService
.
preChargeIp
(
name
,
amount
,
money
);
return
accountService
.
preChargeIp
(
name
,
amount
,
money
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/precharge/money"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/precharge/money"
,
method
=
RequestMethod
.
POST
)
public
IpChargeResultDto
preChargeByMoney
(
@RequestParam
(
"accountId"
)
String
name
,
@RequestParam
(
"money"
)
double
money
)
{
public
IpChargeResultDto
preChargeByMoney
(
@RequestParam
(
"accountId"
)
String
name
,
@RequestParam
(
"money"
)
double
money
)
{
return
accountService
.
preChargeByMoney
(
name
,
money
);
return
accountService
.
preChargeByMoney
(
name
,
money
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/charge/{name}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/charge/{name}"
,
method
=
RequestMethod
.
PUT
)
public
IpChargeResultDto
charge
(
@PathVariable
String
name
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
public
IpChargeResultDto
charge
(
@PathVariable
String
name
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
return
accountService
.
charge
(
name
,
requestDto
);
return
accountService
.
charge
(
name
,
requestDto
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/charge/money"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/charge/money"
,
method
=
RequestMethod
.
PUT
)
public
IpChargeResultDto
chargeByMoney
(
@RequestParam
(
"accountId"
)
String
name
,
@RequestParam
(
"money"
)
double
money
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
public
IpChargeResultDto
chargeByMoney
(
@RequestParam
(
"accountId"
)
String
name
,
@RequestParam
(
"money"
)
double
money
,
@RequestBody
IpChargeRequestDto
requestDto
)
{
return
accountService
.
chargeByMoney
(
name
,
money
,
requestDto
);
return
accountService
.
chargeByMoney
(
name
,
money
,
requestDto
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/{name}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/{name}"
,
method
=
RequestMethod
.
GET
)
public
Account
getAccountByName
(
@PathVariable
String
name
)
{
public
Account
getAccountByName
(
@PathVariable
String
name
)
{
return
accountService
.
findByName
(
name
);
return
accountService
.
findByName
(
name
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/{name}/children/{level}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/{name}/children/{level}"
,
method
=
RequestMethod
.
GET
)
public
List
<
UserDto
>
getDesendentUsers
(
@PathVariable
String
name
,
@PathVariable
int
level
)
{
public
List
<
UserDto
>
getDesendentUsers
(
@PathVariable
String
name
,
@PathVariable
int
level
)
{
return
accountService
.
getAllDesendentUsers
(
name
,
level
);
return
accountService
.
getAllDesendentUsers
(
name
,
level
);
...
...
src/main/java/com/edgec/browserbackend/account/domain/User.java
View file @
4e6f31b8
...
@@ -22,28 +22,8 @@ public class User {
...
@@ -22,28 +22,8 @@ public class User {
private
boolean
enabled
=
false
;
private
boolean
enabled
=
false
;
private
String
agencyID
;
private
String
lockReason
;
private
String
lockReason
;
private
boolean
isVpsUser
=
false
;
public
boolean
isVpsUser
()
{
return
isVpsUser
;
}
public
void
setVpsUser
(
boolean
vpsUser
)
{
isVpsUser
=
vpsUser
;
}
public
String
getAgencyID
()
{
return
agencyID
;
}
public
void
setAgencyID
(
String
agencyID
)
{
this
.
agencyID
=
agencyID
;
}
public
String
getOtp
()
{
public
String
getOtp
()
{
return
otp
;
return
otp
;
}
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
4e6f31b8
...
@@ -527,7 +527,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -527,7 +527,7 @@ public class AccountServiceImpl implements AccountService {
@Override
@Override
public
Account
createWithSms
(
User
user
)
{
public
Account
createWithSms
(
User
user
)
{
boolean
isVps
=
user
.
isVpsUser
()
;
boolean
isVps
=
true
;
Account
existing
=
repository
.
findByName
(
user
.
getUsername
());
Account
existing
=
repository
.
findByName
(
user
.
getUsername
());
if
(
existing
!=
null
)
if
(
existing
!=
null
)
...
...
src/main/java/com/edgec/browserbackend/auth/config/OAuth2AuthorizationConfig.java
View file @
4e6f31b8
...
@@ -47,32 +47,7 @@ public class OAuth2AuthorizationConfig extends AuthorizationServerConfigurerAdap
...
@@ -47,32 +47,7 @@ public class OAuth2AuthorizationConfig extends AuthorizationServerConfigurerAdap
.
authorizedGrantTypes
(
"refresh_token"
,
"password"
)
.
authorizedGrantTypes
(
"refresh_token"
,
"password"
)
.
scopes
(
"ui"
)
.
scopes
(
"ui"
)
.
and
()
.
and
()
.
withClient
(
"account-service"
)
.
withClient
(
"cloudam-browser"
)
.
secret
(
env
.
getProperty
(
"ACCOUNT_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
)
.
and
()
.
withClient
(
"intelligroup-service"
)
.
secret
(
env
.
getProperty
(
"INTELLIGROUP_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
)
.
and
()
.
withClient
(
"intelligroup-vps"
)
.
secret
(
env
.
getProperty
(
"INTELLIGROUP_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
)
.
and
()
.
withClient
(
"c3-app"
)
.
secret
(
env
.
getProperty
(
"ACCOUNT_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
)
.
and
()
.
withClient
(
"c3-ecc-app"
)
.
secret
(
env
.
getProperty
(
"ACCOUNT_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
)
.
and
()
.
withClient
(
"c3-ip-app"
)
.
secret
(
env
.
getProperty
(
"ACCOUNT_SERVICE_PASSWORD"
))
.
secret
(
env
.
getProperty
(
"ACCOUNT_SERVICE_PASSWORD"
))
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
authorizedGrantTypes
(
"client_credentials"
,
"refresh_token"
)
.
scopes
(
"server"
);
.
scopes
(
"server"
);
...
...
src/main/java/com/edgec/browserbackend/auth/config/WebSecurityConfig.java
View file @
4e6f31b8
...
@@ -30,7 +30,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -30,7 +30,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
()
web
.
ignoring
()
.
antMatchers
(
"/users/verify/**"
,
"/users/changepass"
);
.
antMatchers
(
"/users/verify/**"
,
"/users/changepass"
,
"/"
);
}
}
@Override
@Override
...
...
src/main/java/com/edgec/browserbackend/auth/controller/UserController.java
View file @
4e6f31b8
...
@@ -6,6 +6,7 @@ import com.edgec.browserbackend.auth.service.UserAuthService;
...
@@ -6,6 +6,7 @@ import com.edgec.browserbackend.auth.service.UserAuthService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.core.token.TokenService
;
import
org.springframework.security.oauth2.provider.token.ConsumerTokenServices
;
import
org.springframework.security.oauth2.provider.token.ConsumerTokenServices
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -21,7 +22,6 @@ public class UserController {
...
@@ -21,7 +22,6 @@ public class UserController {
private
UserAuthService
userAuthService
;
private
UserAuthService
userAuthService
;
@Autowired
@Autowired
@Qualifier
(
"consumerTokenServices"
)
ConsumerTokenServices
consumerTokenServices
;
ConsumerTokenServices
consumerTokenServices
;
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
"/token"
)
@RequestMapping
(
method
=
RequestMethod
.
DELETE
,
value
=
"/token"
)
...
@@ -39,43 +39,36 @@ public class UserController {
...
@@ -39,43 +39,36 @@ public class UserController {
return
principal
;
return
principal
;
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/{name}/roles/{roles}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/{name}/roles/{roles}"
,
method
=
RequestMethod
.
PUT
)
public
void
updateRoles
(
@PathVariable
String
name
,
@PathVariable
String
roles
)
{
public
void
updateRoles
(
@PathVariable
String
name
,
@PathVariable
String
roles
)
{
userAuthService
.
updateRoles
(
name
,
roles
);
userAuthService
.
updateRoles
(
name
,
roles
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/{name}/addroles/{roles}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/{name}/addroles/{roles}"
,
method
=
RequestMethod
.
PUT
)
public
void
addRoles
(
@PathVariable
String
name
,
@PathVariable
String
roles
)
{
public
void
addRoles
(
@PathVariable
String
name
,
@PathVariable
String
roles
)
{
userAuthService
.
addRoles
(
name
,
roles
);
userAuthService
.
addRoles
(
name
,
roles
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
void
createUser
(
@Valid
@RequestBody
User
user
)
{
public
void
createUser
(
@Valid
@RequestBody
User
user
)
{
userAuthService
.
create
(
user
);
userAuthService
.
create
(
user
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
value
=
"/resetpasswd"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/resetpasswd"
,
method
=
RequestMethod
.
POST
)
public
void
resetUserPassword
(
@Valid
@RequestBody
User
user
)
{
public
void
resetUserPassword
(
@Valid
@RequestBody
User
user
)
{
userAuthService
.
resetUserPassword
(
user
);
userAuthService
.
resetUserPassword
(
user
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/current/{name}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
path
=
"/current/{name}"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteUser
(
@PathVariable
String
name
)
{
public
void
deleteUser
(
@PathVariable
String
name
)
{
userAuthService
.
deleteUser
(
name
);
userAuthService
.
deleteUser
(
name
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
method
=
RequestMethod
.
PUT
)
public
void
resetUser
(
@Valid
@RequestBody
User
user
)
{
public
void
resetUser
(
@Valid
@RequestBody
User
user
)
{
userAuthService
.
reset
(
user
);
userAuthService
.
reset
(
user
);
}
}
@PreAuthorize
(
"#oauth2.hasScope('server')"
)
@RequestMapping
(
path
=
"/{lockOrUnlock}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
path
=
"/{lockOrUnlock}"
,
method
=
RequestMethod
.
PUT
)
public
void
lockOrUnlockUser
(
@Valid
@RequestBody
User
user
,
@PathVariable
String
lockOrUnlock
)
{
//@RequestParam("by") String by,
public
void
lockOrUnlockUser
(
@Valid
@RequestBody
User
user
,
@PathVariable
String
lockOrUnlock
)
{
//@RequestParam("by") String by,
if
(
"lock"
.
equals
(
lockOrUnlock
)){
if
(
"lock"
.
equals
(
lockOrUnlock
)){
...
...
src/main/java/com/edgec/browserbackend/common/commons/client/ElasticsearchClient.java
View file @
4e6f31b8
package
com
.
edgec
.
browserbackend
.
common
.
commons
.
client
;
//
package com.edgec.browserbackend.common.commons.client;
//
//
import
org.apache.commons.lang3.StringUtils
;
//
import org.apache.commons.lang3.StringUtils;
import
org.apache.http.HttpHost
;
//
import org.apache.http.HttpHost;
import
org.apache.http.client.CredentialsProvider
;
//
import org.apache.http.client.CredentialsProvider;
import
org.elasticsearch.action.DocWriteResponse
;
//
import org.elasticsearch.action.DocWriteResponse;
import
org.elasticsearch.action.index.IndexRequest
;
//
import org.elasticsearch.action.index.IndexRequest;
import
org.elasticsearch.action.index.IndexResponse
;
//
import org.elasticsearch.action.index.IndexResponse;
import
org.elasticsearch.client.RequestOptions
;
//
import org.elasticsearch.client.RequestOptions;
import
org.elasticsearch.client.RestClient
;
//
import org.elasticsearch.client.RestClient;
import
org.elasticsearch.client.RestHighLevelClient
;
//
import org.elasticsearch.client.RestHighLevelClient;
import
org.elasticsearch.common.xcontent.XContentType
;
//
import org.elasticsearch.common.xcontent.XContentType;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
//
import
java.io.IOException
;
//
import java.io.IOException;
//
/**
/
//
**
* Elasticsearch Rest Client
//
* Elasticsearch Rest Client
* Make sure to config this client before use it
//
* Make sure to config this client before use it
* See example : intelligroup-tasks#com.edgec.intelligroup.config.ElasticsearchClientConfig
//
* See example : intelligroup-tasks#com.edgec.intelligroup.config.ElasticsearchClientConfig
*/
//
*/
public
class
ElasticsearchClient
{
//
public class ElasticsearchClient {
//
private
String
hostname
;
//
private String hostname;
private
int
port
;
//
private int port;
private
CredentialsProvider
credentialsProvider
;
//
private CredentialsProvider credentialsProvider;
//
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ElasticsearchClient
.
class
);
//
private static final Logger log = LoggerFactory.getLogger(ElasticsearchClient.class);
//
//
public
void
index
(
String
name
,
String
id
,
String
sourceJson
)
{
//
public void index(String name, String id, String sourceJson) {
if
(
StringUtils
.
isEmpty
(
name
)
||
StringUtils
.
isEmpty
(
id
)
||
StringUtils
.
isEmpty
(
sourceJson
))
{
//
if (StringUtils.isEmpty(name) || StringUtils.isEmpty(id) || StringUtils.isEmpty(sourceJson)) {
throw
new
IllegalArgumentException
(
"Missing params"
);
//
throw new IllegalArgumentException("Missing params");
}
//
}
RestHighLevelClient
client
=
buildRestClient
();
//
RestHighLevelClient client = buildRestClient();
try
{
//
try {
IndexRequest
indexRequest
=
new
IndexRequest
(
name
).
id
(
id
).
source
(
sourceJson
,
XContentType
.
JSON
);
//
IndexRequest indexRequest = new IndexRequest(name).id(id).source(sourceJson, XContentType.JSON);
//
IndexResponse
indexResponse
=
client
.
index
(
indexRequest
,
RequestOptions
.
DEFAULT
);
//
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
if
(
indexResponse
!=
null
&&
indexResponse
.
getResult
()
!=
null
)
{
//
if (indexResponse != null && indexResponse.getResult() != null) {
if
(
indexResponse
.
getResult
()
==
DocWriteResponse
.
Result
.
CREATED
)
{
//
if (indexResponse.getResult() == DocWriteResponse.Result.CREATED) {
log
.
info
(
"Index created "
+
indexResponse
.
getId
());
//
log.info("Index created " + indexResponse.getId());
}
else
if
(
indexResponse
.
getResult
()
==
DocWriteResponse
.
Result
.
UPDATED
)
{
//
} else if (indexResponse.getResult() == DocWriteResponse.Result.UPDATED) {
log
.
info
(
"Index updated "
+
indexResponse
.
getId
());
//
log.info("Index updated " + indexResponse.getId());
}
//
}
}
//
}
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
log
.
error
(
"Index request errors "
,
e
);
//
log.error("Index request errors ", e);
}
finally
{
//
} finally {
try
{
//
try {
client
.
close
();
//
client.close();
}
catch
(
IOException
e
)
{
//
} catch (IOException e) {
log
.
error
(
"Closing client errors "
,
e
);
//
log.error("Closing client errors ", e);
}
//
}
}
//
}
}
//
}
//
private
RestHighLevelClient
buildRestClient
()
{
//
private RestHighLevelClient buildRestClient() {
RestHighLevelClient
client
=
new
RestHighLevelClient
(
//
RestHighLevelClient client = new RestHighLevelClient(
RestClient
.
builder
(
new
HttpHost
(
hostname
,
port
,
"http"
))
//
RestClient.builder(new HttpHost(hostname, port, "http"))
.
setHttpClientConfigCallback
(
httpClientBuilder
->
httpClientBuilder
).
setHttpClientConfigCallback
(
httpAsyncClientBuilder
->
httpAsyncClientBuilder
.
setDefaultCredentialsProvider
(
credentialsProvider
)));
//
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder).setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider)));
return
client
;
//
return client;
}
//
}
//
//
public
ElasticsearchClient
(
String
hostname
,
int
port
,
CredentialsProvider
credentialsProvider
)
{
//
public ElasticsearchClient(String hostname, int port, CredentialsProvider credentialsProvider) {
log
.
info
(
"Initialize ElasticsearchClient host {} port {}"
,
hostname
,
port
);
//
log.info("Initialize ElasticsearchClient host {} port {}", hostname, port);
this
.
hostname
=
hostname
;
//
this.hostname = hostname;
this
.
port
=
port
;
//
this.port = port;
this
.
credentialsProvider
=
credentialsProvider
;
//
this.credentialsProvider = credentialsProvider;
}
//
}
}
//
}
src/main/resources/application.yml
View file @
4e6f31b8
spring
:
messages
:
basename
:
i18n/messages
encoding
:
UTF-8
data
:
mongodb
:
uri
:
mongodb://user:${MONGODB_PASSWORD}@cloudam-browser:27017/browser
mail
:
host
:
smtp.qiye.aliyun.com
port
:
465
username
:
info@cloudam.io
password
:
Edgec2018
properties
:
mail
:
smtp
:
auth
:
true
port
:
465
socketFactory
:
port
:
465
class
:
javax.net.ssl.SSLSocketFactory
ssl
:
enable
:
true
security
:
oauth2
:
resource
:
user-info-uri
:
http://localhost:6000/browser/users/current
server
:
servlet
:
context-path
:
/browser
port
:
6000
---
spring
:
profiles
:
dev
data
:
mongodb
:
uri
:
mongodb://user:${MONGODB_PASSWORD}@cloudam-browser:27017/browser
---
spring
:
profiles
:
prod
data
:
mongodb
:
uri
:
mongodb://user:${MONGODB_PASSWORD}@cloudam-browser:27017/browser
---
spring
:
profiles
:
staging
data
:
mongodb
:
uri
:
mongodb://user:${MONGODB_PASSWORD}@cloudam-browser:27017/browser
\ No newline at end of file
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