/** * 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); }
/** * Registers a ResourceResolverSpi instance. This method logs a warning if the class cannot be * registered. * * @param resourceResolverSpi * @param start * @throws SecurityException if a security manager is installed and the caller does not have * permission to register a resource resolver */ public static void register(ResourceResolverSpi resourceResolverSpi, boolean start) { JavaUtils.checkRegisterPermission(); synchronized (resolverList) { if (start) { resolverList.add(0, new ResourceResolver(resourceResolverSpi)); } else { resolverList.add(new ResourceResolver(resourceResolverSpi)); } } if (log.isLoggable(java.util.logging.Level.FINE)) { log.log( java.util.logging.Level.FINE, "Registered resolver: " + resourceResolverSpi.toString()); } }
/** * 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); }
/** * Method canResolve * * @param uri * @param baseURI * @return true if it can resolve the uri */ private boolean canResolve(Attr uri, String baseURI) { return resolverSpi.engineCanResolve(uri, baseURI); }
/** * Method understandsProperty * * @param propertyToTest * @return true if the resolver understands the property */ public boolean understandsProperty(String propertyToTest) { return resolverSpi.understandsProperty(propertyToTest); }
/** * Method getPropertyKeys * * @return all property keys. */ public String[] getPropertyKeys() { return resolverSpi.engineGetPropertyKeys(); }
/** * Method addProperties * * @param properties */ public void addProperties(Map<String, String> properties) { resolverSpi.engineAddProperies(properties); }
/** * Method getProperty * * @param key * @return the value of the property */ public String getProperty(String key) { return resolverSpi.engineGetProperty(key); }
/** * Method setProperty * * @param key * @param value */ public void setProperty(String key, String value) { resolverSpi.engineSetProperty(key, value); }
/** * Method resolve * * @param uri * @param baseURI * @return the resource * @throws ResourceResolverException */ public XMLSignatureInput resolve(Attr uri, String baseURI) throws ResourceResolverException { return resolverSpi.engineResolve(uri, baseURI); }