org.jboss.as.clustering.controller.CredentialSourceDependency Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wildfly-clustering-common Show documentation
Show all versions of wildfly-clustering-common Show documentation
The code in this module is not explicitly related to clustering, but rather contains resuable code used by clustering modules
and any modules that integrate with clustering.
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.as.clustering.controller;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.security.CredentialReference;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.DelegatingServiceBuilder;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.wildfly.clustering.service.Dependency;
import org.wildfly.clustering.service.ServiceSupplierDependency;
import org.wildfly.clustering.service.SupplierDependency;
import org.wildfly.common.function.ExceptionSupplier;
import org.wildfly.security.credential.source.CredentialSource;
/**
* @author Paul Ferraro
* @author Richard Opalka
*/
public class CredentialSourceDependency implements SupplierDependency {
private final ExceptionSupplier supplier;
private final Iterable dependencies;
public CredentialSourceDependency(OperationContext context, Attribute attribute, ModelNode model) throws OperationFailedException {
DependencyCollectingServiceBuilder builder = new DependencyCollectingServiceBuilder();
this.supplier = CredentialReference.getCredentialSourceSupplier(context, (ObjectTypeAttributeDefinition) attribute.getDefinition(), model, builder);
this.dependencies = builder;
}
@Override
public ServiceBuilder register(ServiceBuilder builder) {
for (Dependency dependency : this.dependencies) {
dependency.register(builder);
}
return builder;
}
@Override
public CredentialSource get() {
try {
return this.supplier.get();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
static class DependencyCollectingServiceBuilder extends DelegatingServiceBuilder