001// Generated from: ../../../../../../../../oscal/src/metaschema/oscal_metadata_metaschema.xml 002// Do not edit - changes will be lost when regenerated. 003package dev.metaschema.oscal.lib.model; 004 005import dev.metaschema.core.datatype.adapter.StringAdapter; 006import dev.metaschema.core.model.IBoundObject; 007import dev.metaschema.core.model.IMetaschemaData; 008import dev.metaschema.core.model.constraint.IConstraint; 009import dev.metaschema.core.util.ObjectUtils; 010import dev.metaschema.databind.model.annotations.AllowedValue; 011import dev.metaschema.databind.model.annotations.AllowedValues; 012import dev.metaschema.databind.model.annotations.BoundFieldValue; 013import dev.metaschema.databind.model.annotations.BoundFlag; 014import dev.metaschema.databind.model.annotations.Matches; 015import dev.metaschema.databind.model.annotations.MetaschemaField; 016import dev.metaschema.databind.model.annotations.ValueConstraints; 017import edu.umd.cs.findbugs.annotations.NonNull; 018import edu.umd.cs.findbugs.annotations.Nullable; 019import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 020import org.apache.commons.lang3.builder.ToStringStyle; 021 022/** 023 * A representation of a cryptographic digest generated over a resource using a specified hash algorithm. 024 */ 025@MetaschemaField( 026 formalName = "Hash", 027 description = "A representation of a cryptographic digest generated over a resource using a specified hash algorithm.", 028 name = "hash", 029 moduleClass = OscalMetadataModule.class, 030 valueConstraints = @ValueConstraints(matches = {@Matches(id = "oscal-check-hash-length-SHA2-3-224", level = IConstraint.Level.ERROR, target = ".[@algorithm=('SHA-224','SHA3-224')]", pattern = "^[0-9a-fA-F]{56}$"), @Matches(id = "oscal-check-hash-length-SHA2-3-256", level = IConstraint.Level.ERROR, target = ".[@algorithm=('SHA-256','SHA3-256')]", pattern = "^[0-9a-fA-F]{64}$"), @Matches(id = "oscal-check-hash-length-SHA2-3-384", level = IConstraint.Level.ERROR, target = ".[@algorithm=('SHA-384','SHA3-384')]", pattern = "^[0-9a-fA-F]{96}$"), @Matches(id = "oscal-check-hash-length-SHA2-3-512", level = IConstraint.Level.ERROR, target = ".[@algorithm=('SHA-512','SHA3-512')]", pattern = "^[0-9a-fA-F]{128}$")}) 031) 032public class Hash implements IBoundObject { 033 private final IMetaschemaData __metaschemaData; 034 035 /** 036 * The digest method by which a hash is derived. 037 */ 038 @BoundFlag( 039 formalName = "Hash algorithm", 040 description = "The digest method by which a hash is derived.", 041 name = "algorithm", 042 required = true, 043 typeAdapter = StringAdapter.class, 044 remarks = "Any other value used MUST be a value defined in the W3C [XML Security Algorithm Cross-Reference](https://www.w3.org/TR/xmlsec-algorithms/#digest-method-uris) Digest Methods (W3C, April 2013) or [RFC 6931 Section 2.1.5](https://tools.ietf.org/html/rfc6931#section-2.1.5) New SHA Functions.", 045 valueConstraints = @ValueConstraints(allowedValues = @AllowedValues(id = "oscal-back-matter-resource-hash-algorithm-values", level = IConstraint.Level.ERROR, allowOthers = true, values = {@AllowedValue(value = "SHA-224", description = "The SHA-224 algorithm as defined by [NIST FIPS 180-4](https://doi.org/10.6028/NIST.FIPS.180-4)."), @AllowedValue(value = "SHA-256", description = "The SHA-256 algorithm as defined by [NIST FIPS 180-4](https://doi.org/10.6028/NIST.FIPS.180-4)."), @AllowedValue(value = "SHA-384", description = "The SHA-384 algorithm as defined by [NIST FIPS 180-4](https://doi.org/10.6028/NIST.FIPS.180-4)."), @AllowedValue(value = "SHA-512", description = "The SHA-512 algorithm as defined by [NIST FIPS 180-4](https://doi.org/10.6028/NIST.FIPS.180-4)."), @AllowedValue(value = "SHA3-224", description = "The SHA3-224 algorithm as defined by [NIST FIPS 202](https://doi.org/10.6028/NIST.FIPS.202)."), @AllowedValue(value = "SHA3-256", description = "The SHA3-256 algorithm as defined by [NIST FIPS 202](https://doi.org/10.6028/NIST.FIPS.202)."), @AllowedValue(value = "SHA3-384", description = "The SHA3-384 algorithm as defined by [NIST FIPS 202](https://doi.org/10.6028/NIST.FIPS.202)."), @AllowedValue(value = "SHA3-512", description = "The SHA3-512 algorithm as defined by [NIST FIPS 202](https://doi.org/10.6028/NIST.FIPS.202).")})) 046 ) 047 private String _algorithm; 048 049 /** 050 * The field value. 051 */ 052 @BoundFieldValue( 053 valueKeyName = "value" 054 ) 055 private String _value; 056 057 /** 058 * Constructs a new {@code dev.metaschema.oscal.lib.model.Hash} instance with no metadata. 059 */ 060 public Hash() { 061 this(null); 062 } 063 064 /** 065 * Constructs a new {@code dev.metaschema.oscal.lib.model.Hash} instance with the specified metadata. 066 * 067 * @param data 068 * the metaschema data, or {@code null} if none 069 */ 070 public Hash(IMetaschemaData data) { 071 this.__metaschemaData = data; 072 } 073 074 @Override 075 public IMetaschemaData getMetaschemaData() { 076 return __metaschemaData; 077 } 078 079 /** 080 * Get the "{@literal Hash algorithm}". 081 * 082 * <p> 083 * The digest method by which a hash is derived. 084 * 085 * @return the algorithm value 086 */ 087 @NonNull 088 public String getAlgorithm() { 089 return _algorithm; 090 } 091 092 /** 093 * Set the "{@literal Hash algorithm}". 094 * 095 * <p> 096 * The digest method by which a hash is derived. 097 * 098 * @param value 099 * the algorithm value to set 100 */ 101 public void setAlgorithm(@NonNull String value) { 102 _algorithm = value; 103 } 104 105 /** 106 * Get the field value. 107 * 108 * @return the value 109 */ 110 @Nullable 111 public String getValue() { 112 return _value; 113 } 114 115 /** 116 * Set the field value. 117 * 118 * @param value 119 * the value to set 120 */ 121 public void setValue(@Nullable String value) { 122 _value = value; 123 } 124 125 @Override 126 public String toString() { 127 return ObjectUtils.notNull(new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).toString()); 128 } 129}