Class ExternalXsltResourceLoader

java.lang.Object
net.finmath.smartcontracts.representablestate.postprocessing.ExternalXsltResourceLoader

public final class ExternalXsltResourceLoader extends Object
Loads a top-level XSLT resource from a policy-controlled HTTP(S) URL or from an on-chain ITextResource. It also exposes narrow Web3-only methods for retrieving an ITextResource directly.

The supported web3:// form is deliberately narrower than the full ERC-4804/6860 URL grammar:

 web3://0x<40-hex-address>:<explicit-chain-id>/content
 

The loader calls content()(bytes) at the numeric snapshotBlock supplied by the caller. It does not support name services, cross-chain calls, userinfo/from addresses, manual resolve mode, arbitrary methods, arguments, queries, or fragments.

HTTP access is denied unless the normalized host is explicitly listed in ExternalXsltResourceLoader.Options. Automatic redirects are disabled and each redirect target is checked against the same policy. Private and special-purpose addresses are denied by default. Network-level egress controls are still recommended to close DNS-rebinding and proxy-related gaps that cannot be eliminated by an application-level URL check alone.

  • Constructor Details

    • ExternalXsltResourceLoader

      public ExternalXsltResourceLoader(org.web3j.protocol.Web3j web3j, ExternalXsltResourceLoader.Options options)
      Creates a loader using the supplied application Web3j connection.
      Parameters:
      web3j - Web3j connection used for same-chain, block-pinned web3:// calls.
      options - Immutable HTTP and resource-limit policy.
  • Method Details

    • load

      public byte[] load(URI uri, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException
      Loads a stylesheet at a fixed EVM snapshot block.

      A numeric block is required for every scheme so callers cannot accidentally render state at one block and resolve a web3:// stylesheet at a moving latest block.

      Parameters:
      uri - Absolute external resource URI.
      snapshotBlock - Non-negative numeric snapshot block.
      Returns:
      Raw stylesheet bytes, never larger than the configured limit.
      Throws:
      ExternalXsltResourceLoader.ExternalXsltResourceException - If the URI is invalid or disallowed, the upstream cannot be read, or the resource is too large.
    • loadTextResource

      public byte[] loadTextResource(URI web3Url, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException
      Loads an on-chain text resource from its canonical Web3 URL at a fixed EVM snapshot block.

      Only the canonical same-chain form web3://<address>:<chain-id>/content is accepted. The returned bytes are the exact value of ITextResource.content().

      Parameters:
      web3Url - Canonical Web3 URL of the text resource.
      snapshotBlock - Non-negative numeric snapshot block.
      Returns:
      Exact resource bytes, never larger than the configured limit.
      Throws:
      ExternalXsltResourceLoader.ExternalXsltResourceException - If the URL is malformed or disallowed, the RPC call fails, or the resource is too large.
    • loadTextResource

      public byte[] loadTextResource(String contractAddress, BigInteger snapshotBlock) throws ExternalXsltResourceLoader.ExternalXsltResourceException
      Loads an ITextResource by contract address at a fixed EVM snapshot block. The configured RPC chain is used implicitly.
      Parameters:
      contractAddress - Address of the ITextResource contract.
      snapshotBlock - Non-negative numeric snapshot block.
      Returns:
      Exact resource bytes, never larger than the configured limit.
      Throws:
      ExternalXsltResourceLoader.ExternalXsltResourceException - If the address is malformed, the RPC call fails, or the resource is too large.