cap

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2019 License: BSD-2-Clause Imports: 5 Imported by: 0

README

cap - Common Alerting Protocol Version 1.2 (CAP)

Build Status Go Report Card GoDoc GitHub license

Package cap is the Go implementation of OASIS Common Alerting Protocol Version 1.2 (CAP) + Canadian Profile (CAP-CP).

Usage

The cap package exposes the function ParseCAP. This takes a valid XML CAP 1.2 message as []byte and returns an Alert struct. All fields defined within the Common Alerting Protocol are present in Alert. If the XML data is not valid, an error will be returned.

For all available fields, please see the godoc. Here is a simple example of reading the alert headline.

package main

import (
    "fmt"
    "io/ioutil"

    "github.com/thetannerryan/cap"
)

func main() {
    contents, _ := ioutil.ReadFile("alert.xml")
    alert, err := cap.ParseCAP(contents)
    if err != nil {
        panic(err)
    }
    // print the alert headline
    fmt.Println(alert.Info[0].Headline)
}

License

Copyright (c) 2019 Tanner Ryan. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

The names "OASIS" and “CAP” are trademarks of OASIS, the owner and developer of this specification. Copyright (c) 2010 OASIS. All rights reserved.

Documentation

Overview

Package cap is the Go implementation of OASIS Common Alerting Protocol Version 1.2 (CAP) + Canadian Profile (CAP-CP).

Usage

The cap package exposes the function `ParseCAP`. This takes a valid XML CAP 1.2 message as `[]byte` and returns an `Alert` struct. All fields defined within the Common Alerting Protocol are present in `Alert`. If the XML data is not valid, an error will be returned.

Here is a simple example of reading the alert headline.

package main

import (
    "fmt"
    "io/ioutil"

    "github.com/thetannerryan/cap"
)

func main() {
    contents, _ := ioutil.ReadFile("alert.xml")
    alert, err := cap.ParseCAP(contents)
    if err != nil {
        panic(err)
    }
    // print the alert headline
    fmt.Println(alert.Info[0].Headline)
}

License

Copyright (c) 2019 Tanner Ryan. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

The names "OASIS" and “CAP” are trademarks of OASIS, the owner and developer of this specification. Copyright (c) 2010 OASIS. All rights reserved.

Index

Constants

This section is empty.

Variables

View Source
var (
	CategoryMapping = map[string]Category{
		"Geo":       CategoryGeo,
		"Met":       CategoryMet,
		"Safety":    CategorySafety,
		"Security":  CategorySecurity,
		"Rescue":    CategoryRescue,
		"Fire":      CategoryFire,
		"Health":    CategoryHealth,
		"Env":       CategoryEnv,
		"Transport": CategoryTransport,
		"Infra":     CategoryInfra,
		"CBRNE":     CategoryCBRNE,
		"Other":     CategoryOther,
	}
)

Category mapping

View Source
var (
	CertaintyMapping = map[string]Certainty{
		"Observed": CertaintyObserved,
		"Likely":   CertaintyLikely,
		"Possible": CertaintyPossible,
		"Unlikely": CertaintyUnlikely,
		"Unknown":  CertaintyUnknown,
	}
)

Certainty mapping

View Source
var (
	MsgTypeMapping = map[string]MsgType{
		"Alert":  MsgTypeAlert,
		"Update": MsgTypeUpdate,
		"Cancel": MsgTypeCancel,
		"Ack":    MsgTypeAck,
		"Error":  MsgTypeError,
	}
)

MsgType mapping

View Source
var (
	ResponseTypeMapping = map[string]ResponseType{
		"Shelter":  ResponseTypeShelter,
		"Evacuate": ResponseTypeEvacuate,
		"Prepare":  ResponseTypePrepare,
		"Execute":  ResponseTypeExecute,
		"Avoid":    ResponseTypeAvoid,
		"Monitor":  ResponseTypeMonitor,
		"Assess":   ResponseTypeAssess,
		"AllClear": ResponseTypeAllClear,
		"None":     ResponseTypeNone,
	}
)

ResponseType mapping

View Source
var (
	ScopeMapping = map[string]Scope{
		"Public":     ScopePublic,
		"Restricted": ScopeRestricted,
		"Private":    ScopePrivate,
	}
)

Scope mapping

View Source
var (
	SeverityMapping = map[string]Severity{
		"Extreme":  SeverityExtreme,
		"Severe":   SeveritySevere,
		"Moderate": SeverityModerate,
		"Minor":    SeverityMinor,
		"Unknown":  SeverityUnknown,
	}
)

Severity mapping

View Source
var (
	StatusMapping = map[string]Status{
		"Actual":   StatusActual,
		"Exercise": StatusExercise,
		"System":   StatusSystem,
		"Test":     StatusTest,
		"Draft":    StatusDraft,
	}
)

Status mapping

View Source
var (
	UrgencyMapping = map[string]Urgency{
		"Immediate": UrgencyImmediate,
		"Expected":  UrgencyExpected,
		"Future":    UrgencyFuture,
		"Past":      UrgencyPast,
		"Unknown":   UrgencyUnknown,
	}
)

Urgency mapping

Functions

This section is empty.

Types

type Alert

type Alert struct {
	XMLName xml.Name `xml:"urn:oasis:names:tc:emergency:cap:1.2 alert" json:"alert"` // Reference CAP URN (REQUIRED)

	Identifier  string   `xml:"identifier" json:"identifier"`   // Identifier of the alert message (REQUIRED)
	Sender      string   `xml:"sender" json:"sender"`           // Identifier of the sender of the alert message (REQUIRED)
	Sent        DateTime `xml:"sent" json:"sent"`               // Time and date of the origination of the alert message (REQUIRED)
	Status      Status   `xml:"status" json:"status"`           // Code denoting the appropriate handling of the alert message (REQUIRED)
	MsgType     MsgType  `xml:"msgType" json:"msgType"`         // Code denoting the nature of the alert message (REQUIRED)
	Source      string   `xml:"source" json:"source"`           // Text identifying the source of the alert message
	Scope       Scope    `xml:"scope" json:"scope"`             // Code denoting the intended distribution of the alert message (REQUIRED)
	Restriction string   `xml:"restriction" json:"restriction"` // Text describing the rule for limiting the distribution of the restricted alert message (CONDITIONAL)
	Addresses   string   `xml:"addresses" json:"addresses"`     // Group listing of intended recipients of the alert message (CONDITIONAL)
	Code        []string `xml:"code" json:"code"`               // Code denoting special handling of the alert message
	Note        string   `xml:"note" json:"note"`               // Text describing the purpose or significance of the alert message
	References  List     `xml:"references" json:"references"`   // Group listing identifying earlier message(s) reference by the alert message
	Incidents   string   `xml:"incidents" json:"incidents"`     // Group listing naming the referent incident(s) of the alert message

	Info      []Info      `xml:"info" json:"info"`           // Container for all component parts of the info sub-element of the alert message
	Signature []Signature `xml:"Signature" json:"signature"` // Standard XML Digital Signature, not originally defined in CAP, used in CAP-CP and NAADS
}

Alert provides basic information about the current message: its purpose, its source and its status, as well as a unique identifier for the current message and links to any other, related messages. An Alert struct may be used alone for message acknowledgements, cancellations or other system functions, but most Alert struct will include at least one Info struct.

func ParseCAP

func ParseCAP(data []byte) (*Alert, error)

ParseCAP takes a valid XML byte CAP 1.2 message and returns an Alert. If the message is invalid, an error will be returned.

type Algorithm

type Algorithm struct {
	Algorithm string `xml:"Algorithm,attr" json:"algorithm"`
}

Algorithm is required to access algorithm definitions within the XML digital signature specification.

type Area

type Area struct {
	XMLName xml.Name `xml:"area" json:"area"` // Area CAP

	AreaDesc string     `xml:"areaDesc" json:"areaDesc"` // Text describing the affected area of the alert message (REQUIRED)
	Polygon  List       `xml:"polygon" json:"polygon"`   // Paired values of points defining a polygon that delineates the affected area of the alert message
	Circle   []string   `xml:"circle" json:"circle"`     // Paired values of a point and radius delineating the affected area of the alert message
	Geocode  []KeyValue `xml:"geocode" json:"geocode"`   // Geographic code delineating the affected area of the alert message
	Altitude float32    `xml:"altitude" json:"altitude"` // Specific or minimum altitude of the affected area of the alert message
	Ceiling  float32    `xml:"ceiling" json:"ceiling"`   // Maximum altitude of the affected area of the alert message (CONDITIONAL)
}

Area struct describes a geographic area to which the Info struct in which it appears applies. Textual and coded descriptions (such as postal codes) are supported, but the preferred representations use geospatial shapes (polygons and circles) and an altitude or altitude range, expressed in standard latitude / longitude / altitude terms in accordance with a specified geospatial datum.

type Category

type Category int

Category is a code denoting the appropriate handling of the alert message

const (
	// CategoryGeo :: Geophysical (inc. landslide)
	CategoryGeo Category = 0
	// CategoryMet :: Meteorological (inc. flood)
	CategoryMet Category = 1
	// CategorySafety :: General emergency and public safety
	CategorySafety Category = 2
	// CategorySecurity :: Law enforcement, military, homeland and local/private
	// security
	CategorySecurity Category = 3
	// CategoryRescue :: Rescue and recovery
	CategoryRescue Category = 4
	// CategoryFire :: Fire suppression and rescue
	CategoryFire Category = 5
	// CategoryHealth :: Medical and public health
	CategoryHealth Category = 6
	// CategoryEnv :: Pollution and other environmental
	CategoryEnv Category = 7
	// CategoryTransport :: Public and private transportation
	CategoryTransport Category = 8
	// CategoryInfra :: Utility, telecommunication, other non-transport
	// infrastructure
	CategoryInfra Category = 9
	// CategoryCBRNE :: Chemical, Biological, Radiological, Nuclear or
	// High-Yield Explosive threat or attack
	CategoryCBRNE Category = 10
	// CategoryOther :: Other events
	CategoryOther Category = 11
)

func (Category) MarshalJSON

func (t Category) MarshalJSON() ([]byte, error)

MarshalJSON converts the Category code back to a string when marshaling JSON.

func (Category) MarshalXML

func (t Category) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Category code back to a string when marshaling XML.

func (Category) String

func (t Category) String() string

String converts the Category code back to a string.

func (*Category) UnmarshalJSON

func (t *Category) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Category code.

func (*Category) UnmarshalXML

func (t *Category) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Category code.

type Certainty

type Certainty int

Certainty is a code denoting the appropriate handling of the alert message

const (
	// CertaintyObserved :: Determined to have occurred or to be ongoing
	CertaintyObserved Certainty = 0
	// CertaintyLikely :: Likely (p > ~50%)
	CertaintyLikely Certainty = 1
	// CertaintyPossible :: Possible but not likely (p <= ~50%)
	CertaintyPossible Certainty = 2
	// CertaintyUnlikely :: Not expected to occur (p ~ 0)
	CertaintyUnlikely Certainty = 3
	// CertaintyUnknown :: Certainty unknown
	CertaintyUnknown Certainty = 4
)

func (Certainty) MarshalJSON

func (t Certainty) MarshalJSON() ([]byte, error)

MarshalJSON converts the Certainty code back to a string when marshaling JSON.

func (Certainty) MarshalXML

func (t Certainty) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Certainty code back to a string when marshaling XML.

func (Certainty) String

func (t Certainty) String() string

String converts the Certainty code back to a string.

func (*Certainty) UnmarshalJSON

func (t *Certainty) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Certainty code.

func (*Certainty) UnmarshalXML

func (t *Certainty) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Certainty code.

type DateTime

type DateTime struct {
	// contains filtered or unexported fields
}

DateTime is to represent a time field in an Alert

func (DateTime) MarshalJSON

func (t DateTime) MarshalJSON() ([]byte, error)

MarshalJSON converts the DateTime back to a string when marshaling JSON.

func (DateTime) MarshalXML

func (t DateTime) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the DateTime back to a string when marshaling XML.

func (DateTime) String

func (t DateTime) String() string

String returns the XML dateTime representation of the DateTime

func (*DateTime) Time

func (t *DateTime) Time() time.Time

Time returns a standard time struct for the DateTime

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to DateTime.

func (*DateTime) UnmarshalXML

func (t *DateTime) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to DateTime.

type Info

type Info struct {
	XMLName xml.Name `xml:"info"` // Info CAP

	Language     string         `xml:"language" json:"language"`         // Code denoting the language of the info sub-element of the alert message
	Category     []Category     `xml:"category" json:"category"`         // Code denoting the category of the subject event of the alert message (REQUIRED)
	Event        string         `xml:"event" json:"event"`               // Text denoting the type of the subject event of the alert message (REQUIRED)
	ResponseType []ResponseType `xml:"responseType" json:"responseType"` // Code denoting the type of action recommended for the target audience
	Urgency      Urgency        `xml:"urgency" json:"urgency"`           // Code denoting the urgency of the subject event of the alert message (REQUIRED)
	Severity     Severity       `xml:"severity" json:"severity"`         // Code denoting the severity of the subject event of the alert message (REQUIRED)
	Certainty    Certainty      `xml:"certainty" json:"certainty"`       // Code denoting the certainty of the subject event of the alert message (REQUIRED)
	Audience     string         `xml:"audience" json:"audience"`         // Text describing the intended audience of the alert message
	EventCode    []KeyValue     `xml:"eventCode" json:"eventCode"`       // System-specific code identifying the event type of the alert message
	Effective    DateTime       `xml:"effective" json:"effective"`       // Effective time of the information of the alert message
	Onset        DateTime       `xml:"onset" json:"onset"`               // Expected time of the beginning of the subject event of the alert message
	Expires      DateTime       `xml:"expires" json:"expires"`           // Expiry time of the information of the alert message
	SenderName   string         `xml:"senderName" json:"senderName"`     // Text naming the originator of the alert message
	Headline     string         `xml:"headline" json:"headline"`         // Text headline of the alert message
	Description  string         `xml:"description" json:"description"`   // Text describing the subject event of the alert message
	Instruction  string         `xml:"instruction" json:"instruction"`   // Text describing the recommended action to be taken by recipients of the alert message
	Web          string         `xml:"web" json:"web"`                   // Identifier of the hyperlink associating additional information with the alert message
	Contact      string         `xml:"contact" json:"contact"`           // Text describing the contact for follow-up and confirmation of the alert message
	Parameter    []KeyValue     `xml:"parameter" json:"parameter"`       // System-specific additional parameter associated with the alert message

	Resource []Resource `xml:"resource" json:"resource"` // Container for all component parts of the resource sub-element of the info sub-element of the alert element
	Area     []Area     `xml:"area" json:"area"`         // Container for all component parts of the area sub-element of the info sub-element of the alert message
}

Info struct describes an anticipated or actual event in terms of its urgency (time available to prepare), severity (intensity of impact) and certainty (confidence in the observation or prediction), as well as providing both categorical and textual descriptions of the subject event. It may also provide instructions for appropriate response by message recipients and various other details (hazard duration, technical parameters, contact information, links to additional information sources, etc.) Multiple Info structs may be used to describe differing parameters (e.g., for different probability or intensity “bands”) or to provide the information in multiple languages.

type KeyValue

type KeyValue struct {
	ValueName string `xml:"valueName" json:"valueName"`
	Value     string `xml:"value" json:"value"`
}

KeyValue is a generic element for representing key-value pairs

type List

type List struct {
	// contains filtered or unexported fields
}

List is to represent delimited string values

func (List) MarshalJSON

func (t List) MarshalJSON() ([]byte, error)

MarshalJSON converts the List back to a string when marshaling JSON.

func (List) MarshalXML

func (t List) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the List back to a string when marshaling XML.

func (*List) String

func (t *List) String() string

String returns the a joined string representation of the values, delimited with the listDelimeter.

func (*List) UnmarshalJSON

func (t *List) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to List.

func (*List) UnmarshalXML

func (t *List) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to List.

func (*List) Values

func (t *List) Values() []string

Values returns a standard string slice .

type MsgType

type MsgType int

MsgType is a code denoting the appropriate handling of the alert message

const (
	// MsgTypeAlert :: Initial information requiring attention by targeted
	// recipients
	MsgTypeAlert MsgType = 0
	// MsgTypeUpdate :: Updates and supercedes the earlier message(s) identified
	// in References
	MsgTypeUpdate MsgType = 1
	// MsgTypeCancel :: Cancels the earlier message(s) identified in References
	MsgTypeCancel MsgType = 2
	// MsgTypeAck :: Acknowledges receipt and acceptance of the message(s)
	// identified in References
	MsgTypeAck MsgType = 3
	// MsgTypeError :: Indicates rejection of the message(s) identified in
	// References; explanation SHOULD appear in Note
	MsgTypeError MsgType = 4
)

func (MsgType) MarshalJSON

func (t MsgType) MarshalJSON() ([]byte, error)

MarshalJSON converts the MsgType code back to a string when marshaling JSON.

func (MsgType) MarshalXML

func (t MsgType) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the MsgType code back to a string when marshaling XML.

func (MsgType) String

func (t MsgType) String() string

String converts the MsgType code back to a string.

func (*MsgType) UnmarshalJSON

func (t *MsgType) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to MsgType code.

func (*MsgType) UnmarshalXML

func (t *MsgType) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to MsgType code.

type Reference

type Reference struct {
	URI          string    `xml:"URI,attr" json:"uri"`
	Transform    Algorithm `xml:"Transforms>Transform" json:"transform"`
	DigestMethod Algorithm `xml:"DigestMethod" json:"digestMethod"`
	DigestValue  string    `xml:"DigestValue" json:"digestValue"`
}

Reference elements specify the resource being signed by URI reference and any transforms to be applied to the resource prior to signing.

type Resource

type Resource struct {
	XMLName xml.Name `xml:"resource" json:"resource"` // Resouce CAP

	ResourceDesc string `xml:"resourceDesc" json:"resourceDesc"` // Text describing the type and content of the resource file (REQUIRED)
	MimeType     string `xml:"mimeType" json:"mimeType"`         // Identifier of the MIME content type and sub-type describing the resource file (REQUIRED)
	Size         int    `xml:"size" json:"size"`                 // Integer indicating the size of the resource file
	URI          string `xml:"uri" json:"uri"`                   // Identifier of the hyperlink for the resource file
	DerefURI     string `xml:"derefUri" json:"derefUri"`         // Base-64 encoded data content of the resource file (CONDITIONAL)
	Digest       string `xml:"digest" json:"digest"`             // Code representing the digital digest ("hash") computed from the resource file

}

Resource struct provides an optional reference to additional information related to the Info struct within which it appears in the form of a digital asset such as an image or audio file.

type ResponseType

type ResponseType int

ResponseType is a code denoting the appropriate handling of the alert message

const (
	// ResponseTypeShelter :: Take shelter in place or per Instruction
	ResponseTypeShelter ResponseType = 0
	// ResponseTypeEvacuate :: Relocate as instructed in the Instruction
	ResponseTypeEvacuate ResponseType = 1
	// ResponseTypePrepare :: Make preparations per the Instruction
	ResponseTypePrepare ResponseType = 2
	// ResponseTypeExecute :: Execute a pre-planned activity identified in
	// Instruction
	ResponseTypeExecute ResponseType = 3
	// ResponseTypeAvoid :: Avoid the subject event as per the Instruction
	ResponseTypeAvoid ResponseType = 4
	// ResponseTypeMonitor :: Attend to information sources as described in
	// Instruction
	ResponseTypeMonitor ResponseType = 5
	// ResponseTypeAssess :: Evaluate the information in this message.  (This
	// value SHOULD NOT be used in public warning applications.)
	ResponseTypeAssess ResponseType = 6
	// ResponseTypeAllClear :: The subject event no longer poses a threat or
	// concern and any follow on action is described in Instruction
	ResponseTypeAllClear ResponseType = 7
	// ResponseTypeNone :: No action recommended
	ResponseTypeNone ResponseType = 8
)

func (ResponseType) MarshalJSON

func (t ResponseType) MarshalJSON() ([]byte, error)

MarshalJSON converts the ResponseType code back to a string when marshaling JSON.

func (ResponseType) MarshalXML

func (t ResponseType) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the ResponseType code back to a string when marshaling XML.

func (ResponseType) String

func (t ResponseType) String() string

String converts the ResponseType code back to a string.

func (*ResponseType) UnmarshalJSON

func (t *ResponseType) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to ResponseType code.

func (*ResponseType) UnmarshalXML

func (t *ResponseType) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to ResponseType code.

type Scope

type Scope int

Scope is a code denoting the appropriate handling of the alert message

const (
	// ScopePublic :: For general dissemination to unrestricted audiences
	ScopePublic Scope = 0
	// ScopeRestricted :: For dissemination only to users with a known
	// operational requirement (see Restriction, below)
	ScopeRestricted Scope = 1
	// ScopePrivate :: For dissemination only to specified addresses (see
	// Addresses, below)
	ScopePrivate Scope = 2
)

func (Scope) MarshalJSON

func (t Scope) MarshalJSON() ([]byte, error)

MarshalJSON converts the Scope code back to a string when marshaling JSON.

func (Scope) MarshalXML

func (t Scope) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Scope code back to a string when marshaling XML.

func (Scope) String

func (t Scope) String() string

String converts the Scope code back to a string.

func (*Scope) UnmarshalJSON

func (t *Scope) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Scope code.

func (*Scope) UnmarshalXML

func (t *Scope) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Scope code.

type Severity

type Severity int

Severity is a code denoting the appropriate handling of the alert message

const (
	// SeverityExtreme :: Extraordinary threat to life or property
	SeverityExtreme Severity = 0
	// SeveritySevere :: Significant threat to life or property
	SeveritySevere Severity = 1
	// SeverityModerate :: Possible threat to life or property
	SeverityModerate Severity = 2
	// SeverityMinor :: Minimal to no known threat to life or property
	SeverityMinor Severity = 3
	// SeverityUnknown :: Severity unknown
	SeverityUnknown Severity = 4
)

func (Severity) MarshalJSON

func (t Severity) MarshalJSON() ([]byte, error)

MarshalJSON converts the Severity code back to a string when marshaling JSON.

func (Severity) MarshalXML

func (t Severity) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Severity code back to a string when marshaling XML.

func (Severity) String

func (t Severity) String() string

String converts the Severity code back to a string.

func (*Severity) UnmarshalJSON

func (t *Severity) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Severity code.

func (*Severity) UnmarshalXML

func (t *Severity) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Severity code.

type Signature

type Signature struct {
	XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature" json:"signature"`

	ID                  string              `xml:"Id,attr" json:"id"`
	SignedInfo          SignedInfo          `xml:"SignedInfo" json:"signedInfo"`
	SignatureValue      string              `xml:"SignatureValue" json:"signatureValue"`
	X509Certificate     string              `xml:"KeyInfo>X509Data>X509Certificate" json:"x509Certificate"`
	SignatureProperties []SignatureProperty `xml:"Object>SignatureProperties>SignatureProperty" json:"signatureProperty"`
}

Signature is a standard XML digital signature. This is not included in the original CAP protocol, but is implemented in CAP-CP and is enforced in Pelmorex's National Alert Aggregation & Dissemination System (NAADS).

type SignatureProperty

type SignatureProperty struct {
	ID      string  `xml:"Id,attr" json:"id"`
	Target  string  `xml:"Target,attr" json:"target"`
	XCValue XCValue `xml:"value" json:"value"`
}

SignatureProperty is the simplified Object element that contains the signed data for the enveloping signature.

type SignedInfo

type SignedInfo struct {
	CanonicalizationMethod Algorithm `xml:"CanonicalizationMethod" json:"canonicalizationMethod"`
	SignatureMethod        Algorithm `xml:"SignatureMethod" json:"signatureMethod"`
	Reference              Reference `xml:"Reference" json:"reference"`
}

SignedInfo elements references the signed data and specifies what algorithms are used.

type Status

type Status int

Status is a code denoting the appropriate handling of the alert message

const (
	// StatusActual :: Actionable by all targeted recipients
	StatusActual Status = 0
	// StatusExercise :: Actionable only by designated exercise participants;
	// exercise identifier SHOULD appear in Note
	StatusExercise Status = 1
	// StatusSystem :: For messages that support alert network internal
	// functions
	StatusSystem Status = 2
	// StatusTest :: Technical testing only, all recipients disregard
	StatusTest Status = 3
	// StatusDraft :: A preliminary template or draft, not actionable in its
	// current form
	StatusDraft Status = 4
)

func (Status) MarshalJSON

func (t Status) MarshalJSON() ([]byte, error)

MarshalJSON converts the Status code back to a string when marshaling JSON.

func (Status) MarshalXML

func (t Status) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Status code back to a string when marshaling XML.

func (Status) String

func (t Status) String() string

String converts the Status code back to a string.

func (*Status) UnmarshalJSON

func (t *Status) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Status code.

func (*Status) UnmarshalXML

func (t *Status) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Status code.

type Urgency

type Urgency int

Urgency is a code denoting the appropriate handling of the alert message

const (
	// UrgencyImmediate :: Responsive action SHOULD be taken immediately
	UrgencyImmediate Urgency = 0
	// UrgencyExpected :: Responsive action SHOULD be taken soon (within next
	// hour)
	UrgencyExpected Urgency = 1
	// UrgencyFuture :: Responsive action SHOULD be taken soon (within next
	// hour)
	UrgencyFuture Urgency = 2
	// UrgencyPast ::  Responsive action is no longer required
	UrgencyPast Urgency = 3
	// UrgencyUnknown :: Urgency not known
	UrgencyUnknown Urgency = 4
)

func (Urgency) MarshalJSON

func (t Urgency) MarshalJSON() ([]byte, error)

MarshalJSON converts the Urgency code back to a string when marshaling JSON.

func (Urgency) MarshalXML

func (t Urgency) MarshalXML(encoder *xml.Encoder, elem xml.StartElement) error

MarshalXML converts the Urgency code back to a string when marshaling XML.

func (Urgency) String

func (t Urgency) String() string

String converts the Urgency code back to a string.

func (*Urgency) UnmarshalJSON

func (t *Urgency) UnmarshalJSON(buff []byte) error

UnmarshalJSON will be used during the JSON unmarshaling for conversion to Urgency code.

func (*Urgency) UnmarshalXML

func (t *Urgency) UnmarshalXML(decoder *xml.Decoder, elem xml.StartElement) error

UnmarshalXML will be used during the XML unmarshaling for conversion to Urgency code.

type XCValue

type XCValue struct {
	XC string `xml:"xc,attr" json:"xc"`
}

XCValue is required to access the value of the SignatureProperty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL