Class AgendaCalendarLinkServiceImpl

java.lang.Object
org.exoplatform.agenda.service.AgendaCalendarLinkServiceImpl
All Implemented Interfaces:
org.exoplatform.agenda.service.AgendaCalendarLinkService

@Service public class AgendaCalendarLinkServiceImpl extends Object implements org.exoplatform.agenda.service.AgendaCalendarLinkService
Holds every rule of calendar links: who manages one, what its token is, and when it stops answering.

Managing (read the status, create or reset, delete) is Utils.canPublishCalendar(org.exoplatform.social.core.manager.IdentityManager, org.exoplatform.social.core.space.spi.SpaceService, long, long): the owner of a personal calendar, a real manager of the space for a space calendar.

Answering is decided again on every fetch, because the URL is presented with no session: a link answers only while its creator still holds the right that let them create it — a space calendar's creator is still a manager of the space, a personal calendar's creator is still its owner — and the creator's account is neither disabled nor deleted. The same predicate sets CalendarLink.isActive() for the drawer, so the drawer and the feed cannot disagree about a link.

Tokens: 32 bytes of SecureRandom, base64url without padding, stored twice and never in clear. The SHA-256 digest is what a feed request is found and compared by — no salt and no stretching are needed for a 256-bit random secret, there is no dictionary to search. A copy encrypted with the platform codec (CodecInitializer, the key every stored secret of the instance is encrypted with) lets the link be shown again to whoever may manage it; if that key is ever replaced, the copy no longer decrypts, the link can no longer be displayed, and it keeps answering through its digest until someone resets it. Neither the token, nor its digest, nor its copy is ever logged.

  • Field Details

    • PAST_DAYS

      public static final int PAST_DAYS
      Days of past events the feed publishes.
      See Also:
    • FUTURE_DAYS

      public static final int FUTURE_DAYS
      Days of future events the feed publishes.
      See Also:
    • MAX_EVENTS

      public static final int MAX_EVENTS
      Most events one document carries, occurrences counted. A safety stop for a calendar with a dense recurring event, not a page: the earliest are kept. The writer adds a budget on the characters written.
      See Also:
    • MAX_MANAGED_SPACES

      public static final int MAX_MANAGED_SPACES
      Most managed spaces one listing looks at. Kept under a thousand with the user's own identity: the owners go into one IN list, and Oracle refuses more than a thousand items there.
      See Also:
  • Constructor Details

    • AgendaCalendarLinkServiceImpl

      @Autowired public AgendaCalendarLinkServiceImpl(CalendarLinkStorage calendarLinkStorage, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, org.exoplatform.agenda.service.AgendaEventService agendaEventService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.web.security.codec.CodecInitializer codecInitializer)
      Builds the service.
      Parameters:
      calendarLinkStorage - storage of calendar links
      agendaCalendarService - reads calendars
      agendaEventService - reads the events a feed publishes, re-applying the calendar ACL for the link's creator
      identityManager - resolves users and space identities
      spaceService - resolves space management rights
      codecInitializer - the platform codec the displayable copy of a token is encrypted with
  • Method Details

    • getCalendarLink

      public org.exoplatform.agenda.model.CalendarLink getCalendarLink(long calendarId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      getCalendarLink in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getCalendarLinks

      public List<org.exoplatform.agenda.model.CalendarLink> getCalendarLinks(String username) throws IllegalAccessException

      One query reads the links: the candidate calendars are those the user's own identity owns and those the spaces they manage own, and the links are joined to them in the database. Each link found is then checked again with the same rule every other method applies — so a space they stopped managing since the list of managed spaces was read is left out — and read the same way getCalendarLink(long, java.lang.String) reads it. Space identities and calendars are read through the platform's cached services.

      Specified by:
      getCalendarLinks in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      IllegalAccessException
    • saveCalendarLink

      public String saveCalendarLink(long calendarId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      saveCalendarLink in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deleteCalendarLink

      public void deleteCalendarLink(long calendarId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      deleteCalendarLink in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deleteCalendarLinks

      public void deleteCalendarLinks(long calendarId)
      Specified by:
      deleteCalendarLinks in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
    • getCalendarFeed

      public String getCalendarFeed(String token) throws org.exoplatform.commons.exception.ObjectNotFoundException

      Every refusal throws the same exception with the same message, and a malformed token is still digested and looked up before it is refused, so that the answer to an unknown token does not come back faster than the answer to a real one. A link whose creator lost their right costs the permission checks on top of that lookup before it is refused: only someone already holding a once-valid token can observe that difference.

      Specified by:
      getCalendarFeed in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • getFeedCalendarId

      public long getFeedCalendarId(String token) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Specified by:
      getFeedCalendarId in interface org.exoplatform.agenda.service.AgendaCalendarLinkService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException