Hi David,
Here is my files:
elasticsearch.yml:
cluster.name: elasticsearch
node.name: "Franz Kafka1"
node.master: true
node.data: true
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["localhost"]
http.jsonp.enable: true
script.disable_dynamic: false
script.inline: on
script.indexed: on
http.cors.enabled: true
http.cors.allow-origin: http://localhost:5601
In shield folder:
logging.yml:
logger:
shield.audit.logfile: INFO, access_log
additivity:
shield.audit.logfile: false
appender:
access_log:
type: dailyRollingFile
file: {path.logs}/{cluster.name}-access.log
datePattern: "'.'yyyy-MM-dd"
layout:
type: pattern
conversionPattern: "[%d{ISO8601}] %m%n"
role_mapping.yml:
roles.yml:
# All cluster rights
# All operations on all indices
admin:
cluster: all
indices:
'*': all
# monitoring cluster privileges
# All operations on all indices
power_user:
cluster: monitor
indices:
'*': all
# Read-only operations on indices
user:
indices:
'*': read
# Defines the required permissions for transport clients
transport_client:
cluster:
- cluster:monitor/nodes/info
#uncomment the following for sniffing
#- cluster:monitor/state
# The required role for kibana 3 users
kibana3:
cluster: cluster:monitor/nodes/info
indices:
'*': indices:data/read/search, indices:data/read/get, indices:admin/get
'kibana-int': indices:data/read/search, indices:data/read/get, indices:data/write/delete, indices:data/write/index, create_index
# The required permissions for kibana 4 users.
kibana4:
cluster:
- cluster:monitor/nodes/info
- cluster:monitor/health
indices:
'*':
- indices:admin/mappings/fields/get
- indices:admin/validate/query
- indices:data/read/search
- indices:data/read/msearch
- indices:admin/get
'.kibana':
- indices:admin/exists
- indices:admin/mapping/put
- indices:admin/mappings/fields/get
- indices:admin/refresh
- indices:admin/validate/query
- indices:data/read/get
- indices:data/read/mget
- indices:data/read/search
- indices:data/write/delete
- indices:data/write/index
- indices:data/write/update
- indices:admin/create
# The required permissions for the kibana 4 server
kibana4_server:
cluster:
- cluster:monitor/nodes/info
- cluster:monitor/health
indices:
'.kibana':
- indices:admin/exists
- indices:admin/mapping/put
- indices:admin/mappings/fields/get
- indices:admin/refresh
- indices:admin/validate/query
- indices:data/read/get
- indices:data/read/mget
- indices:data/read/search
- indices:data/write/delete
- indices:data/write/index
- indices:data/write/update
# The required role for logstash users
logstash:
cluster: indices:admin/template/get, indices:admin/template/put
indices:
'logstash-*': indices:data/write/bulk, indices:data/write/delete, indices:data/write/update, indices:data/read/search, indices:data/read/scroll, create_index
# Marvel role, allowing all operations
# on the marvel indices
marvel_user:
cluster: cluster:monitor/nodes/info, cluster:admin/plugin/license/get
indices:
'.marvel-*': all
# Marvel Agent users
marvel_agent:
cluster: indices:admin/template/get, indices:admin/template/put
indices:
'.marvel-*': indices:data/write/bulk, create_index
users.yml:
es_admin:$2a$10$RbWXUQSEmsR1JbhmP4xCFudyMc1SvT.KXjz3rvc2ZzxJ2XW8v9sgW
user_roles.yml:
admin:es_admin
Here is my Java Client Code:
public class Test{
public static final Client client = getTransportClient("localhost", 9300);
public static String token = null;
public static Client getTransportClient(String host, int port) {
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").put("shield.user", "es_admin:anusha").build();
token = basicAuthHeaderValue("es_admin", new SecuredString("anusha".toCharArray()));
return new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(host, port));
}
public static void getResponse(String index, String indextype) throws InvalidFormatException, Exception {
SearchHits hits = null;
SearchHit hit = null;
SearchResponse response = client.prepareSearch(index).setTypes(indextype).putHeader("Authorization", token).get();
hits = response.getHits();
Iterator<SearchHit> hitsIte = hits.iterator();
while (hitsIte.hasNext()) {
hit = hitsIte.next();
// jsonArray.add(hit.getSource());
System.out.println(hit.getSourceAsString());
}
}
}