Java Code Examples for org.apache.solr.common.SolrException.ErrorCode#UNAUTHORIZED
The following examples show how to use
org.apache.solr.common.SolrException.ErrorCode#UNAUTHORIZED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityProcessorWrapper.java From lucene-solr with Apache License 2.0 | 6 votes |
private void checkIfTrusted(String trans) { if (docBuilder != null) { SolrCore core = docBuilder.dataImporter.getCore(); boolean trusted = (core != null)? core.getCoreDescriptor().isConfigSetTrusted(): true; if (!trusted) { Exception ex = new SolrException(ErrorCode.UNAUTHORIZED, "The configset for this collection was uploaded " + "without any authentication in place," + " and this transformer is not available for collections with untrusted configsets. To use this transformer," + " re-upload the configset after enabling authentication and authorization."); String msg = "Transformer: " + trans + ". " + ex.getMessage(); log.error(msg); wrapAndThrow(SEVERE, ex, msg); } } }
Example 2
Source File: StatelessScriptUpdateProcessorFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void inform(SolrCore core) { if (!core.getCoreDescriptor().isConfigSetTrusted()) { throw new SolrException(ErrorCode.UNAUTHORIZED, "The configset for this collection was uploaded without any authentication in place," + " and this operation is not available for collections with untrusted configsets. To use this component, re-upload the configset" + " after enabling authentication and authorization."); } resourceLoader = core.getResourceLoader(); // test that our engines & scripts are valid SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams()); try { initEngines(req, rsp); } catch (Exception e) { String msg = "Unable to initialize scripts: " + e.getMessage(); log.error(msg, e); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e); } finally { req.close(); } }
Example 3
Source File: PackageUtils.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Fetches a manifest file from the File Store / Package Store. A SHA512 check is enforced after fetching. */ public static Manifest fetchManifest(HttpSolrClient solrClient, String solrBaseUrl, String manifestFilePath, String expectedSHA512) throws MalformedURLException, IOException { String manifestJson = PackageUtils.getJsonStringFromUrl(solrClient.getHttpClient(), solrBaseUrl + "/api/node/files" + manifestFilePath); String calculatedSHA512 = BlobRepository.sha512Digest(ByteBuffer.wrap(manifestJson.getBytes("UTF-8"))); if (expectedSHA512.equals(calculatedSHA512) == false) { throw new SolrException(ErrorCode.UNAUTHORIZED, "The manifest SHA512 doesn't match expected SHA512. Possible unauthorized manipulation. " + "Expected: " + expectedSHA512 + ", calculated: " + calculatedSHA512 + ", manifest location: " + manifestFilePath); } Manifest manifest = getMapper().readValue(manifestJson, Manifest.class); return manifest; }