Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
d48f2bf6
Commit
d48f2bf6
authored
8 years ago
by
Hanne Moa
Browse files
Options
Downloads
Patches
Plain Diff
Add a map from error codes to titles/descriptions
parent
ac348d4b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/SimpleSAML/Error/Error.php
+2
-2
2 additions, 2 deletions
lib/SimpleSAML/Error/Error.php
lib/SimpleSAML/Error/ErrorCodes.php
+188
-0
188 additions, 0 deletions
lib/SimpleSAML/Error/ErrorCodes.php
with
190 additions
and
2 deletions
lib/SimpleSAML/Error/Error.php
+
2
−
2
View file @
d48f2bf6
...
...
@@ -100,8 +100,8 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
$this
->
dictTitle
=
'{'
.
$this
->
module
.
':errors:title_'
.
$moduleCode
[
1
]
.
'}'
;
$this
->
dictDescr
=
'{'
.
$this
->
module
.
':errors:descr_'
.
$moduleCode
[
1
]
.
'}'
;
}
else
{
$this
->
dictTitle
=
'{errors:t
itle
_'
.
$this
->
errorCode
.
'}'
;
$this
->
dictDescr
=
'{errors:descr_'
.
$this
->
errorCode
.
'}'
;
$this
->
dictTitle
=
SimpleSAML\Error\ErrorCodes
::
getErrorCodeT
itle
(
$this
->
errorCode
)
;
$this
->
dictDescr
=
SimpleSAML\Error\ErrorCodes
::
getErrorCodeDescription
(
$this
->
errorCode
)
;
}
if
(
!
empty
(
$this
->
parameters
))
{
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Error/ErrorCodes.php
0 → 100644
+
188
−
0
View file @
d48f2bf6
<?php
/**
* Class that maps SimpleSAMLphp error codes to translateable strings.
*
* @author Hanne Moa, UNINETT AS. <hanne.moa@uninett.no>
* @package SimpleSAMLphp
*/
namespace
SimpleSAML\Error
;
class
ErrorCodes
{
/**
* Fetch all default translation strings for error code titles.
*
* @return array A map from error code to error code title
*/
final
public
static
function
defaultGetAllErrorCodeTitles
()
{
return
array
(
'ACSPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_ACSPARAMS}'
),
'ARSPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_ARSPARAMS}'
),
'AUTHSOURCEERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_AUTHSOURCEERROR}'
),
'BADREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_BADREQUEST}'
),
'CASERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_CASERROR}'
),
'CONFIG'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_CONFIG}'
),
'CREATEREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_CREATEREQUEST}'
),
'DISCOPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_DISCOPARAMS}'
),
'GENERATEAUTHNRESPONSE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_GENERATEAUTHNRESPONSE}'
),
'INVALIDCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_INVALIDCERT}'
),
'LDAPERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_LDAPERROR}'
),
'LOGOUTINFOLOST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_LOGOUTINFOLOST}'
),
'LOGOUTREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_LOGOUTREQUEST}'
),
'MEMCACHEDOWN'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_MEMCACHEDOWN}'
),
'METADATA'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_METADATA}'
),
'METADATANOTFOUND'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_METADATANOTFOUND}'
),
'NOACCESS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOACCESS}'
),
'NOCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOCERT}'
),
'NORELAYSTATE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NORELAYSTATE}'
),
'NOSTATE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOSTATE}'
),
'NOTFOUND'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOTFOUND}'
),
'NOTFOUNDREASON'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOTFOUNDREASON}'
),
'NOTSET'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOTSET}'
),
'NOTVALIDCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_NOTVALIDCERT}'
),
'PROCESSASSERTION'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_PROCESSASSERTION}'
),
'PROCESSAUTHNREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_PROCESSAUTHNREQUEST}'
),
'RESPONSESTATUSNOSUCCESS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_RESPONSESTATUSNOSUCCESS}'
),
'SLOSERVICEPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_SLOSERVICEPARAMS}'
),
'SSOPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_SSOPARAMS}'
),
'UNHANDLEDEXCEPTION'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_UNHANDLEDEXCEPTION}'
),
'UNKNOWNCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_UNKNOWNCERT}'
),
'USERABORTED'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_USERABORTED}'
),
'WRONGUSERPASS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:title_WRONGUSERPASS}'
),
);
}
/**
* Fetch all translation strings for error code titles.
*
* Extend this to add error codes.
*
* @return array A map from error code to error code title
*/
public
static
function
getAllErrorCodeTitles
()
{
return
self
::
defaultGetAllErrorCodeTitles
();
}
/**
* Fetch all default translation strings for error code descriptions.
*
* @return string A map from error code to error code description
*/
final
public
static
function
defaultGetAllErrorCodeDescriptions
()
{
return
array
(
'ACSPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_ACSPARAMS}'
),
'ARSPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_ARSPARAMS}'
),
'AUTHSOURCEERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_AUTHSOURCEERROR}'
),
'BADREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_BADREQUEST}'
),
'CASERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_CASERROR}'
),
'CONFIG'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_CONFIG}'
),
'CREATEREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_CREATEREQUEST}'
),
'DISCOPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_DISCOPARAMS}'
),
'GENERATEAUTHNRESPONSE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_GENERATEAUTHNRESPONSE}'
),
'INVALIDCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_INVALIDCERT}'
),
'LDAPERROR'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_LDAPERROR}'
),
'LOGOUTINFOLOST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_LOGOUTINFOLOST}'
),
'LOGOUTREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_LOGOUTREQUEST}'
),
'MEMCACHEDOWN'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_MEMCACHEDOWN}'
),
'METADATA'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_METADATA}'
),
'METADATANOTFOUND'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_METADATANOTFOUND}'
),
'NOACCESS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOACCESS}'
),
'NOCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOCERT}'
),
'NORELAYSTATE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NORELAYSTATE}'
),
'NOSTATE'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOSTATE}'
),
'NOTFOUND'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOTFOUND}'
),
'NOTFOUNDREASON'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOTFOUNDREASON}'
),
'NOTSET'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOTSET}'
),
'NOTVALIDCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_NOTVALIDCERT}'
),
'PROCESSASSERTION'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_PROCESSASSERTION}'
),
'PROCESSAUTHNREQUEST'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_PROCESSAUTHNREQUEST}'
),
'RESPONSESTATUSNOSUCCESS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_RESPONSESTATUSNOSUCCESS}'
),
'SLOSERVICEPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_SLOSERVICEPARAMS}'
),
'SSOPARAMS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_SSOPARAMS}'
),
'UNHANDLEDEXCEPTION'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_UNHANDLEDEXCEPTION}'
),
'UNKNOWNCERT'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_UNKNOWNCERT}'
),
'USERABORTED'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_USERABORTED}'
),
'WRONGUSERPASS'
=>
\SimpleSAML\Locale\Translate
::
noop
(
'{error:descr_WRONGUSERPASS}'
),
);
}
/**
* Fetch all translation strings for error code descriptions.
*
* Extend this to add error codes.
*
* @return string A map from error code to error code description
*/
public
static
function
getAllErrorCodeDescriptions
()
{
return
self
::
defaultGetAllErrorCodeDescriptions
();
}
/**
* Get a map of both errorcode titles and descriptions
*
* Convenience-method for template-callers
*
* @return array An array containing both errorcode maps.
*/
public
static
function
getAllErrorCodeMessages
()
{
return
array
(
'title'
=>
self
::
getAllErrorCodeTitles
(),
'descr'
=>
self
::
getAllErrorCodeDescriptions
(),
);
}
/**
* Fetch a translation string for a title for a given error code.
*
* @param string $errorCode The error code to look up
*
* @return string A string to translate
*/
public
static
function
getErrorCodeTitle
(
$errorCode
)
{
$errorCodeTitles
=
self
::
getAllErrorCodeTitles
();
return
$errorCodeTitles
[
$errorCode
];
}
/**
* Fetch a translation string for a description for a given error code.
*
* @param string $errorCode The error code to look up
*
* @return string A string to translate
*/
public
static
function
getErrorCodeDescription
(
$errorCode
)
{
$errorCodeDescriptions
=
self
::
getAllErrorCodeDescriptions
();
return
$errorCodeDescriptions
[
$errorCode
];
}
/**
* Get both title and description for a specific error code
*
* Convenience-method for template-callers
*
* @param string $errorCode The error code to look up
*
* @return array An array containing both errorcode strings.
*/
public
static
function
getErrorCodeMessage
(
$errorCode
)
{
return
array
(
'title'
=>
self
::
getErrorCodeTitle
(
$errorCode
),
'descr'
=>
self
::
getErrorCodeDescription
(
$errorCode
),
);
}
}
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