/** * Method getInstance * * @param uri * @param baseURI * @param individualResolvers * @param secureValidation * @return the instance * @throws ResourceResolverException */ public static ResourceResolver getInstance( Attr uri, String baseURI, List<ResourceResolver> individualResolvers, boolean secureValidation) throws ResourceResolverException { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log( java.util.logging.Level.FINE, "I was asked to create a ResourceResolver and got " + (individualResolvers == null ? 0 : individualResolvers.size())); } // first check the individual Resolvers if (individualResolvers != null) { for (int i = 0; i < individualResolvers.size(); i++) { ResourceResolver resolver = individualResolvers.get(i); if (resolver != null) { if (log.isLoggable(java.util.logging.Level.FINE)) { String currentClass = resolver.resolverSpi.getClass().getName(); log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass); } resolver.resolverSpi.secureValidation = secureValidation; if (resolver.canResolve(uri, baseURI)) { return resolver; } } } } return getInstance(uri, baseURI, secureValidation); }
/** * Method getInstance * * @param uri * @param baseURI * @param secureValidation * @return the instance * @throws ResourceResolverException */ public static final ResourceResolver getInstance( Attr uri, String baseURI, boolean secureValidation) throws ResourceResolverException { synchronized (resolverList) { for (ResourceResolver resolver : resolverList) { ResourceResolver resolverTmp = resolver; if (!resolver.resolverSpi.engineIsThreadSafe()) { try { resolverTmp = new ResourceResolver(resolver.resolverSpi.getClass().newInstance()); } catch (InstantiationException e) { throw new ResourceResolverException("", e, uri, baseURI); } catch (IllegalAccessException e) { throw new ResourceResolverException("", e, uri, baseURI); } } if (log.isLoggable(java.util.logging.Level.FINE)) { log.log( java.util.logging.Level.FINE, "check resolvability by class " + resolverTmp.getClass().getName()); } resolverTmp.resolverSpi.secureValidation = secureValidation; if ((resolverTmp != null) && resolverTmp.canResolve(uri, baseURI)) { // Check to see whether the Resolver is allowed if (secureValidation && (resolverTmp.resolverSpi instanceof ResolverLocalFilesystem || resolverTmp.resolverSpi instanceof ResolverDirectHTTP)) { Object exArgs[] = {resolverTmp.resolverSpi.getClass().getName()}; throw new ResourceResolverException( "signature.Reference.ForbiddenResolver", exArgs, uri, baseURI); } return resolverTmp; } } } Object exArgs[] = {((uri != null) ? uri.getNodeValue() : "null"), baseURI}; throw new ResourceResolverException("utils.resolver.noClass", exArgs, uri, baseURI); }