Class CalendarFeedFetcher

java.lang.Object
org.exoplatform.agenda.util.CalendarFeedFetcher

@Component public class CalendarFeedFetcher extends Object
Reads a calendar link over HTTP (EXO-90278), within bounds, through the platform's SafeHttpFetcher.

Addresses are the shared guard's: it is the resolver of the HTTP client's connection manager, so the address of every connection is judged when the connection is opened, redirects followed one hop at a time with each target checked again. Bounds: a connect timeout, a read timeout, a deadline over the whole read — redirects included — a body limit counted on the decoded bytes, and a redirect count. Nothing of the platform's goes out: no cookie store, no credentials, no proxy, no retry; the only headers sent are the ones a conditional read needs. Nothing of the URL goes into a log: it may embed a secret.

  • Field Details

    • DEFAULT_MAX_BYTES

      public static final long DEFAULT_MAX_BYTES
      Largest body read, in bytes.
      See Also:
    • DEFAULT_CONNECT

      public static final Duration DEFAULT_CONNECT
      Longest wait for a connection.
    • DEFAULT_READ

      public static final Duration DEFAULT_READ
      Longest wait between two reads.
    • DEFAULT_TOTAL

      public static final Duration DEFAULT_TOTAL
      Longest read of a link, redirects included.
    • DEFAULT_MAX_REDIRECTS

      public static final int DEFAULT_MAX_REDIRECTS
      Most redirects followed.
      See Also:
    • DEFAULT_PORTS

      public static final String DEFAULT_PORTS
      The ports a link may reach unless the deployment says otherwise.
      See Also:
  • Constructor Details

    • CalendarFeedFetcher

      @Autowired public CalendarFeedFetcher(@Value("${exo.agenda.calendarSubscription.allowInternalAddresses:false}") boolean allowInternalAddresses, @Value("${exo.agenda.calendarSubscription.allowedPorts:80,443,8080,8443}") String allowedPorts)
      The fetcher of a deployment.
      Parameters:
      allowInternalAddresses - whether internal addresses may be read, false by default: the deployment's opt-out, as caldav-integration's exo.agenda.caldav.server.allowPrivateAddresses
      allowedPorts - comma-separated ports a link may reach
  • Method Details

    • getGuard

      public CalendarAddressGuard getGuard()
      Returns:
      the address guard, whose URL rules the service applies before a read
    • fetch

      public CalendarFeedFetcher.FeedResponse fetch(URI uri, String etag, String lastModified) throws CalendarFeedException
      Reads a link, conditionally when validators are given; a stored validator carrying a control character (a tab included), which an earlier version kept, is not sent, and the read is then unconditional.
      Parameters:
      uri - the URL, already normalized by the guard
      etag - the entity tag of the previous read, or null
      lastModified - the Last-Modified header of the previous read, or null
      Returns:
      what the server answered
      Throws:
      CalendarFeedException - with the reason nothing usable was read
    • close

      @PreDestroy public void close()
      Closes the connections.