Class BlueMindSudoCredentialsProvider
- All Implemented Interfaces:
org.exoplatform.services.connector.credentials.ConnectorCredentialsProvider
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
PROPFINDon the CalDAV root answered 207, an IMAPLOGINanswereda OK [...] User logged in.and an SMTPAUTH PLAINanswered235 2.0.0 OK. It opens a REST session too:POST /api/auth/loginwith the session id as the password answersOk— 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 -
Constructor Summary
ConstructorsConstructorDescriptionBlueMindSudoCredentialsProvider(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 TypeMethodDescriptionList<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 typedSECRET, so it goes through the platform codec and never comes back to a screen — and which eXo field names the user on BlueMind.getName()Set<org.exoplatform.services.connector.credentials.ConnectorCredentialsChannel> All three: the sudo session is accepted by IMAP, SMTP and CalDAV alike.voidinvalidate(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.ConnectorCredentialsproduce(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.voidregister()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.booleanFalse, 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.voidvalidateConfiguration(Map<String, String> values) Refuses an API address whose path is neither empty nor/api.
-
Field Details
-
NAME
The name connectors store to select this provider.- See Also:
-
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'scredentialsProviderConfigbundle.- 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 providersconfigStorage- where each connector's configuration is storedorganizationService- the directorysessionStorage- 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
- Specified by:
getNamein interfaceorg.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:
getSupportedChannelsin interfaceorg.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:
requiresUserActionin interfaceorg.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 typedSECRET, 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:
getConfigurationFieldsin interfaceorg.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.ConnectorCredentialsExceptionRefuses 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:
validateConfigurationin interfaceorg.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:
resolveTargetIdentityin interfaceorg.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:
producein interfaceorg.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 accountBlueMindSudoRefusedException- when BlueMind refuses the technical login, or the sudo for any other reasonorg.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:
invalidatein interfaceorg.exoplatform.services.connector.credentials.ConnectorCredentialsProvider- Parameters:
context- the connector and user whose session is dropped
-