* AuthProvider implementation delegating to AAA CredentialAuth<PasswordCredentials> instance.
*/
public final class CredentialServiceAuthProvider implements AuthProvider, AutoCloseable {
- private static final Logger logger = LoggerFactory.getLogger(CredentialServiceAuthProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CredentialServiceAuthProvider.class);
/**
- * Singleton instance with delayed instantiation
+ * Singleton instance with delayed instantiation.
*/
public static volatile Map.Entry<BundleContext, CredentialServiceAuthProvider> INSTANCE;
public CredentialServiceAuthProvider(final BundleContext bundleContext) {
- final ServiceTrackerCustomizer<CredentialAuth, CredentialAuth> customizer = new ServiceTrackerCustomizer<CredentialAuth, CredentialAuth>() {
+ final ServiceTrackerCustomizer<CredentialAuth, CredentialAuth> customizer =
+ new ServiceTrackerCustomizer<CredentialAuth, CredentialAuth>() {
@Override
public CredentialAuth addingService(final ServiceReference<CredentialAuth> reference) {
- logger.trace("Credential service {} added", reference);
+ LOG.trace("Credential service {} added", reference);
nullableCredService = bundleContext.getService(reference);
return nullableCredService;
}
@Override
- public void modifiedService(final ServiceReference<CredentialAuth> reference, final CredentialAuth service) {
- logger.trace("Replacing modified Credential service {}", reference);
+ public void modifiedService(final ServiceReference<CredentialAuth> reference,
+ final CredentialAuth service) {
+ LOG.trace("Replacing modified Credential service {}", reference);
nullableCredService = service;
}
@Override
public void removedService(final ServiceReference<CredentialAuth> reference, final CredentialAuth service) {
- logger.trace("Removing Credential service {}. This AuthProvider will fail to authenticate every time", reference);
+ LOG.trace("Removing Credential service {}. "
+ + "This AuthProvider will fail to authenticate every time", reference);
synchronized (CredentialServiceAuthProvider.this) {
nullableCredService = null;
}
}
/**
- * Authenticate user. This implementation tracks CredentialAuth<PasswordCredentials> and delegates the decision to it. If the service is not
- * available, IllegalStateException is thrown.
+ * Authenticate user. This implementation tracks CredentialAuth<PasswordCredentials>
+ * and delegates the decision to it. If the service is not available, IllegalStateException is thrown.
*/
@Override
public synchronized boolean authenticated(final String username, final String password) {
if (nullableCredService == null) {
- logger.warn("Cannot authenticate user '{}', Credential service is missing", username);
+ LOG.warn("Cannot authenticate user '{}', Credential service is missing", username);
throw new IllegalStateException("Credential service is not available");
}
try {
claim = nullableCredService.authenticate(new PasswordCredentialsWrapper(username, password));
} catch (AuthenticationException e) {
- logger.debug("Authentication failed for user '{}' : {}", username, e);
+ LOG.debug("Authentication failed for user '{}' : {}", username, e);
return false;
}
- logger.debug("Authentication result for user '{}' : {}", username, claim.domain());
+ LOG.debug("Authentication result for user '{}' : {}", username, claim.domain());
return true;
}
/**
- * Invoke by blueprint
+ * Invoked by blueprint.
*/
@Override
public void close() {
private final String username;
private final String password;
- public PasswordCredentialsWrapper(final String username, final String password) {
+ PasswordCredentialsWrapper(final String username, final String password) {
this.username = username;
this.password = password;
}