1. solr-webapp中的web.xml
2. solr-jetty-context.xml
注意此处realm.properties的位置是相对于jetty.home
3. realm.properties
username: password,role
注意password需要配置成MD5
例如:username=admin, password=12345
admin: MD5:827ccb0eea8a706c4c34a16891f84e7b, admin
生成上述MD5: java -cp jetty-util-9.2.13.v20150730.jar org.eclipse.jetty.util.security.Password admin 12345
修改或者添加密码后需要重启服务
4. Solrj访问时进行相关权限设置。参见Solr5部分
http://stackoverflow.com/questions/2014700/preemptive-basic-authentication-with-apache-httpclient-4/11868040#11868040
5. 自动更新进行权限设置,参考http://www.cnblogs.com/donganwangshi/p/4276015.html
在sendHttpPost(StringcoreName,Stringparams)中添加
String headerKey = "Authorization";
String encoding = username+":"+password;
String headerValue = "Basic " + new BASE64Encoder().encode(encoding.getBytes());
conn.setRequestProperty(headerKey, headerValue);
其中username和password是从配置文件dataimport.properties中读取的