keyvalue

package
v0.0.0-...-dba5c58 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2013 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Package keyvalue

import "github.com/kugutsumen/encoding/keyvalue"

Overview

Package keyvalue implements the Key-Value Form Encoding as specified by the OpenID Authentication 2.0 specifications.

Key-Value Form encoding is used for signature calculation and for direct responses to Relying Parties.

A message in Key-Value form is a sequence of lines. Each line begins with a key, followed by a colon, and the value associated with the key. The line is terminated by a single newline (UCS codepoint 10, "\n").

Example:

mode:error
error:This is an example message

Install

go get github.com/kugutsumen/encoding/keyvalue

If this is not the first time you're "getting" the package, add -u param to get an updated version, i.e. go get -u ....

Doc

Documentation

Overview

Package keyvalue implements the Key-Value Form Encoding as specified by the OpenID Authentication 2.0 specifications.

http://openid.net/specs/openid-authentication-2_0.html#rfc.section.4.1.1

Key-Value Form encoding is used for signature calculation and for direct responses to Relying Parties.

A message in Key-Value form is a sequence of lines. Each line begins with a key, followed by a colon, and the value associated with the key. The line is terminated by a single newline (UCS codepoint 10, "\n").

Example:

mode:error
error:This is an example message

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingFields = fmt.Errorf("No fields to sign")
	ErrEmptyForm     = fmt.Errorf("Form is empty or values are missing.")
)

Functions

This section is empty.

Types

type Form

type Form map[string]string

Form maps a string key to a string value.

func (Form) Del

func (f Form) Del(key string)

Del deletes the value associated with key.

func (Form) Get

func (f Form) Get(key string) string

Get gets the value associated with the given key.

If there are no value associated with the key, Get returns the empty string.

func (Form) Set

func (f Form) Set(key, value string)

Set sets the key to value. It replaces any existing value.

func (Form) String

func (f Form) String() string

String returns the Key-Value Form Encoded message.

func (Form) Validate

func (f Form) Validate() error

Validate Key-Value message. Additional characters, including whitespace, MUST NOT be added before or after the colon or newline.

The message MUST be encoded in UTF-8 to produce a byte string.

func (Form) Write

func (f Form) Write(w io.Writer) error

type SignedForm

type SignedForm struct {
	Form
	// List of fields to be signed without the "openid." prefix that the signature covers.
	Fields []string
}

Signed message in key-value form.

func (*SignedForm) SignedFields

func (s *SignedForm) SignedFields() string

Comma-separated list of signed fields

func (*SignedForm) SignedString

func (s *SignedForm) SignedString() string

Convert the list of key/value pairs to be signed to an octet string by encoding with Key-Value Form Encoding.

Jump to

Keyboard shortcuts

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