class Anonymous in Entity Share 8.3
Provides Anonymous authorization.
Plugin annotation
@ClientAuthorization(
id = "anonymous",
label = @Translation("Anonymous"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\entity_share_client\ClientAuthorization\ClientAuthorizationPluginBase implements ContainerFactoryPluginInterface, ClientAuthorizationInterface
- class \Drupal\entity_share_client\Plugin\ClientAuthorization\Anonymous
- class \Drupal\entity_share_client\ClientAuthorization\ClientAuthorizationPluginBase implements ContainerFactoryPluginInterface, ClientAuthorizationInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Anonymous
1 string reference to 'Anonymous'
- ChannelForm::getAuthorizedUsersOptions in modules/
entity_share_server/ src/ Form/ ChannelForm.php - Helper function.
File
- modules/
entity_share_client/ src/ Plugin/ ClientAuthorization/ Anonymous.php, line 18
Namespace
Drupal\entity_share_client\Plugin\ClientAuthorizationView source
class Anonymous extends ClientAuthorizationPluginBase {
/**
* {@inheritdoc}
*/
public function checkIfAvailable() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function getClient($url) {
$options = [
'base_uri' => $url . '/',
'cookies' => TRUE,
'allow_redirects' => TRUE,
];
$credentials = $this->keyService
->getCredentials($this);
if (!empty($credentials['username']) && !empty($credentials['password'])) {
$options['auth'] = [
$credentials['username'],
$credentials['password'],
];
}
return $this->httpClientFactory
->fromOptions($options);
}
/**
* {@inheritdoc}
*/
public function getJsonApiClient($url) {
$options = [
'base_uri' => $url . '/',
'headers' => [
'Content-type' => 'application/vnd.api+json',
],
];
$credentials = $this->keyService
->getCredentials($this);
if (!empty($credentials['username']) && !empty($credentials['password'])) {
$options['auth'] = [
$credentials['username'],
$credentials['password'],
];
}
return $this->httpClientFactory
->fromOptions($options);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$credentials = $this->keyService
->getCredentials($this);
$form['entity_share']['#description'] = $this
->t('Leave empty if the server website is not protected via HTTP Password.');
$form['entity_share']['username'] = [
'#type' => 'textfield',
'#required' => FALSE,
'#title' => $this
->t('Username'),
'#default_value' => $credentials['username'] ?? '',
];
$form['entity_share']['password'] = [
'#type' => 'password',
'#required' => FALSE,
'#title' => $this
->t('Password'),
'#default_value' => $credentials['password'] ?? '',
];
if ($this->keyService
->additionalProviders()) {
$this
->expandedProviderOptions($form);
$form['key']['id']['#key_filters'] = [
'type' => 'entity_share_basic_auth',
];
$form['key']['id']['#description'] = $this
->t('Select the key you have configured to hold the HTTP Password credentials.');
}
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
// To prevent validation from parent::validateConfigurationForm() as
// credentials is not required.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Anonymous:: |
public | function |
Form constructor. Overrides ClientAuthorizationPluginBase:: |
|
Anonymous:: |
public | function |
Returns true if the plugin method is supported. Overrides ClientAuthorizationInterface:: |
|
Anonymous:: |
public | function |
Prepares a guzzle client for http operations with the supported auth. Overrides ClientAuthorizationInterface:: |
|
Anonymous:: |
public | function |
Prepares a guzzle client for JSON operations with the supported auth. Overrides ClientAuthorizationInterface:: |
|
Anonymous:: |
public | function |
Form validation handler. Overrides ClientAuthorizationPluginBase:: |
|
ClientAuthorizationInterface:: |
constant | The collection ID of for authorization config local storage. | ||
ClientAuthorizationPluginBase:: |
protected | property | Injected HTTP client factory. | |
ClientAuthorizationPluginBase:: |
protected | property | Injected key service. | |
ClientAuthorizationPluginBase:: |
protected | property | The key value store to use. | |
ClientAuthorizationPluginBase:: |
protected | property | Injected UUID service. | |
ClientAuthorizationPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
ClientAuthorizationPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
ClientAuthorizationPluginBase:: |
protected | function | Helper method to build the credential provider elements of the form. | |
ClientAuthorizationPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ClientAuthorizationPluginBase:: |
public | function |
Returns the plugin data if it is set, otherwise returns NULL. Overrides ClientAuthorizationInterface:: |
|
ClientAuthorizationPluginBase:: |
public | function |
Gets the plugin label. Overrides ClientAuthorizationInterface:: |
|
ClientAuthorizationPluginBase:: |
public | function |
Returns the plugin data if it is set, otherwise returns NULL. Overrides ClientAuthorizationInterface:: |
|
ClientAuthorizationPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
ClientAuthorizationPluginBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
1 |
ClientAuthorizationPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |