Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
search
Commits
f733e3c5
Commit
f733e3c5
authored
May 18, 2021
by
Gradl, Tobias
Browse files
428: Show real error page instead of Whitelabel Error Page (OPENED)
Task-Url:
#428
parent
b3b25d62
Pipeline
#23490
passed with stage
in 53 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
f733e3c5
...
...
@@ -9,7 +9,7 @@ allprojects {
apply
plugin:
'eclipse'
group
=
'eu.dariah.de.minfba'
version
=
'4.
0
-SNAPSHOT'
version
=
'4.
1
-SNAPSHOT'
repositories
{
mavenLocal
()
...
...
@@ -22,7 +22,7 @@ allprojects {
gtfVersion
=
"2.1.0-SNAPSHOT"
processingVersion
=
"4.2.0-SNAPSHOT"
colregModelVersion
=
"4.3.4-RELEASE"
dariahSpVersion
=
"2.1.
6
-RELEASE"
dariahSpVersion
=
"2.1.
7
-RELEASE"
jsonAssertVersion
=
"1.5.0"
jodaTimeVersion
=
"2.10.10"
...
...
search-ui/src/main/java/eu/dariah/de/search/controller/ErrorController.java
0 → 100644
View file @
f733e3c5
package
eu.dariah.de.search.controller
;
import
java.util.Map
;
import
javax.servlet.RequestDispatcher
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties
;
import
org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
;
import
org.springframework.boot.web.servlet.error.ErrorAttributes
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.servlet.ModelAndView
;
import
eu.dariah.de.dariahsp.config.SecurityConfig
;
import
eu.dariah.de.dariahsp.error.RequiredAttributesException
;
/**
* Error controller for the sample application
*
* @author Tobias Gradl
*/
@Controller
@RequestMapping
({
"${server.error.path:${error.path:/error}}"
})
public
class
ErrorController
extends
BasicErrorController
{
@Autowired
private
SecurityConfig
securityConfig
;
/**
* Constructor with autowired ErrorAttributes
*
* @param errorAttributes
*/
@Autowired
public
ErrorController
(
ErrorAttributes
errorAttributes
)
{
super
(
errorAttributes
,
new
ErrorProperties
());
}
/**
* Error handling method dispatching all errors as messages to the default index view.
* Particular attention lies on the treatment of the {@link RequiredAttributesException}
*/
@Override
@RequestMapping
(
produces
=
{
"text/html"
})
public
ModelAndView
errorHtml
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
Object
>
attr
=
getErrorAttributes
(
request
,
getErrorAttributeOptions
(
request
,
MediaType
.
ALL
));
HttpStatus
status
=
getStatus
(
request
);
this
.
assembleMap
(
attr
,
status
);
// This is an error that needs special treatment in DARIAH/CLARIAH
Object
ex
=
request
.
getAttribute
(
RequestDispatcher
.
ERROR_EXCEPTION
);
if
(
ex
!=
null
&&
RequiredAttributesException
.
class
.
isAssignableFrom
(
ex
.
getClass
()))
{
StringBuilder
errorStrBldr
=
new
StringBuilder
();
errorStrBldr
.
append
(
"Your IdP did not provide all required attributes. "
);
if
(
securityConfig
.
getSaml
().
getSp
().
getAttributesIncompleteRedirectUrl
()!=
null
)
{
errorStrBldr
.
append
(
"Please visit "
)
.
append
(
"<a href='"
).
append
(
securityConfig
.
getSaml
().
getSp
().
getAttributesIncompleteRedirectUrl
()).
append
(
"'>"
)
.
append
(
securityConfig
.
getSaml
().
getSp
().
getAttributesIncompleteRedirectUrl
())
.
append
(
"</a> to validate your profile setup."
);
}
attr
.
put
(
"hint"
,
errorStrBldr
.
toString
());
attr
.
put
(
"error"
,
HttpStatus
.
FORBIDDEN
.
value
());
attr
.
put
(
"reason"
,
HttpStatus
.
FORBIDDEN
.
getReasonPhrase
());
}
return
new
ModelAndView
(
"common/error"
,
attr
);
}
/* Do not do this in production as users should not see all reasons openly */
@Override
protected
boolean
isIncludeMessage
(
HttpServletRequest
request
,
MediaType
produces
)
{
return
true
;
}
private
void
assembleMap
(
Map
<
String
,
Object
>
map
,
HttpStatus
status
)
{
map
.
put
(
"error"
,
status
.
value
());
map
.
put
(
"reason"
,
status
.
getReasonPhrase
());
map
.
put
(
"localEnabled"
,
securityConfig
.
getLocal
().
isEnabled
());
map
.
put
(
"samlEnabled"
,
securityConfig
.
getSaml
().
isEnabled
());
}
}
\ No newline at end of file
_search-commons
@
ca479bb9
Compare
7274639e
...
ca479bb9
Subproject commit
7274639e8461b8c5970617dcdeb6305f7c819fb9
Subproject commit
ca479bb95e8f7dac66ac4718192f1374710bb06e
search-ui/src/main/webapp/WEB-INF/view/views.xml
View file @
f733e3c5
...
...
@@ -76,9 +76,14 @@
</definition>
<!-- Errors -->
<definition
name=
"*/error"
extends=
"{1}/template_simple"
>
<definition
name=
"*/common/error"
extends=
"{1}/template_simple"
>
<put-attribute
name=
"fluidLayout"
cascade=
"true"
value=
"false"
/>
<put-attribute
name=
"content"
value=
"/WEB-INF/view/jsp/_search-commons/common/error.jsp"
/>
</definition>
<definition
name=
"*/error/404"
extends=
"{1}/template_simple"
>
<put-attribute
name=
"fluidLayout"
cascade=
"true"
value=
"false"
/>
<put-attribute
name=
"content"
value=
"/WEB-INF/view/jsp/_search-commons/common/error404.jsp"
/>
</definition>
<!-- User profile -->
<definition
name=
"*/user"
extends=
"{1}/template_simple"
>
...
...
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