protected function authVersion2(Request $request)
{
$adapter = $this->params('authentication_adapter', false);
if ($adapter) {
$adapter = strtolower($adapter);
}
switch ($request->getMethod()) {
case $request::METHOD_GET:
if (!$adapter) {
return $this->fetchAuthenticationCollection();
}
return $this->fetchAuthenticationEntity($adapter);
case $request::METHOD_POST:
if ($adapter) {
$response = new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET, PUT, and DELETE are allowed for this URI'));
$response->getHeaders()->addHeaderLine('Allow', 'GET, PUT, DELETE');
return $response;
}
return $this->createAuthenticationAdapter($this->bodyParams());
case $request::METHOD_PUT:
return $this->updateAuthenticationAdapter($adapter, $this->bodyParams());
case $request::METHOD_DELETE:
return $this->removeAuthenticationAdapter($adapter);
default:
return new ApiProblemResponse(new ApiProblem(405, 'Only the methods GET, POST, PUT, and DELETE are allowed for this URI'));
}
}