Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
b6cfef28
Commit
b6cfef28
authored
Nov 14, 2019
by
michael.simon
Browse files
redirect after service register
parent
294a825e
Changes
6
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/SamlIdpService.java
View file @
b6cfef28
...
...
@@ -10,7 +10,7 @@ public interface SamlIdpService {
long
registerAuthnRequest
(
AuthnRequest
authnRequest
);
void
resumeAuthnRequest
(
Long
authnRequestId
,
Long
userId
,
Long
authnRequestIdpConfigId
,
String
resumeAuthnRequest
(
Long
authnRequestId
,
Long
userId
,
Long
authnRequestIdpConfigId
,
HttpServletResponse
resonse
)
throws
SamlAuthenticationException
;
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/SamlIdpServiceImpl.java
View file @
b6cfef28
...
...
@@ -132,7 +132,7 @@ public class SamlIdpServiceImpl implements SamlIdpService {
}
@Override
public
void
resumeAuthnRequest
(
Long
authnRequestId
,
Long
userId
,
public
String
resumeAuthnRequest
(
Long
authnRequestId
,
Long
userId
,
Long
authnRequestIdpConfigId
,
HttpServletResponse
response
)
throws
SamlAuthenticationException
{
SamlIdpConfigurationEntity
idpConfig
=
idpConfigDao
.
findById
(
authnRequestIdpConfigId
);
...
...
@@ -155,15 +155,9 @@ public class SamlIdpServiceImpl implements SamlIdpService {
logger
.
debug
(
"Service for SP found: {}"
,
service
);
RegistryEntity
registry
=
registryDao
.
findByServiceAndUserAndStatus
(
service
,
user
,
RegistryStatus
.
ACTIVE
);
if
(
registry
==
null
)
{
try
{
logger
.
info
(
"No active registration for user {} and service {}, redirecting to register page"
,
user
.
getEppn
(),
service
.
getName
());
response
.
sendRedirect
(
"/user/register-service.xhtml?serviceId="
+
service
.
getId
());
return
;
}
catch
(
IOException
e
)
{
logger
.
warn
(
"Cannot send to register page"
,
e
);
throw
new
SamlAuthenticationException
(
"Cannot send to register page"
);
}
logger
.
info
(
"No active registration for user {} and service {}, redirecting to register page"
,
user
.
getEppn
(),
service
.
getName
());
return
"/user/register-service.xhtml?serviceId="
+
service
.
getId
();
}
}
...
...
@@ -247,6 +241,8 @@ public class SamlIdpServiceImpl implements SamlIdpService {
try
{
postEncoder
.
initialize
();
postEncoder
.
encode
();
return
null
;
}
catch
(
MessageEncodingException
|
ComponentInitializationException
e
)
{
logger
.
warn
(
"Exception occured"
,
e
);
throw
new
SamlAuthenticationException
(
e
);
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/RegisterServiceBean.java
View file @
b6cfef28
...
...
@@ -241,15 +241,22 @@ public class RegisterServiceBean implements Serializable {
return
null
;
}
if
(
service
.
getServiceProps
().
containsKey
(
"redirect_after_register"
))
{
ExternalContext
context
=
FacesContext
.
getCurrentInstance
().
getExternalContext
();
try
{
try
{
if
(
service
.
getServiceProps
().
containsKey
(
"redirect_after_register"
))
{
ExternalContext
context
=
FacesContext
.
getCurrentInstance
().
getExternalContext
();
context
.
redirect
(
service
.
getServiceProps
().
get
(
"redirect_after_register"
));
sessionManager
.
setOriginalRequestPath
(
null
);
return
null
;
}
catch
(
IOException
e
)
{
logger
.
info
(
"Could not redirect client"
,
e
);
}
}
}
else
if
(
sessionManager
.
getOriginalRequestPath
()
!=
null
)
{
ExternalContext
context
=
FacesContext
.
getCurrentInstance
().
getExternalContext
();
context
.
redirect
(
sessionManager
.
getOriginalRequestPath
());
sessionManager
.
setOriginalRequestPath
(
null
);
return
null
;
}
}
catch
(
IOException
e
)
{
logger
.
info
(
"Could not redirect client"
,
e
);
}
return
ViewIds
.
INDEX_USER
+
"?faces-redirect=true"
;
}
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/RegisterUserBean.java
View file @
b6cfef28
...
...
@@ -175,11 +175,12 @@ public class RegisterUserBean implements Serializable {
sessionManager
.
setUserId
(
entity
.
getId
());
if
(
sessionManager
.
getOriginalRequestPath
()
!=
null
)
{
String
orig
=
sessionManager
.
getOriginalRequestPath
();
sessionManager
.
setOriginalRequestPath
(
null
);
ExternalContext
externalContext
=
FacesContext
.
getCurrentInstance
().
getExternalContext
();
try
{
externalContext
.
redirect
(
sessionManager
.
getOriginalRequestPath
()
);
externalContext
.
redirect
(
orig
);
}
catch
(
IOException
e
)
{
messageGenerator
.
addResolvedErrorMessage
(
"error_msg"
,
e
.
toString
(),
false
);
}
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/Saml2IdpRedirectResponseHandler.java
View file @
b6cfef28
...
...
@@ -50,8 +50,13 @@ public class Saml2IdpRedirectResponseHandler {
}
try
{
samlIdpService
.
resumeAuthnRequest
(
session
.
getAuthnRequestId
(),
session
.
getUserId
(),
session
.
getAuthnRequestIdpConfigId
(),
response
);
String
redirect
=
samlIdpService
.
resumeAuthnRequest
(
session
.
getAuthnRequestId
(),
session
.
getUserId
(),
session
.
getAuthnRequestIdpConfigId
(),
response
);
if
(
redirect
!=
null
)
{
session
.
setOriginalRequestPath
(
request
.
getRequestURI
());
response
.
sendRedirect
(
redirect
);
}
}
catch
(
SamlAuthenticationException
e
)
{
throw
new
ServletException
(
e
);
}
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/Saml2PostHandler.java
View file @
b6cfef28
...
...
@@ -157,8 +157,9 @@ public class Saml2PostHandler {
session
.
setLocale
(
user
.
getLocale
());
if
(
session
.
getOriginalRequestPath
()
!=
null
)
{
String
orig
=
session
.
getOriginalRequestPath
();
session
.
setOriginalRequestPath
(
null
);
response
.
sendRedirect
(
session
.
getOriginalRequestPath
()
);
response
.
sendRedirect
(
orig
);
}
else
response
.
sendRedirect
(
"/index.xhtml"
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment