@Test public void testImpliedDefaultCredentials() throws Throwable { final TestRunner runner = TestRunners.newTestRunner(MockAWSProcessor.class); runner.assertValid(); Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties(); final CredentialsProviderFactory factory = new CredentialsProviderFactory(); final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties); Assert.assertNotNull(credentialsProvider); assertEquals("credentials provider should be equal", DefaultAWSCredentialsProviderChain.class, credentialsProvider.getClass()); }
public AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties) { final CredentialsStrategy primaryStrategy = selectPrimaryStrategy(properties); AWSCredentialsProvider primaryCredentialsProvider = primaryStrategy.getCredentialsProvider(properties); AWSCredentialsProvider derivedCredentialsProvider = null; for (CredentialsStrategy strategy : strategies) { if (strategy.canCreateDerivedCredential(properties)) { derivedCredentialsProvider = strategy.getDerivedCredentialsProvider(properties, primaryCredentialsProvider); break; } } if (derivedCredentialsProvider != null) { return derivedCredentialsProvider; } else { return primaryCredentialsProvider; } }
CredentialsProviderFactory { public AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties) { final CredentialsStrategy primaryStrategy = selectPrimaryStrategy(properties); AWSCredentialsProvider primaryCredentialsProvider = primaryStrategy.getCredentialsProvider(properties); AWSCredentialsProvider derivedCredentialsProvider = null; for (CredentialsStrategy strategy : strategies) { if (strategy.canCreateDerivedCredential(properties)) { derivedCredentialsProvider = strategy.getDerivedCredentialsProvider(properties, primaryCredentialsProvider); break; } } if (derivedCredentialsProvider != null) { return derivedCredentialsProvider; } else { return primaryCredentialsProvider; } } }
CredentialsProviderFactory { public AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties) { final CredentialsStrategy primaryStrategy = selectPrimaryStrategy(properties); AWSCredentialsProvider primaryCredentialsProvider = primaryStrategy.getCredentialsProvider(properties); AWSCredentialsProvider derivedCredentialsProvider = null; for (CredentialsStrategy strategy : strategies) { if (strategy.canCreateDerivedCredential(properties)) { derivedCredentialsProvider = strategy.getDerivedCredentialsProvider(properties, primaryCredentialsProvider); break; } } if (derivedCredentialsProvider != null) { return derivedCredentialsProvider; } else { return primaryCredentialsProvider; } } CredentialsProviderFactory(); }
CredentialsProviderFactory { public AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties) { final CredentialsStrategy primaryStrategy = selectPrimaryStrategy(properties); AWSCredentialsProvider primaryCredentialsProvider = primaryStrategy.getCredentialsProvider(properties); AWSCredentialsProvider derivedCredentialsProvider = null; for (CredentialsStrategy strategy : strategies) { if (strategy.canCreateDerivedCredential(properties)) { derivedCredentialsProvider = strategy.getDerivedCredentialsProvider(properties, primaryCredentialsProvider); break; } } if (derivedCredentialsProvider != null) { return derivedCredentialsProvider; } else { return primaryCredentialsProvider; } } CredentialsProviderFactory(); CredentialsStrategy selectPrimaryStrategy(final Map<PropertyDescriptor, String> properties); CredentialsStrategy selectPrimaryStrategy(final ValidationContext validationContext); Collection<ValidationResult> validate(final ValidationContext validationContext); AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties); }
CredentialsProviderFactory { public AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties) { final CredentialsStrategy primaryStrategy = selectPrimaryStrategy(properties); AWSCredentialsProvider primaryCredentialsProvider = primaryStrategy.getCredentialsProvider(properties); AWSCredentialsProvider derivedCredentialsProvider = null; for (CredentialsStrategy strategy : strategies) { if (strategy.canCreateDerivedCredential(properties)) { derivedCredentialsProvider = strategy.getDerivedCredentialsProvider(properties, primaryCredentialsProvider); break; } } if (derivedCredentialsProvider != null) { return derivedCredentialsProvider; } else { return primaryCredentialsProvider; } } CredentialsProviderFactory(); CredentialsStrategy selectPrimaryStrategy(final Map<PropertyDescriptor, String> properties); CredentialsStrategy selectPrimaryStrategy(final ValidationContext validationContext); Collection<ValidationResult> validate(final ValidationContext validationContext); AWSCredentialsProvider getCredentialsProvider(final Map<PropertyDescriptor, String> properties);  }