Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
A
auth
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lib
unicaen
auth
Commits
448bf935
Commit
448bf935
authored
Sep 20, 2019
by
Laurent Lécluse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adaptation des assertions au ZF3
Fourniture d'une factory à utiliser par défaut
parent
d4b42da1
Pipeline
#5313
failed with stage
in 9 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
57 deletions
+61
-57
src/UnicaenAuth/Assertion/AbstractAssertion.php
src/UnicaenAuth/Assertion/AbstractAssertion.php
+17
-57
src/UnicaenAuth/Assertion/AssertionFactory.php
src/UnicaenAuth/Assertion/AssertionFactory.php
+44
-0
No files found.
src/UnicaenAuth/Assertion/AbstractAssertion.php
View file @
448bf935
...
...
@@ -3,11 +3,11 @@
namespace
UnicaenAuth\Assertion
;
use
BjyAuthorize\Service\Authorize
;
use
UnicaenA
pp\ServiceManager\ServiceLocatorAwareInterfa
ce
;
use
UnicaenA
pp\ServiceManager\ServiceLocator
AwareTrait
;
use
UnicaenA
uth\Service\AuthorizeServi
ce
;
use
UnicaenA
uth\Service\Traits\AuthorizeService
AwareTrait
;
use
UnicaenAuth\Service\Traits\UserContextServiceAwareTrait
;
use
UnicaenAuth\Service\UserContext
;
use
Zend\Mvc\MvcEvent
;
use
Zend\Mvc\Plugin\FlashMessenger\FlashMessenger
;
use
Zend\Permissions\Acl\Acl
;
use
Zend\Permissions\Acl\Assertion\AssertionInterface
;
use
Zend\Permissions\Acl\Resource\ResourceInterface
;
...
...
@@ -18,10 +18,10 @@ use Zend\Permissions\Acl\Role\RoleInterface;
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
abstract
class
AbstractAssertion
implements
AssertionInterface
,
ServiceLocatorAwareInterface
abstract
class
AbstractAssertion
implements
AssertionInterface
{
use
ServiceLocatorAwareTrait
;
use
UserContextServiceAwareTrait
;
use
AuthorizeServiceAwareTrait
;
/**
* @var Acl
...
...
@@ -34,9 +34,9 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
private
$role
=
false
;
/**
* @var
FlashMessenger
* @var
MvcEvent
*/
private
$
fm
;
private
$
mvcEvent
;
...
...
@@ -117,9 +117,10 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/
public
function
getAcl
()
{
if
(
!
$this
->
acl
){
if
(
!
$this
->
acl
)
{
$this
->
acl
=
$this
->
getServiceAuthorize
()
->
getAcl
();
}
return
$this
->
acl
;
}
...
...
@@ -144,12 +145,13 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/
public
function
getRole
()
{
if
(
false
===
$this
->
role
){
$sUserContext
=
$this
->
getServiceUserContext
()
;
if
(
false
===
$this
->
role
)
{
$sUserContext
=
$this
->
serviceUserContext
;
if
(
$sUserContext
->
getIdentity
())
{
$this
->
role
=
$sUserContext
->
getSelectedIdentityRole
();
}
}
return
$this
->
role
;
}
...
...
@@ -284,30 +286,26 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/
protected
function
asserts
(
$assertions
)
{
if
(
!
is_array
(
$assertions
)){
if
(
!
is_array
(
$assertions
))
{
$assertions
=
[
$assertions
];
}
foreach
(
$assertions
as
$assertion
)
{
foreach
(
$assertions
as
$assertion
)
{
if
(
!
$assertion
)
return
false
;
}
return
true
;
}
/**
* @var MvcEvent
*/
private
$mvcEvent
;
/**
* @param MvcEvent $mvcEvent
*/
public
function
setMvcEvent
(
MvcEvent
$mvcEvent
)
{
$this
->
mvcEvent
=
$mvcEvent
;
}
/**
* @return MvcEvent
*/
...
...
@@ -316,42 +314,4 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
return
$this
->
mvcEvent
;
}
/**
* @var Authorize
*/
private
$serviceAuthorize
;
/**
* @param Authorize $serviceAuthorize
*/
public
function
setServiceAuthorize
(
Authorize
$serviceAuthorize
)
{
$this
->
serviceAuthorize
=
$serviceAuthorize
;
}
/**
* @return Authorize
*/
private
function
getServiceAuthorize
()
{
return
$this
->
serviceAuthorize
;
}
/**
* @param FlashMessenger $fm
* @deprecated Merci d'abandonner cette méthode : SoC violation !
*/
public
function
setFlashMessenger
(
FlashMessenger
$fm
)
{
$this
->
fm
=
$fm
;
}
/**
* @return FlashMessenger
* @deprecated Merci d'abandonner cette méthode : SoC violation !
*/
protected
function
flashMessenger
()
{
return
$this
->
fm
;
}
}
\ No newline at end of file
src/UnicaenAuth/Assertion/AssertionFactory.php
0 → 100644
View file @
448bf935
<?php
namespace
UnicaenAuth\Assertion
;
use
BjyAuthorize\Service\Authorize
;
use
Interop\Container\ContainerInterface
;
use
Zend\Authentication\AuthenticationService
;
use
Zend\Mvc\Application
;
use
Zend\ServiceManager\Factory\FactoryInterface
;
/**
* Class AssertionFactory
*
* @package UnicaenAuth\Assertion
*/
class
AssertionFactory
implements
FactoryInterface
{
/**
* @param ContainerInterface $container
*
* @return UserContext
*/
public
function
__invoke
(
ContainerInterface
$container
,
$requestedName
,
array
$options
=
null
)
{
/* @var $application Application */
$application
=
$container
->
get
(
'Application'
);
$mvcEvent
=
$application
->
getMvcEvent
();
/* @var $serviceAuthorize Authorize */
$serviceAuthorize
=
$container
->
get
(
'BjyAuthorize\Service\Authorize'
);
/** @var UserContext $serviceUserContext */
$serviceUserContext
=
$container
->
get
(
'UnicaenAuth\Service\UserContext'
);
/* @var $assertion AbstractAssertion */
$assertion
=
new
$requestedName
;
$assertion
->
setMvcEvent
(
$mvcEvent
);
$assertion
->
setServiceAuthorize
(
$serviceAuthorize
);
$assertion
->
setServiceUserContext
(
$serviceUserContext
);
return
$assertion
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment