Example usage for org.springframework.vault.core.lease.event SecretLeaseEvent getSource

List of usage examples for org.springframework.vault.core.lease.event SecretLeaseEvent getSource

Introduction

In this page you can find the example usage for org.springframework.vault.core.lease.event SecretLeaseEvent getSource.

Prototype

@Override
    public RequestedSecret getSource() 

Source Link

Usage

From source file:org.springframework.vault.core.env.LeaseAwareVaultPropertySource.java

/**
 * Hook method to handle a {@link SecretLeaseEvent}.
 *
 * @param leaseEvent must not be {@literal null}.
 * @param properties reference to property storage of this property source.
 *//*from   w w  w  .  j  a  va  2s . c  om*/
protected void handleLeaseEvent(SecretLeaseEvent leaseEvent, Map<String, String> properties) {

    if (leaseEvent.getSource() != getRequestedSecret()) {
        return;
    }

    if (leaseEvent instanceof SecretLeaseExpiredEvent || leaseEvent instanceof BeforeSecretLeaseRevocationEvent
            || leaseEvent instanceof SecretLeaseCreatedEvent) {
        properties.clear();
    }

    if (leaseEvent instanceof SecretLeaseCreatedEvent) {

        SecretLeaseCreatedEvent created = (SecretLeaseCreatedEvent) leaseEvent;
        properties.putAll(doTransformProperties(toStringMap(created.getSecrets())));
    }
}