Class BlueMindSudoCredentialsProvider

java.lang.Object
org.exoplatform.bluemind.credentials.plugin.BlueMindSudoCredentialsProvider
All Implemented Interfaces:
org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider

public class BlueMindSudoCredentialsProvider extends Object implements org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
Authenticates through a BlueMind technical account acting on each user's behalf: the "bluemind-sudo" credentials provider.

The sequence is two calls, not one: the technical account opens its own session, then asks BlueMind for a session in the name of the target user — a "sudo". What comes back is that user's session id, which the connector then presents as a password on IMAP, SMTP or CalDAV. Nothing of the user's own is ever needed.

Confirmed end to end against a live 5.7 instance, and these four facts are what produce(ConnectorCredentialsContext) is built on:

  • the session id is accepted as a password on all three channels: a PROPFIND on the CalDAV root answered 207, an IMAP LOGIN answered a OK [...] User logged in. and an SMTP AUTH PLAIN answered 235 2.0.0 OK. It opens a REST session too: POST /api/auth/login with the session id as the password answers Ok — a session id mints another;
  • the Basic login must be the target user, not the technical account: the same session id presented under the technical login was refused with a 401. The identity that authenticates and the identity being served are one and the same, which is why resolveTargetIdentity(ConnectorCredentialsContext) feeds both;
  • the target's name is not required in the URL: the server root answered with the target's current-user-principal;
  • the technical session survives every sudo, and two users' session ids coexist — so one technical session plus one id per user is a sound cache shape (EXO-89647).

The contract is the name and the configuration fields. Connector rows store "bluemind-sudo" as their provider name, and the platform's configuration storage keys every stored value by the provider name and the field key, and decides from the field type whether it went through the codec. The name, the four keys, their types and the choice's options are therefore those this provider has always declared: changing one orphans every configuration already saved, with nothing raised anywhere.

It yields to another provider of the same name. commons-exo still ships its own copy of this provider for as long as its removal has not landed, and the registry refuses a second provider under one name with an IllegalStateException that would escape this web application's startup and stop the portal container. So register() looks first: when the name is already held by another provider, this one stays unregistered, says so once in a WARN, and the holder serves every connector.

Not a @Service: the registry is how every host reaches it, so it is built by BlueMindCredentialsConfiguration as a factory-method bean, which the Kernel/Spring bridge never exports to another web application.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The message code the administration screen shows when the API address carries a path other than /api: a key of this add-on's credentialsProviderConfig bundle.
    static final String
    The name connectors store to select this provider.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlueMindSudoCredentialsProvider(org.exoplatform.services.connector.credentials.ConnectorCredentialsService connectorCredentialsService, org.exoplatform.services.connector.credentials.ConnectorProviderConfigStorage configStorage, org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.bluemind.client.BlueMindSessionStorage sessionStorage)
    The provider, over the platform's registry and configuration storage.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.exoplatform.services.connector.credentials.ConnectorCredentialsConfigField>
    What an administrator must give for this provider to work on one connector, in the order the form shows them: the REST API address (the connector's own URLs address IMAP, SMTP or CalDAV, never the API the sudo is asked for), the technical login, its password — the one value typed SECRET, so it goes through the platform codec and never comes back to a screen — and which eXo field names the user on BlueMind.
    Set<org.exoplatform.services.connector.credentials.ConnectorCredentialsChannel>
    All three: the sudo session is accepted by IMAP, SMTP and CalDAV alike.
    void
    invalidate(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context)
    Drops the target session kept for this user, so the next production opens a new one — what a caller does once when BlueMind refuses material that was produced from the store (EXO-89649).
    org.exoplatform.services.connector.credentials.ConnectorCredentials
    produce(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context)
    The target's session, in the shape the asking channel consumes: two calls to BlueMind on a miss — the technical login, then the sudo — and none on a hit.
    void
    Registers this provider under "bluemind-sudo", unless another provider already holds that name, in which case this one stays unregistered and a WARN says which one serves.
    boolean
    False, where the Personal provider answers true — the single difference the whole default-connector feature rests on (EXO-89651 to EXO-89656): a population can be connected without anyone being asked to type a password.
    resolveTargetIdentity(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context)
    The BlueMind login of the user this connector is working for.
    void
    Refuses an API address whose path is neither empty nor /api.

    Methods inherited from class java.lang.Object

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

    • NAME

      public static final String NAME
      The name connectors store to select this provider.
      See Also:
    • API_URL_WITH_PATH

      public static final String API_URL_WITH_PATH
      The message code the administration screen shows when the API address carries a path other than /api: a key of this add-on's credentialsProviderConfig bundle.
      See Also:
  • Constructor Details

    • BlueMindSudoCredentialsProvider

      public BlueMindSudoCredentialsProvider(org.exoplatform.services.connector.credentials.ConnectorCredentialsService connectorCredentialsService, org.exoplatform.services.connector.credentials.ConnectorProviderConfigStorage configStorage, org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.bluemind.client.BlueMindSessionStorage sessionStorage)
      The provider, over the platform's registry and configuration storage.
      Parameters:
      connectorCredentialsService - the platform's registry of providers
      configStorage - where each connector's configuration is stored
      organizationService - the directory
      sessionStorage - the BlueMind sessions this provider spends
  • Method Details

    • register

      @PostConstruct public void register()
      Registers this provider under "bluemind-sudo", unless another provider already holds that name, in which case this one stays unregistered and a WARN says which one serves. Never throws for a held name: a duplicate registration refused by the registry is answered the same way, so the web application's startup cannot fail on it.
    • getName

      public String getName()
      Specified by:
      getName in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Returns:
      "bluemind-sudo"
    • getSupportedChannels

      public Set<org.exoplatform.services.connector.credentials.ConnectorCredentialsChannel> getSupportedChannels()
      All three: the sudo session is accepted by IMAP, SMTP and CalDAV alike.
      Specified by:
      getSupportedChannels in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Returns:
      every channel
    • requiresUserAction

      public boolean requiresUserAction()
      False, where the Personal provider answers true — the single difference the whole default-connector feature rests on (EXO-89651 to EXO-89656): a population can be connected without anyone being asked to type a password.
      Specified by:
      requiresUserAction in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Returns:
      false
    • getConfigurationFields

      public List<org.exoplatform.services.connector.credentials.ConnectorCredentialsConfigField> getConfigurationFields()
      What an administrator must give for this provider to work on one connector, in the order the form shows them: the REST API address (the connector's own URLs address IMAP, SMTP or CalDAV, never the API the sudo is asked for), the technical login, its password — the one value typed SECRET, so it goes through the platform codec and never comes back to a screen — and which eXo field names the user on BlueMind.

      The help text on the login is load-bearing: an account that may not sudo logs in, its token is accepted everywhere else in the API, and every sudo answers HTTP 200 with a "Bad" status and no message.

      Specified by:
      getConfigurationFields in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Returns:
      the four fields, every one required
    • validateConfiguration

      public void validateConfiguration(Map<String,String> values) throws org.exoplatform.services.connector.credentials.ConnectorCredentialsException
      Refuses an API address whose path is neither empty nor /api.

      The sudo keeps only the address's scheme, host and port, and sends the technical account's password to <root>/api/auth/login: an address with any other path would have that password go to whatever answers at the host's root. The rule is the mail endpoint's (BlueMindRestClient.isServerOrApiPath(String)). An address that is no URL at all is not this rule's to judge.

      Specified by:
      validateConfiguration in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Parameters:
      values - what was posted, keyed by field
      Throws:
      org.exoplatform.services.connector.credentials.ConnectorCredentialsException - carrying "credentialsProviderConfig.bluemind-sudo.apiUrlWithPath"
    • resolveTargetIdentity

      public String resolveTargetIdentity(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context)
      The BlueMind login of the user this connector is working for.

      The single derivation of the whole provider. produce(ConnectorCredentialsContext) calls this very method to know what to sudo to: a second, parallel derivation would let the sudo and the URL the connector addresses drift apart, and that is not an authentication error — it is a valid session pointed at someone else's mailbox, with nothing raised anywhere.

      Reads the configuration without its secrets: naming a user needs the target field, never the password. Answers null for every case where the user cannot be named — no configuration, no username, a directory that does not know them, a profile with no address, a directory that is down.

      Specified by:
      resolveTargetIdentity in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Parameters:
      context - the connector and user the material would be produced for
      Returns:
      the login to sudo to, or null when the user cannot be named
    • produce

      public org.exoplatform.services.connector.credentials.ConnectorCredentials produce(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context) throws org.exoplatform.services.connector.credentials.ConnectorCredentialsException
      The target's session, in the shape the asking channel consumes: two calls to BlueMind on a miss — the technical login, then the sudo — and none on a hit. The technical secret is read for the load; the sessions are filed under its keyed digest, never under the secret itself.
      Specified by:
      produce in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Parameters:
      context - the connector, the user and the channel
      Returns:
      the material, declaring when its kept session leaves the store
      Throws:
      org.exoplatform.services.connector.credentials.ConnectorTargetRefusedException - when BlueMind refuses the sudo because of the target account
      BlueMindSudoRefusedException - when BlueMind refuses the technical login, or the sudo for any other reason
      org.exoplatform.services.connector.credentials.ConnectorCredentialsException - when the user cannot be named, the configuration cannot be read, its API address carries a path other than /api, or BlueMind cannot be reached
    • invalidate

      public void invalidate(org.exoplatform.services.connector.credentials.ConnectorCredentialsContext context)
      Drops the target session kept for this user, so the next production opens a new one — what a caller does once when BlueMind refuses material that was produced from the store (EXO-89649). Never throws: an invalidation that cannot derive its key has nothing to drop, and the entry expires anyway.
      Specified by:
      invalidate in interface org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
      Parameters:
      context - the connector and user whose session is dropped