Package org.jboss.as.controller.security
Class CredentialReference
- java.lang.Object
-
- org.jboss.as.controller.security.CredentialReference
-
public final class CredentialReference extends Object
Utility class holding attribute definitions for credential-reference attribute in the model. The class is unifying access to credentials defined throughCredentialStore. It defines credential-reference attribute that other subsystems can use to reference external credentials of various types.- Author:
- Peter Skopek
-
-
Field Summary
Fields Modifier and Type Field Description static StringALIASName of a field in the complex credential reference attribute.static StringCLEAR_TEXTName of a field in the complex credential reference attribute.static StringCREDENTIAL_REFERENCEStandard name of a credential reference attribute.static StringCREDENTIAL_STORE_CAPABILITYCapability required by a credential-reference attribute if itsstorefield is configured.static StringCREDENTIAL_STORE_UPDATEstatic StringEXISTING_ENTRY_UPDATEDstatic StringKEY_DELIMITERstatic StringNEW_ALIASstatic StringNEW_ENTRY_ADDEDstatic RejectAttributeCheckerREJECT_CREDENTIAL_REFERENCE_WITH_BOTH_STORE_AND_CLEAR_TEXTstatic StringSTATUSstatic StringSTOREName of a field in the complex credential reference attribute.static StringTYPEName of a field in the complex credential reference attribute.static StringUPDATE_ROLLED_BACK
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanapplyCredentialReferenceUpdateToRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode resolvedValue, org.jboss.dmr.ModelNode currentValue, String attributeName)static StringcredentialReferencePartAsStringIfDefined(org.jboss.dmr.ModelNode credentialReferenceValue, String name)Utility method to return part ofObjectTypeAttributeDefinitionfor credential reference attribute.static ObjectTypeAttributeDefinition.BuildergetAttributeBuilder(boolean allowNull, boolean referenceCredentialStore)Gets an attribute builder for a credential-reference attribute with the standardcredential-referenceattribute name, a configurable setting as to whether the attribute is required, and optionally configured toregister a requirementfor acredential store capability.static ObjectTypeAttributeDefinition.BuildergetAttributeBuilder(String name, String xmlName, boolean allowNull)Get an attribute builder for a credential-reference attribute with the specified characteristics.static ObjectTypeAttributeDefinition.BuildergetAttributeBuilder(String name, String xmlName, boolean allowNull, boolean referenceCredentialStore)Get an attribute builder for a credential-reference attribute with the specified characteristics, optionally configured toregister a requirementfor acredential store capability.static ObjectTypeAttributeDefinition.BuildergetAttributeBuilder(String name, String xmlName, boolean allowNull, CapabilityReferenceRecorder capabilityStoreReferenceRecorder)Get an attribute builder for a credential-reference attribute with the specified characteristics, optionally configured toAbstractAttributeDefinitionBuilder.setCapabilityReference(CapabilityReferenceRecorder)register a requirement} for acredential store capability.static ObjectTypeAttributeDefinitiongetAttributeDefinition()Returns a definition for a credential reference attribute.static ObjectTypeAttributeDefinitiongetAttributeDefinition(boolean referenceCredentialStore)Returns a definition for a credential reference attribute, one that optionallyregisters a requirementfor acredential store capability.static org.wildfly.security.credential.source.CredentialSourcegetCredentialSource(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model)static ServiceDependency<org.wildfly.security.credential.source.CredentialSource>getCredentialSourceDependency(OperationContext context, AttributeDefinition attribute, org.jboss.dmr.ModelNode model)Returns a service dependency on aCredentialSourceused to obtain a credential referenced by the specified attribute.static ServiceDependency<org.wildfly.security.credential.source.CredentialSource>getCredentialSourceDependency(OperationContext context, AttributeDefinition attribute, org.jboss.dmr.ModelNode model, String keySuffix)Returns a service dependency on aCredentialSourceused to obtain a credential referenced by the specified attribute.static org.wildfly.common.function.ExceptionSupplier<org.wildfly.security.credential.source.CredentialSource,Exception>getCredentialSourceSupplier(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model, org.jboss.msc.service.ServiceBuilder<?> serviceBuilder)Get the ExceptionSupplier ofCredentialSourcewhich might throw an Exception while getting it.static org.wildfly.common.function.ExceptionSupplier<org.wildfly.security.credential.source.CredentialSource,Exception>getCredentialSourceSupplier(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model, org.jboss.msc.service.ServiceBuilder<?> serviceBuilder, String keySuffix)Get the ExceptionSupplier ofCredentialSourcewhich might throw an Exception while getting it.static voidhandleCredentialReferenceUpdate(OperationContext context, org.jboss.dmr.ModelNode model)static voidhandleCredentialReferenceUpdate(OperationContext context, org.jboss.dmr.ModelNode credentialReference, String credentialReferenceAttributeName)static voidrollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, String store, String alias)static voidrollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, Resource resource)static voidrollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, org.jboss.dmr.ModelNode resolvedValue)
-
-
-
Field Detail
-
CREDENTIAL_STORE_CAPABILITY
public static final String CREDENTIAL_STORE_CAPABILITY
Capability required by a credential-reference attribute if itsstorefield is configured.- See Also:
- Constant Field Values
-
CREDENTIAL_REFERENCE
public static final String CREDENTIAL_REFERENCE
Standard name of a credential reference attribute.- See Also:
- Constant Field Values
-
STORE
public static final String STORE
Name of a field in the complex credential reference attribute.- See Also:
- Constant Field Values
-
ALIAS
public static final String ALIAS
Name of a field in the complex credential reference attribute.- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
Name of a field in the complex credential reference attribute.- See Also:
- Constant Field Values
-
CLEAR_TEXT
public static final String CLEAR_TEXT
Name of a field in the complex credential reference attribute.- See Also:
- Constant Field Values
-
CREDENTIAL_STORE_UPDATE
public static final String CREDENTIAL_STORE_UPDATE
- See Also:
- Constant Field Values
-
STATUS
public static final String STATUS
- See Also:
- Constant Field Values
-
NEW_ENTRY_ADDED
public static final String NEW_ENTRY_ADDED
- See Also:
- Constant Field Values
-
EXISTING_ENTRY_UPDATED
public static final String EXISTING_ENTRY_UPDATED
- See Also:
- Constant Field Values
-
NEW_ALIAS
public static final String NEW_ALIAS
- See Also:
- Constant Field Values
-
UPDATE_ROLLED_BACK
public static final String UPDATE_ROLLED_BACK
- See Also:
- Constant Field Values
-
KEY_DELIMITER
public static final String KEY_DELIMITER
- See Also:
- Constant Field Values
-
REJECT_CREDENTIAL_REFERENCE_WITH_BOTH_STORE_AND_CLEAR_TEXT
public static final RejectAttributeChecker REJECT_CREDENTIAL_REFERENCE_WITH_BOTH_STORE_AND_CLEAR_TEXT
-
-
Method Detail
-
getAttributeDefinition
public static ObjectTypeAttributeDefinition getAttributeDefinition()
Returns a definition for a credential reference attribute. Thestorefield in the attribute does not register any requirement for a credential store capability.- Returns:
- credential reference attribute definition
-
getAttributeDefinition
public static ObjectTypeAttributeDefinition getAttributeDefinition(boolean referenceCredentialStore)
Returns a definition for a credential reference attribute, one that optionallyregisters a requirementfor acredential store capability. If a requirement is registered, the dependent capability will be the single capability registered by the resource that uses this attribute definition. The resource must expose one and only one capability in order to use this facility.- Parameters:
referenceCredentialStore-trueif thestorefield in the attribute should register a requirement for a credential store capability.- Returns:
- credential reference attribute definition
-
getAttributeBuilder
public static ObjectTypeAttributeDefinition.Builder getAttributeBuilder(boolean allowNull, boolean referenceCredentialStore)
Gets an attribute builder for a credential-reference attribute with the standardcredential-referenceattribute name, a configurable setting as to whether the attribute is required, and optionally configured toregister a requirementfor acredential store capability. If a requirement is registered, the dependent capability will be the single capability registered by the resource that uses this attribute definition. The resource must expose one and only one capability in order to use this facility.- Parameters:
allowNull- whether the attribute is requiredreferenceCredentialStore-trueif thestorefield in the attribute should register a requirement for a credential store capability.- Returns:
- an
ObjectTypeAttributeDefinition.Builderwhich can be used to build an attribute definition
-
getAttributeBuilder
public static ObjectTypeAttributeDefinition.Builder getAttributeBuilder(String name, String xmlName, boolean allowNull)
Get an attribute builder for a credential-reference attribute with the specified characteristics. Thestorefield in the attribute does not register any requirement for a credential store capability.- Parameters:
name- name of attributexmlName- name of xml elementallowNull-falseif the attribute is required- Returns:
- an
ObjectTypeAttributeDefinition.Builderwhich can be used to build an attribute definition
-
getAttributeBuilder
public static ObjectTypeAttributeDefinition.Builder getAttributeBuilder(String name, String xmlName, boolean allowNull, boolean referenceCredentialStore)
Get an attribute builder for a credential-reference attribute with the specified characteristics, optionally configured toregister a requirementfor acredential store capability. If a requirement is registered, the dependent capability will be the single capability registered by the resource that uses this attribute definition. The resource must expose one and only one capability in order to use this facility.- Parameters:
name- name of attributexmlName- name of xml elementallowNull-falseif the attribute is requiredreferenceCredentialStore-trueif thestorefield in the attribute should register a requirement for a credential store capability.- Returns:
- an
ObjectTypeAttributeDefinition.Builderwhich can be used to build an attribute definition
-
getAttributeBuilder
public static ObjectTypeAttributeDefinition.Builder getAttributeBuilder(String name, String xmlName, boolean allowNull, CapabilityReferenceRecorder capabilityStoreReferenceRecorder)
Get an attribute builder for a credential-reference attribute with the specified characteristics, optionally configured toAbstractAttributeDefinitionBuilder.setCapabilityReference(CapabilityReferenceRecorder)register a requirement} for acredential store capability.- Parameters:
name- name of attributexmlName- name of xml elementallowNull-falseif the attribute is requiredcapabilityStoreReferenceRecorder- a capability reference recorder that can record a requirement for the credential store referenced by thestorefield of the returned attribute definition. Can benull, in which case no requirement would be recorded. If notnullthe recorder'sbase requirement namemust equalCREDENTIAL_STORE_CAPABILITY- Returns:
- an
ObjectTypeAttributeDefinition.Builderwhich can be used to build attribute definition
-
credentialReferencePartAsStringIfDefined
public static String credentialReferencePartAsStringIfDefined(org.jboss.dmr.ModelNode credentialReferenceValue, String name) throws OperationFailedException
Utility method to return part ofObjectTypeAttributeDefinitionfor credential reference attribute. {@see CredentialReference#getAttributeDefinition}- Parameters:
credentialReferenceValue- value of credential reference attributename- name of part to return (supported names:STOREALIASTYPECLEAR_TEXT- Returns:
- value of part as
String - Throws:
OperationFailedException- when something goes wrong
-
getCredentialSourceDependency
public static ServiceDependency<org.wildfly.security.credential.source.CredentialSource> getCredentialSourceDependency(OperationContext context, AttributeDefinition attribute, org.jboss.dmr.ModelNode model) throws OperationFailedException
Returns a service dependency on aCredentialSourceused to obtain a credential referenced by the specified attribute.- Parameters:
context- operation contextattribute- an attribute that references a credentialmodel- a resource model- Returns:
- a
CredentialSourceservice dependency - Throws:
OperationFailedException- if the attribute could not be resolved
-
getCredentialSourceDependency
public static ServiceDependency<org.wildfly.security.credential.source.CredentialSource> getCredentialSourceDependency(OperationContext context, AttributeDefinition attribute, org.jboss.dmr.ModelNode model, String keySuffix) throws OperationFailedException
Returns a service dependency on aCredentialSourceused to obtain a credential referenced by the specified attribute.- Parameters:
context- operation contextattribute- an attribute that references a credentialmodel- a resource modelkeySuffix- extra path elements- Returns:
- a
CredentialSourceservice dependency - Throws:
OperationFailedException- if the attribute could not be resolved
-
getCredentialSourceSupplier
public static org.wildfly.common.function.ExceptionSupplier<org.wildfly.security.credential.source.CredentialSource,Exception> getCredentialSourceSupplier(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model, org.jboss.msc.service.ServiceBuilder<?> serviceBuilder) throws OperationFailedException
Get the ExceptionSupplier ofCredentialSourcewhich might throw an Exception while getting it.CredentialSourceis used later to retrieve the credential requested by configuration.- Parameters:
context- operation contextcredentialReferenceAttributeDefinition- credential-reference attribute definitionmodel- containing the actual valuesserviceBuilder- of service which needs the credential- Returns:
- ExceptionSupplier of CredentialSource
- Throws:
OperationFailedException- wrapping exception when something goes wrong
-
getCredentialSourceSupplier
public static org.wildfly.common.function.ExceptionSupplier<org.wildfly.security.credential.source.CredentialSource,Exception> getCredentialSourceSupplier(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model, org.jboss.msc.service.ServiceBuilder<?> serviceBuilder, String keySuffix) throws OperationFailedException
Get the ExceptionSupplier ofCredentialSourcewhich might throw an Exception while getting it.CredentialSourceis used later to retrieve the credential requested by configuration.- Parameters:
context- operation contextcredentialReferenceAttributeDefinition- credential-reference attribute definitionmodel- containing the actual valuesserviceBuilder- of service which needs the credentialkeySuffix- extra path elements- Returns:
- ExceptionSupplier of CredentialSource
- Throws:
OperationFailedException- wrapping exception when something goes wrong
-
getCredentialSource
public static org.wildfly.security.credential.source.CredentialSource getCredentialSource(OperationContext context, ObjectTypeAttributeDefinition credentialReferenceAttributeDefinition, org.jboss.dmr.ModelNode model) throws OperationFailedException
- Throws:
OperationFailedException
-
handleCredentialReferenceUpdate
public static void handleCredentialReferenceUpdate(OperationContext context, org.jboss.dmr.ModelNode model) throws OperationFailedException
- Throws:
OperationFailedException
-
rollbackCredentialStoreUpdate
public static void rollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, Resource resource)
-
rollbackCredentialStoreUpdate
public static void rollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, org.jboss.dmr.ModelNode resolvedValue)
-
rollbackCredentialStoreUpdate
public static void rollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, String store, String alias)
-
handleCredentialReferenceUpdate
public static void handleCredentialReferenceUpdate(OperationContext context, org.jboss.dmr.ModelNode credentialReference, String credentialReferenceAttributeName) throws OperationFailedException
- Throws:
OperationFailedException
-
applyCredentialReferenceUpdateToRuntime
public static boolean applyCredentialReferenceUpdateToRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode resolvedValue, org.jboss.dmr.ModelNode currentValue, String attributeName) throws OperationFailedException
- Throws:
OperationFailedException
-
-