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
dariahsp
Commits
0a197e21
Commit
0a197e21
authored
Nov 30, 2020
by
Gradl, Tobias
Browse files
18: Adapt according to needs of first actual implementation (CR)
Task-Url:
#18
parent
b75f9143
Pipeline
#18149
passed with stage
in 1 minute and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/web/controller/CommonLoginController.java
View file @
0a197e21
package
eu.dariah.de.dariahsp.web.controller
;
import
java.util.Map
;
import
java.util.Optional
;
import
org.pac4j.core.client.Client
;
import
org.pac4j.core.config.Config
;
...
...
@@ -26,7 +27,19 @@ public class CommonLoginController {
@Autowired
private
SecurityConfig
securityConfig
;
@Autowired
private
Config
config
;
@Autowired
private
JEEContext
jeeContext
;
private
final
String
loginView
;
public
CommonLoginController
()
{
this
.
loginView
=
"login"
;
}
public
CommonLoginController
(
String
loginView
)
{
this
.
loginView
=
loginView
;
}
/**
* Present the local login form; override if the desired view is not 'login'
*
...
...
@@ -39,7 +52,7 @@ public class CommonLoginController {
final
FormClient
formClient
=
(
FormClient
)
config
.
getClients
().
findClient
(
securityConfig
.
getLocal
().
getAuthorizerName
()).
orElseThrow
();
map
.
put
(
"callbackUrl"
,
formClient
.
getCallbackUrl
());
map
.
put
(
"requestUrl"
,
requestUrl
);
return
"
login
"
;
return
login
View
;
}
/**
...
...
@@ -66,13 +79,13 @@ public class CommonLoginController {
/**
* Initiate a login based on a requested authentication client specified in terms of a client_name GET parameter
*
* @param client_name name of the authentication client
* @param client_name name of the authentication client
, null selects default
* @return redirection
*/
@RequestMapping
(
"/
loginClient
"
)
@RequestMapping
(
"/
startLogin
"
)
@ResponseBody
public
String
forceLogin
()
{
final
String
clientName
=
authInfoHelper
.
getRequestedClientName
();
final
String
clientName
=
Optional
.
ofNullable
(
authInfoHelper
.
getRequestedClientName
()
).
orElse
(
securityConfig
.
getEnabledClientNames
().
get
(
0
))
;
final
Client
<?>
client
=
config
.
getClients
().
findClient
(
clientName
).
orElse
(
null
);
if
(
client
==
null
)
{
throw
new
AuthenticatorNotAvailable
(
clientName
);
...
...
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