# Poco::Net

# class HTTPAuthenticationParams

Library: Net
Package: HTTP
Header: Poco/Net/HTTPAuthenticationParams.h

## Description

Collection of name-value pairs of HTTP authentication header (i.e. "realm", "qop", "nonce" in case of digest authentication header).

For NTLM, the base64-encoded NTLM message is available from the "NTLM" property.

## Inheritance

Direct Base Classes: NameValueCollection

All Base Classes: NameValueCollection

## Member Summary

Member Functions: fromAuthInfo, fromRequest, fromResponse, getRealm, operator =, setRealm, toString

Inherited Functions: add, begin, clear, empty, end, erase, find, get, has, operator =, operator [], secureClear, secureErase, set, size, swap

## Constructors

### HTTPAuthenticationParams

HTTPAuthenticationParams();

Creates an empty authentication parameters collection.

### HTTPAuthenticationParams

explicit HTTPAuthenticationParams(
const std::string & authInfo
);

See fromAuthInfo() documentation.

### HTTPAuthenticationParams

explicit HTTPAuthenticationParams(
const HTTPRequest & request
);

See fromRequest() documentation.

### HTTPAuthenticationParams

HTTPAuthenticationParams(
const HTTPResponse & response,
const std::string & header = WWW_AUTHENTICATE
);

See fromResponse() documentation.

## Destructor

### ~HTTPAuthenticationParams

virtual ~HTTPAuthenticationParams();

Destroys the HTTPAuthenticationParams.

## Member Functions

### fromAuthInfo

void fromAuthInfo(
const std::string & authInfo
);

Creates an HTTPAuthenticationParams by parsing authentication information.

### fromRequest

void fromRequest(
const HTTPRequest & request
);

Extracts authentication information from the request and creates HTTPAuthenticationParams by parsing it.

Throws a NotAuthenticatedException if no authentication information is contained in request. Throws a InvalidArgumentException if authentication scheme is unknown or invalid.

### fromResponse

void fromResponse(
const HTTPResponse & response,
const std::string & header = WWW_AUTHENTICATE
);

Extracts authentication information from the response and creates HTTPAuthenticationParams by parsing it.

Throws a NotAuthenticatedException if no authentication information is contained in response. Throws a InvalidArgumentException if authentication scheme is unknown or invalid.

### getRealm

const std::string & getRealm() const;

Returns value of the "realm" parameter.

Throws NotFoundException is there is no "realm" set in the HTTPAuthenticationParams.

### operator =

HTTPAuthenticationParams & operator = (
const HTTPAuthenticationParams & authParams
);

Assigns the content of another HTTPAuthenticationParams.

### setRealm

void setRealm(
const std::string & realm
);

Sets the "realm" parameter to the provided string.

### toString

std::string toString() const;

Formats the HTTPAuthenticationParams for inclusion in HTTP request or response authentication header.

## Variables

### NTLM

static const std::string NTLM;

### PROXY_AUTHENTICATE

static const std::string PROXY_AUTHENTICATE;

### REALM

static const std::string REALM;

### WWW_AUTHENTICATE

static const std::string WWW_AUTHENTICATE;