# OneLogin_Saml2_Auth

Main class of PHP Toolkit

### Methods

## Initializes the SP SAML instance.

    __construct(array $oldSettings = null)

### Arguments

#### $oldSettings

`array`

Setting data

## Returns the settings info

    getSettings() : array

### Response

`array`

The settings data.

## Set the strict mode active/disable

    setStrict(boolean $value) : array

### Arguments

#### $value

`boolean`

Strict parameter

### Response

`array`

The settings data.

## Process the SAML Response sent by the IdP.

    processResponse(string $requestId = null)

### Arguments

#### $requestId

`string`

The ID of the AuthNRequest sent by this SP to the IdP

## Process the SAML Logout Response / Logout Request sent by the IdP.

    processSLO(boolean $keepLocalSession = false, string $requestId = null)

### Arguments

#### $keepLocalSession

`boolean`

When false will destroy the local session, otherwise will destroy it

#### $requestId

`string`

The ID of the LogoutRequest sent by this SP to the IdP

## Redirects the user to the url past by parameter or to the url that we defined in our SSO Request.

    redirectTo(string $url = '', array $parameters = array())

### Arguments

#### $url

`string`

The target URL to redirect the user.

#### $parameters

`array`

Extra parameters to be passed as part of the url

## Checks if the user is authenticated or not.

    isAuthenticated() : boolean

### Response

`boolean`

True if the user is authenticated

## Returns the set of SAML attributes.

    getAttributes() : array

### Response

`array`

Attributes of the user.

## Returns the nameID

    getNameId() : string

### Response

`string`

The nameID of the assertion

## Returns the SessionIndex

    getSessionIndex() : string

### Response

`string`

The SessionIndex of the assertion

## Returns if there were any error

    getErrors() : array

### Response

`array`

Errors

## Returns the reason for the last error

    getLastErrorReason() : string

### Response

`String`

Error

## Returns the requested SAML attribute

    getAttribute(string $name) : NULL || Array

### Arguments

#### $name

`string`

The requested attribute of the user.

### Response

`NULL`

|| array Requested SAML attribute ($name).

## Initiates the SSO process.

    login(string $returnTo = null, $parameters = array(), $forceAuthn = false, $isPassive = false)

### Arguments

#### $returnTo

`string`

The target URL the user should be returned to after login.

#### $parameters

`array`

Extra parameters to be added to the GET.

#### $forceAuthn

`bool`

When true the AuthNReuqest will set the ForceAuthn='true'.

#### $isPassive

`bool`

When true the AuthNReuqest will set the Ispassive='true'.

## Initiates the SLO process.

    logout(string $returnTo = null, array $parameters = array(), string $nameId = null, string $sessionIndex = null)

### Arguments

#### $returnTo

`string`

The target URL the user should be returned to after logout.

#### $parameters

`array`

Extra parameters to be added to the GET.

#### $nameId

`string`

The NameID that will be set in the LogoutRequest.

#### $sessionIndex

`string`

The SessionIndex (taken from the SAML Response in the SSO process).

## Gets the SSO url.

    getSSOurl() : string

### Response

`string`

The url of the Single Sign On Service

## Gets the SLO url.

    getSLOurl() : string

### Response

`string`

The url of the Single Logout Service

## Generates the Signature for a SAML Request

    buildRequestSignature(string $samlRequest, string $relayState) : string

### Arguments

#### $samlRequest

`string`

The SAML Request

#### $relayState

`string`

The RelayState

### Response

`string`

A base64 encoded signature

## Generates the Signature for a SAML Response

    buildResponseSignature(string $samlResponse, string $relayState) : string

### Arguments

#### $samlResponse

`string`

The SAML Response

#### $relayState

`string`

The RelayState

### Response

`string`

A base64 encoded signature

### Properties

## Settings data.

    _settings : array

var |

### Type(s)

`array`

## User attributes data.

    _attributes : array

var |

### Type(s)

`array`

## NameID

    _nameid : string

var |

### Type(s)

`string`

## If user is authenticated.

    _authenticated : boolean

var |

### Type(s)

`boolean`

## SessionIndex. When the user is logged, this stored the from the AuthnStatement of the SAML Response.

    _sessionIndex : string

var |

### Type(s)

`boolean`

## If any error.

    _errors : array

var |

### Type(s)

`array`