org.wildfly.swarm.config.security.security_domain.JaspiAuthentication Maven / Gradle / Ivy
package org.wildfly.swarm.config.security.security_domain;
import org.wildfly.swarm.config.runtime.AttributeDocumentation;
import org.wildfly.swarm.config.runtime.ResourceDocumentation;
import org.wildfly.swarm.config.runtime.SingletonResource;
import org.wildfly.swarm.config.runtime.Address;
import org.wildfly.swarm.config.runtime.ResourceType;
import org.wildfly.swarm.config.runtime.Implicit;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.wildfly.swarm.config.runtime.Subresource;
import org.wildfly.swarm.config.security.security_domain.authentication.LoginModuleStackConsumer;
import org.wildfly.swarm.config.security.security_domain.authentication.LoginModuleStackSupplier;
import org.wildfly.swarm.config.security.security_domain.authentication.LoginModuleStack;
import org.wildfly.swarm.config.runtime.SubresourceInfo;
import org.wildfly.swarm.config.security.security_domain.authentication.AuthModuleConsumer;
import org.wildfly.swarm.config.security.security_domain.authentication.AuthModuleSupplier;
import org.wildfly.swarm.config.security.security_domain.authentication.AuthModule;
import org.wildfly.swarm.config.runtime.ModelNodeBinding;
/**
* JASPI authentication configuration.
*/
@Address("/subsystem=security/security-domain=*/authentication=jaspi")
@ResourceType("authentication")
@Implicit
public class JaspiAuthentication>
implements
org.wildfly.swarm.config.runtime.Keyed {
private String key;
private PropertyChangeSupport pcs;
private JaspiAuthenticationResources subresources = new JaspiAuthenticationResources();
public JaspiAuthentication() {
super();
this.key = "jaspi";
this.pcs = new PropertyChangeSupport(this);
}
public String getKey() {
return this.key;
}
/**
* Adds a property change listener
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
if (null == this.pcs)
this.pcs = new PropertyChangeSupport(this);
this.pcs.addPropertyChangeListener(listener);
}
/**
* Removes a property change listener
*/
public void removePropertyChangeListener(
java.beans.PropertyChangeListener listener) {
if (this.pcs != null)
this.pcs.removePropertyChangeListener(listener);
}
public JaspiAuthenticationResources subresources() {
return this.subresources;
}
/**
* Add all LoginModuleStack objects to this subresource
*
* @return this
* @param value
* List of LoginModuleStack objects.
*/
@SuppressWarnings("unchecked")
public T loginModuleStacks(java.util.List value) {
this.subresources.loginModuleStacks = value;
return (T) this;
}
/**
* Add the LoginModuleStack object to the list of subresources
*
* @param value
* The LoginModuleStack to add
* @return this
*/
@SuppressWarnings("unchecked")
public T loginModuleStack(LoginModuleStack value) {
this.subresources.loginModuleStacks.add(value);
return (T) this;
}
/**
* Create and configure a LoginModuleStack object to the list of
* subresources
*
* @param key
* The key for the LoginModuleStack resource
* @param config
* The LoginModuleStackConsumer to use
* @return this
*/
@SuppressWarnings("unchecked")
public T loginModuleStack(java.lang.String childKey,
LoginModuleStackConsumer consumer) {
LoginModuleStack child = new LoginModuleStack<>(
childKey);
if (consumer != null) {
consumer.accept(child);
}
loginModuleStack(child);
return (T) this;
}
/**
* Create and configure a LoginModuleStack object to the list of
* subresources
*
* @param key
* The key for the LoginModuleStack resource
* @return this
*/
@SuppressWarnings("unchecked")
public T loginModuleStack(java.lang.String childKey) {
loginModuleStack(childKey, null);
return (T) this;
}
/**
* Install a supplied LoginModuleStack object to the list of subresources
*/
@SuppressWarnings("unchecked")
public T loginModuleStack(LoginModuleStackSupplier supplier) {
loginModuleStack(supplier.get());
return (T) this;
}
/**
* Add all AuthModule objects to this subresource
*
* @return this
* @param value
* List of AuthModule objects.
*/
@SuppressWarnings("unchecked")
public T authModules(java.util.List value) {
this.subresources.authModules = value;
return (T) this;
}
/**
* Add the AuthModule object to the list of subresources
*
* @param value
* The AuthModule to add
* @return this
*/
@SuppressWarnings("unchecked")
public T authModule(AuthModule value) {
this.subresources.authModules.add(value);
return (T) this;
}
/**
* Create and configure a AuthModule object to the list of subresources
*
* @param key
* The key for the AuthModule resource
* @param config
* The AuthModuleConsumer to use
* @return this
*/
@SuppressWarnings("unchecked")
public T authModule(java.lang.String childKey, AuthModuleConsumer consumer) {
AuthModule child = new AuthModule<>(childKey);
if (consumer != null) {
consumer.accept(child);
}
authModule(child);
return (T) this;
}
/**
* Create and configure a AuthModule object to the list of subresources
*
* @param key
* The key for the AuthModule resource
* @return this
*/
@SuppressWarnings("unchecked")
public T authModule(java.lang.String childKey) {
authModule(childKey, null);
return (T) this;
}
/**
* Install a supplied AuthModule object to the list of subresources
*/
@SuppressWarnings("unchecked")
public T authModule(AuthModuleSupplier supplier) {
authModule(supplier.get());
return (T) this;
}
/**
* Child mutators for JaspiAuthentication
*/
public static class JaspiAuthenticationResources {
/**
* List of "named" login modules that are used by jaspi authentication
* modules.
*/
@ResourceDocumentation("List of \"named\" login modules that are used by jaspi authentication modules.")
@SubresourceInfo("loginModuleStack")
private List loginModuleStacks = new java.util.ArrayList<>();
/**
* List of modules that map principal, role, and credential information
*/
@ResourceDocumentation("List of modules that map principal, role, and credential information")
@SubresourceInfo("authModule")
private List authModules = new java.util.ArrayList<>();
/**
* Get the list of LoginModuleStack resources
*
* @return the list of resources
*/
@Subresource
public List loginModuleStacks() {
return this.loginModuleStacks;
}
public LoginModuleStack loginModuleStack(java.lang.String key) {
return this.loginModuleStacks.stream()
.filter(e -> e.getKey().equals(key)).findFirst()
.orElse(null);
}
/**
* Get the list of AuthModule resources
*
* @return the list of resources
*/
@Subresource
public List authModules() {
return this.authModules;
}
public AuthModule authModule(java.lang.String key) {
return this.authModules.stream()
.filter(e -> e.getKey().equals(key)).findFirst()
.orElse(null);
}
}
}