Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NMC-PHP-Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UNL Information Services
NMC-PHP-Framework
Commits
942c6bab
Commit
942c6bab
authored
11 years ago
by
Tim Steiner
Browse files
Options
Downloads
Patches
Plain Diff
Updates to Unl_Cas to make the native PHP session handling work with older versions of PHP. @1h00
parent
e3d4d2c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
library/Unl/Cas.php
+34
-15
34 additions, 15 deletions
library/Unl/Cas.php
with
34 additions
and
15 deletions
library/Unl/Cas.php
+
34
−
15
View file @
942c6bab
...
@@ -41,8 +41,9 @@ class Unl_Cas
...
@@ -41,8 +41,9 @@ class Unl_Cas
const
PARAM_RENEW
=
3
;
const
PARAM_RENEW
=
3
;
/**
/**
* Session storage use to prevent infinate redirect loops when in gateway mode.
* Session storage use to prevent infinite redirect loops when in gateway mode.
* @var Zend_Session_Namespace
* Do not use this directly, use $this->_session()
* @var Zend_Session_Namespace|array
*/
*/
private
$_session
;
private
$_session
;
...
@@ -75,13 +76,10 @@ class Unl_Cas
...
@@ -75,13 +76,10 @@ class Unl_Cas
$this
->
_session
=
new
Zend_Session_Namespace
(
__CLASS__
);
$this
->
_session
=
new
Zend_Session_Namespace
(
__CLASS__
);
}
catch
(
Zend_Session_Exception
$e
)
{
}
catch
(
Zend_Session_Exception
$e
)
{
//Problem starting Zend_Session (probably because it was already started, use standard PHP sessions.
//Problem starting Zend_Session (probably because it was already started, use standard PHP sessions.
if
(
!
array_key_exists
(
__CLASS__
,
$_SESSION
)
||
!
$_SESSION
[
__CLASS__
]
instanceof
ArrayObject
)
{
if
(
!
array_key_exists
(
__CLASS__
,
$_SESSION
)
||
!
is_array
(
$_SESSION
[
__CLASS__
]
)
)
{
$_SESSION
[
__CLASS__
]
=
new
ArrayObject
();
$_SESSION
[
__CLASS__
]
=
array
();
}
}
$this
->
_session
=
$_SESSION
[
__CLASS__
];
$this
->
_session
=
NULL
;
}
if
(
!
isset
(
$this
->
_session
->
ticket
))
{
$this
->
_session
->
ticket
=
NULL
;
}
}
}
}
...
@@ -160,7 +158,7 @@ class Unl_Cas
...
@@ -160,7 +158,7 @@ class Unl_Cas
*/
*/
public
function
getUsername
()
public
function
getUsername
()
{
{
return
$this
->
_session
->
username
;
return
$this
->
_session
(
'
username
'
)
;
}
}
/**
/**
...
@@ -290,7 +288,7 @@ class Unl_Cas
...
@@ -290,7 +288,7 @@ class Unl_Cas
$response
=
$client
->
request
();
$response
=
$client
->
request
();
if
(
$response
->
isSuccessful
()
&&
$this
->
_parseResponse
(
$response
->
getBody
()))
{
if
(
$response
->
isSuccessful
()
&&
$this
->
_parseResponse
(
$response
->
getBody
()))
{
$this
->
_addValidTicket
(
$ticket
);
$this
->
_addValidTicket
(
$ticket
);
$this
->
_session
->
ticket
=
$ticket
;
$this
->
_session
(
'
ticket
'
,
$ticket
)
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -308,7 +306,7 @@ class Unl_Cas
...
@@ -308,7 +306,7 @@ class Unl_Cas
if
(
$xml
->
loadXML
(
$response
))
{
if
(
$xml
->
loadXML
(
$response
))
{
if
(
$success
=
$xml
->
getElementsByTagName
(
'authenticationSuccess'
))
{
if
(
$success
=
$xml
->
getElementsByTagName
(
'authenticationSuccess'
))
{
if
(
$success
->
length
>
0
&&
$uid
=
$success
->
item
(
0
)
->
getElementsByTagName
(
'user'
))
{
if
(
$success
->
length
>
0
&&
$uid
=
$success
->
item
(
0
)
->
getElementsByTagName
(
'user'
))
{
$this
->
_session
->
username
=
$uid
->
item
(
0
)
->
nodeValue
;
$this
->
_session
(
'
username
'
,
$uid
->
item
(
0
)
->
nodeValue
)
;
return
true
;
return
true
;
}
}
}
}
...
@@ -362,7 +360,7 @@ class Unl_Cas
...
@@ -362,7 +360,7 @@ class Unl_Cas
public
function
isTicketExpired
()
public
function
isTicketExpired
()
{
{
return
!
$this
->
_isStillValidTicket
(
$this
->
_session
->
ticket
);
return
!
$this
->
_isStillValidTicket
(
$this
->
_session
(
'
ticket
'
)
);
}
}
public
function
handleLogoutRequest
(
$saml
)
public
function
handleLogoutRequest
(
$saml
)
...
@@ -382,9 +380,30 @@ class Unl_Cas
...
@@ -382,9 +380,30 @@ class Unl_Cas
public
function
destroySession
()
public
function
destroySession
()
{
{
$this
->
_removeValidTicket
(
$this
->
_session
->
ticket
);
$this
->
_removeValidTicket
(
$this
->
_session
(
'ticket'
));
$this
->
_session
->
ticket
=
NULL
;
$this
->
_session
(
'ticket'
,
NULL
);
$this
->
_session
->
username
=
NULL
;
$this
->
_session
(
'username'
,
NULL
);
}
// Wrapper to use either Zend sessions or native PHP sessions
protected
function
_session
(
$key
,
$val
=
NULL
)
{
if
(
$this
->
_session
instanceof
Zend_Session_Namespace
)
{
if
(
func_num_args
()
==
2
)
{
$this
->
_session
->
$key
=
$val
;
}
else
{
return
$this
->
_session
->
$key
;
}
}
else
{
if
(
func_num_args
()
==
2
)
{
$_SESSION
[
__CLASS__
][
$key
]
=
$val
;
}
else
{
if
(
!
isset
(
$_SESSION
[
__CLASS__
][
$key
]))
{
return
NULL
;
}
return
$_SESSION
[
__CLASS__
][
$key
];
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment