Class CalendarAddressGuard

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

public class CalendarAddressGuard extends Object
Decides which calendar links the platform may be made to read (EXO-90278): the platform's SafeAddressGuard, with what is a calendar's own — webcal:// and webcals:// read as https://, and each refusal reported as the CalendarFeedException reason the user is shown.

The rules themselves — http or https, no credentials, a port in the allowed set, and every internal address range refused unless the deployment allows internal addresses — are the shared guard's, applied once more by the HTTP client's own resolver when a connection opens, so that the address checked is the address dialled.

  • Constructor Summary

    Constructors
    Constructor
    Description
    CalendarAddressGuard(io.meeds.commons.http.SafeAddressGuard delegate)
    The guard over a shared guard: the fetcher's, so that the rules applied before a read are the ones its connections apply.
  • Method Summary

    Modifier and Type
    Method
    Description
    Reads a URL as the user typed it: trimmed, webcal:// and webcals:// read as https://, then normalized and checked by the platform's guard.
    normalize(String url, Predicate<URI> readInProcess)
    Reads a URL as the user typed it, as normalize(String) does, but keeps a URL whose only fault is an internal address literal when it is read in the process, never over the network: a link of this eXo, whose public domain may well be an internal address.
    static String
    reason(io.meeds.commons.http.SafeFetchFailure failure)
    The reason a calendar link cannot be read, from why the platform's fetcher read nothing: the message code the user is shown.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CalendarAddressGuard

      public CalendarAddressGuard(io.meeds.commons.http.SafeAddressGuard delegate)
      The guard over a shared guard: the fetcher's, so that the rules applied before a read are the ones its connections apply.
      Parameters:
      delegate - the platform's guard
  • Method Details

    • normalize

      public URI normalize(String url) throws CalendarFeedException
      Reads a URL as the user typed it: trimmed, webcal:// and webcals:// read as https://, then normalized and checked by the platform's guard. Nothing is resolved here. The form for a URL that is only ever read over the network; the subscription service, which reads links of this eXo in the process, uses normalize(String, Predicate).
      Parameters:
      url - the URL as typed
      Returns:
      the URL to read
      Throws:
      CalendarFeedException - with the reason it is refused
    • normalize

      public URI normalize(String url, Predicate<URI> readInProcess) throws CalendarFeedException
      Reads a URL as the user typed it, as normalize(String) does, but keeps a URL whose only fault is an internal address literal when it is read in the process, never over the network: a link of this eXo, whose public domain may well be an internal address. Every other rule still applies, since the platform's guard judges the literal last.
      Parameters:
      url - the URL as typed
      readInProcess - whether a URL is read without any connection
      Returns:
      the URL to read
      Throws:
      CalendarFeedException - with the reason it is refused
    • reason

      public static String reason(io.meeds.commons.http.SafeFetchFailure failure)
      The reason a calendar link cannot be read, from why the platform's fetcher read nothing: the message code the user is shown.
      Parameters:
      failure - why nothing was read
      Returns:
      the CalendarFeedException reason