All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mitre.capec.capec_2.AttackStepTechnique Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2015, The MITRE Corporation. All rights reserved.
 * See LICENSE for complete terms.
 */

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2 
// See http://java.sun.com/xml/jaxb 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2015.07.01 at 03:19:53 PM EDT 
//

package org.mitre.capec.capec_2;

import java.io.StringReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
import org.mitre.cybox.cybox_2.Observables;
import org.mitre.stix.DocumentUtilities;
import org.mitre.stix.STIXSchema;
import org.mitre.stix.ValidationEventHandler;
import org.xml.sax.SAXException;

/**
 * A particular technique that may accomplish this attack step.
 * 				
 * 
 * 

Java class for anonymous complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <all>
 *         <element name="Attack_Step_Technique_Description" type="{http://capec.mitre.org/capec-2}Structured_Text_Type"/>
 *         <element name="Leveraged_Attack_Patterns" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="Leveraged_Attack_Pattern_ID" type="{http://www.w3.org/2001/XMLSchema}anyType" maxOccurs="unbounded"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *         <element name="Relevant_Attack_Surface_Elements" type="{http://capec.mitre.org/capec-2}Relevant_Attack_Surface_ElementsType" minOccurs="0"/>
 *         <element name="Observables" type="{http://cybox.mitre.org/cybox-2}ObservablesType" minOccurs="0"/>
 *         <element name="Environments" type="{http://www.w3.org/2001/XMLSchema}IDREFS"/>
 *       </all>
 *       <attribute name="ID" use="required" type="{http://www.w3.org/2001/XMLSchema}integer" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { }) @XmlRootElement(name = "Attack_Step_Technique") public class AttackStepTechnique implements Equals, HashCode, ToString { @XmlElement(name = "Attack_Step_Technique_Description", required = true) protected StructuredTextType attackStepTechniqueDescription; @XmlElement(name = "Leveraged_Attack_Patterns") protected AttackStepTechnique.LeveragedAttackPatterns leveragedAttackPatterns; @XmlElement(name = "Relevant_Attack_Surface_Elements") protected RelevantAttackSurfaceElementsType relevantAttackSurfaceElements; @XmlElement(name = "Observables") protected Observables observables; @XmlList @XmlElement(name = "Environments", required = true) @XmlIDREF @XmlSchemaType(name = "IDREFS") protected List environments; @XmlAttribute(name = "ID", required = true) protected BigInteger id; /** * Default no-arg constructor * */ public AttackStepTechnique() { super(); } /** * Fully-initialising value constructor * */ public AttackStepTechnique( final StructuredTextType attackStepTechniqueDescription, final AttackStepTechnique.LeveragedAttackPatterns leveragedAttackPatterns, final RelevantAttackSurfaceElementsType relevantAttackSurfaceElements, final Observables observables, final List environments, final BigInteger id) { this.attackStepTechniqueDescription = attackStepTechniqueDescription; this.leveragedAttackPatterns = leveragedAttackPatterns; this.relevantAttackSurfaceElements = relevantAttackSurfaceElements; this.observables = observables; this.environments = environments; this.id = id; } /** * Gets the value of the attackStepTechniqueDescription property. * * @return * possible object is * {@link StructuredTextType } * */ public StructuredTextType getAttackStepTechniqueDescription() { return attackStepTechniqueDescription; } /** * Sets the value of the attackStepTechniqueDescription property. * * @param value * allowed object is * {@link StructuredTextType } * */ public void setAttackStepTechniqueDescription(StructuredTextType value) { this.attackStepTechniqueDescription = value; } /** * Gets the value of the leveragedAttackPatterns property. * * @return * possible object is * {@link AttackStepTechnique.LeveragedAttackPatterns } * */ public AttackStepTechnique.LeveragedAttackPatterns getLeveragedAttackPatterns() { return leveragedAttackPatterns; } /** * Sets the value of the leveragedAttackPatterns property. * * @param value * allowed object is * {@link AttackStepTechnique.LeveragedAttackPatterns } * */ public void setLeveragedAttackPatterns( AttackStepTechnique.LeveragedAttackPatterns value) { this.leveragedAttackPatterns = value; } /** * Gets the value of the relevantAttackSurfaceElements property. * * @return * possible object is * {@link RelevantAttackSurfaceElementsType } * */ public RelevantAttackSurfaceElementsType getRelevantAttackSurfaceElements() { return relevantAttackSurfaceElements; } /** * Sets the value of the relevantAttackSurfaceElements property. * * @param value * allowed object is * {@link RelevantAttackSurfaceElementsType } * */ public void setRelevantAttackSurfaceElements( RelevantAttackSurfaceElementsType value) { this.relevantAttackSurfaceElements = value; } /** * Gets the value of the observables property. * * @return * possible object is * {@link Observables } * */ public Observables getObservables() { return observables; } /** * Sets the value of the observables property. * * @param value * allowed object is * {@link Observables } * */ public void setObservables(Observables value) { this.observables = value; } /** * Gets the value of the environments property. * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the environments property. * *

* For example, to add a new item, do as follows: *

	 *    getEnvironments().add(newItem);
	 * 
* * *

* Objects of the following type(s) are allowed in the list * {@link Object } * * */ public List getEnvironments() { if (environments == null) { environments = new ArrayList(); } return this.environments; } /** * Gets the value of the id property. * * @return * possible object is * {@link BigInteger } * */ public BigInteger getID() { return id; } /** * Sets the value of the id property. * * @param value * allowed object is * {@link BigInteger } * */ public void setID(BigInteger value) { this.id = value; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof AttackStepTechnique)) { return false; } if (this == object) { return true; } final AttackStepTechnique that = ((AttackStepTechnique) object); { StructuredTextType lhsAttackStepTechniqueDescription; lhsAttackStepTechniqueDescription = this .getAttackStepTechniqueDescription(); StructuredTextType rhsAttackStepTechniqueDescription; rhsAttackStepTechniqueDescription = that .getAttackStepTechniqueDescription(); if (!strategy.equals(LocatorUtils.property(thisLocator, "attackStepTechniqueDescription", lhsAttackStepTechniqueDescription), LocatorUtils.property( thatLocator, "attackStepTechniqueDescription", rhsAttackStepTechniqueDescription), lhsAttackStepTechniqueDescription, rhsAttackStepTechniqueDescription)) { return false; } } { AttackStepTechnique.LeveragedAttackPatterns lhsLeveragedAttackPatterns; lhsLeveragedAttackPatterns = this.getLeveragedAttackPatterns(); AttackStepTechnique.LeveragedAttackPatterns rhsLeveragedAttackPatterns; rhsLeveragedAttackPatterns = that.getLeveragedAttackPatterns(); if (!strategy.equals(LocatorUtils.property(thisLocator, "leveragedAttackPatterns", lhsLeveragedAttackPatterns), LocatorUtils.property(thatLocator, "leveragedAttackPatterns", rhsLeveragedAttackPatterns), lhsLeveragedAttackPatterns, rhsLeveragedAttackPatterns)) { return false; } } { RelevantAttackSurfaceElementsType lhsRelevantAttackSurfaceElements; lhsRelevantAttackSurfaceElements = this .getRelevantAttackSurfaceElements(); RelevantAttackSurfaceElementsType rhsRelevantAttackSurfaceElements; rhsRelevantAttackSurfaceElements = that .getRelevantAttackSurfaceElements(); if (!strategy.equals(LocatorUtils.property(thisLocator, "relevantAttackSurfaceElements", lhsRelevantAttackSurfaceElements), LocatorUtils.property( thatLocator, "relevantAttackSurfaceElements", rhsRelevantAttackSurfaceElements), lhsRelevantAttackSurfaceElements, rhsRelevantAttackSurfaceElements)) { return false; } } { Observables lhsObservables; lhsObservables = this.getObservables(); Observables rhsObservables; rhsObservables = that.getObservables(); if (!strategy.equals(LocatorUtils.property(thisLocator, "observables", lhsObservables), LocatorUtils.property( thatLocator, "observables", rhsObservables), lhsObservables, rhsObservables)) { return false; } } { List lhsEnvironments; lhsEnvironments = (((this.environments != null) && (!this.environments .isEmpty())) ? this.getEnvironments() : null); List rhsEnvironments; rhsEnvironments = (((that.environments != null) && (!that.environments .isEmpty())) ? that.getEnvironments() : null); if (!strategy.equals(LocatorUtils.property(thisLocator, "environments", lhsEnvironments), LocatorUtils.property( thatLocator, "environments", rhsEnvironments), lhsEnvironments, rhsEnvironments)) { return false; } } { BigInteger lhsID; lhsID = this.getID(); BigInteger rhsID; rhsID = that.getID(); if (!strategy.equals( LocatorUtils.property(thisLocator, "id", lhsID), LocatorUtils.property(thatLocator, "id", rhsID), lhsID, rhsID)) { return false; } } return true; } public boolean equals(Object object) { final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); } public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { StructuredTextType theAttackStepTechniqueDescription; theAttackStepTechniqueDescription = this .getAttackStepTechniqueDescription(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "attackStepTechniqueDescription", theAttackStepTechniqueDescription), currentHashCode, theAttackStepTechniqueDescription); } { AttackStepTechnique.LeveragedAttackPatterns theLeveragedAttackPatterns; theLeveragedAttackPatterns = this.getLeveragedAttackPatterns(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "leveragedAttackPatterns", theLeveragedAttackPatterns), currentHashCode, theLeveragedAttackPatterns); } { RelevantAttackSurfaceElementsType theRelevantAttackSurfaceElements; theRelevantAttackSurfaceElements = this .getRelevantAttackSurfaceElements(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "relevantAttackSurfaceElements", theRelevantAttackSurfaceElements), currentHashCode, theRelevantAttackSurfaceElements); } { Observables theObservables; theObservables = this.getObservables(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "observables", theObservables), currentHashCode, theObservables); } { List theEnvironments; theEnvironments = (((this.environments != null) && (!this.environments .isEmpty())) ? this.getEnvironments() : null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "environments", theEnvironments), currentHashCode, theEnvironments); } { BigInteger theID; theID = this.getID(); currentHashCode = strategy.hashCode( LocatorUtils.property(locator, "id", theID), currentHashCode, theID); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public AttackStepTechnique withAttackStepTechniqueDescription( StructuredTextType value) { setAttackStepTechniqueDescription(value); return this; } public AttackStepTechnique withLeveragedAttackPatterns( AttackStepTechnique.LeveragedAttackPatterns value) { setLeveragedAttackPatterns(value); return this; } public AttackStepTechnique withRelevantAttackSurfaceElements( RelevantAttackSurfaceElementsType value) { setRelevantAttackSurfaceElements(value); return this; } public AttackStepTechnique withObservables(Observables value) { setObservables(value); return this; } public AttackStepTechnique withEnvironments(Object... values) { if (values != null) { for (Object value : values) { getEnvironments().add(value); } } return this; } public AttackStepTechnique withEnvironments(Collection values) { if (values != null) { getEnvironments().addAll(values); } return this; } public AttackStepTechnique withID(BigInteger value) { setID(value); return this; } public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); } public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; } public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { { StructuredTextType theAttackStepTechniqueDescription; theAttackStepTechniqueDescription = this .getAttackStepTechniqueDescription(); strategy.appendField(locator, this, "attackStepTechniqueDescription", buffer, theAttackStepTechniqueDescription); } { AttackStepTechnique.LeveragedAttackPatterns theLeveragedAttackPatterns; theLeveragedAttackPatterns = this.getLeveragedAttackPatterns(); strategy.appendField(locator, this, "leveragedAttackPatterns", buffer, theLeveragedAttackPatterns); } { RelevantAttackSurfaceElementsType theRelevantAttackSurfaceElements; theRelevantAttackSurfaceElements = this .getRelevantAttackSurfaceElements(); strategy.appendField(locator, this, "relevantAttackSurfaceElements", buffer, theRelevantAttackSurfaceElements); } { Observables theObservables; theObservables = this.getObservables(); strategy.appendField(locator, this, "observables", buffer, theObservables); } { List theEnvironments; theEnvironments = (((this.environments != null) && (!this.environments .isEmpty())) ? this.getEnvironments() : null); strategy.appendField(locator, this, "environments", buffer, theEnvironments); } { BigInteger theID; theID = this.getID(); strategy.appendField(locator, this, "id", buffer, theID); } return buffer; } /** *

Java class for anonymous complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

	 * <complexType>
	 *   <complexContent>
	 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
	 *       <sequence>
	 *         <element name="Leveraged_Attack_Pattern_ID" type="{http://www.w3.org/2001/XMLSchema}anyType" maxOccurs="unbounded"/>
	 *       </sequence>
	 *     </restriction>
	 *   </complexContent>
	 * </complexType>
	 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "leveragedAttackPatternIDs" }) public static class LeveragedAttackPatterns implements Equals, HashCode, ToString { @XmlElement(name = "Leveraged_Attack_Pattern_ID", required = true) protected List leveragedAttackPatternIDs; /** * Default no-arg constructor * */ public LeveragedAttackPatterns() { super(); } /** * Fully-initialising value constructor * */ public LeveragedAttackPatterns( final List leveragedAttackPatternIDs) { this.leveragedAttackPatternIDs = leveragedAttackPatternIDs; } /** * Gets the value of the leveragedAttackPatternIDs property. * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the leveragedAttackPatternIDs property. * *

* For example, to add a new item, do as follows: *

		 *    getLeveragedAttackPatternIDs().add(newItem);
		 * 
* * *

* Objects of the following type(s) are allowed in the list * {@link Object } * * */ public List getLeveragedAttackPatternIDs() { if (leveragedAttackPatternIDs == null) { leveragedAttackPatternIDs = new ArrayList(); } return this.leveragedAttackPatternIDs; } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof AttackStepTechnique.LeveragedAttackPatterns)) { return false; } if (this == object) { return true; } final AttackStepTechnique.LeveragedAttackPatterns that = ((AttackStepTechnique.LeveragedAttackPatterns) object); { List lhsLeveragedAttackPatternIDs; lhsLeveragedAttackPatternIDs = (((this.leveragedAttackPatternIDs != null) && (!this.leveragedAttackPatternIDs .isEmpty())) ? this.getLeveragedAttackPatternIDs() : null); List rhsLeveragedAttackPatternIDs; rhsLeveragedAttackPatternIDs = (((that.leveragedAttackPatternIDs != null) && (!that.leveragedAttackPatternIDs .isEmpty())) ? that.getLeveragedAttackPatternIDs() : null); if (!strategy.equals(LocatorUtils.property(thisLocator, "leveragedAttackPatternIDs", lhsLeveragedAttackPatternIDs), LocatorUtils.property( thatLocator, "leveragedAttackPatternIDs", rhsLeveragedAttackPatternIDs), lhsLeveragedAttackPatternIDs, rhsLeveragedAttackPatternIDs)) { return false; } } return true; } public boolean equals(Object object) { final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); } public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { List theLeveragedAttackPatternIDs; theLeveragedAttackPatternIDs = (((this.leveragedAttackPatternIDs != null) && (!this.leveragedAttackPatternIDs .isEmpty())) ? this.getLeveragedAttackPatternIDs() : null); currentHashCode = strategy.hashCode(LocatorUtils.property( locator, "leveragedAttackPatternIDs", theLeveragedAttackPatternIDs), currentHashCode, theLeveragedAttackPatternIDs); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } public AttackStepTechnique.LeveragedAttackPatterns withLeveragedAttackPatternIDs( Object... values) { if (values != null) { for (Object value : values) { getLeveragedAttackPatternIDs().add(value); } } return this; } public AttackStepTechnique.LeveragedAttackPatterns withLeveragedAttackPatternIDs( Collection values) { if (values != null) { getLeveragedAttackPatternIDs().addAll(values); } return this; } public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); } public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; } public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { { List theLeveragedAttackPatternIDs; theLeveragedAttackPatternIDs = (((this.leveragedAttackPatternIDs != null) && (!this.leveragedAttackPatternIDs .isEmpty())) ? this.getLeveragedAttackPatternIDs() : null); strategy.appendField(locator, this, "leveragedAttackPatternIDs", buffer, theLeveragedAttackPatternIDs); } return buffer; } } /** * Returns A Document representation of this instance that is not formatted. * * @return The Document representation for this instance. */ public org.w3c.dom.Document toDocument() { return toDocument(false); } /** * Returns A Document representation for this instance. * * @param prettyPrint * True for pretty print, otherwise false * * @return The Document representation for this instance. */ public org.w3c.dom.Document toDocument(boolean prettyPrint) { return DocumentUtilities.toDocument(toJAXBElement(), prettyPrint); } /** * Returns JAXBElement for this instance. * * @return The JAXBElement for this instance. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public JAXBElement toJAXBElement() { QName qualifiedName = STIXSchema.getQualifiedName(this); return new JAXBElement(qualifiedName, AttackStepTechnique.class, this); } /** * Returns String representation of this instance that is not formatted. * * @return The String containing the XML mark-up. */ public String toXMLString() { return toXMLString(false); } /** * Returns XML String for JAXB Document Object Model object. * * @param prettyPrint * True for pretty print, otherwise false * * @return The String containing the XML mark-up. */ public String toXMLString(boolean prettyPrint) { return DocumentUtilities.toXMLString(toDocument(), prettyPrint); } /** * Creates AttackStepTechnique instance for XML String * * @param text * XML String for the document * @return The AttackStepTechnique instance for the passed XML String */ public static AttackStepTechnique fromXMLString(String text) { JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(AttackStepTechnique.class .getPackage().getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(STIXSchema.getInstance().getSchema()); unmarshaller.setEventHandler(new ValidationEventHandler()); StreamSource streamSource = new StreamSource(new StringReader(text)); return (AttackStepTechnique) unmarshaller.unmarshal(streamSource); } catch (JAXBException e) { throw new RuntimeException(e); } } /** * Validates the XML representation of this AttackStepTechnique instance * Returning true indicating a successful validation, false if not. * * @return boolean True If it validates against the schema * @throws SAXException * If the a validation ErrorHandler has not been set, and * validation throws a SAXException */ public boolean validate() throws SAXException { return STIXSchema.getInstance().validate(toXMLString()); } }