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
a0f239a6
Commit
a0f239a6
authored
Nov 14, 2019
by
michael.simon
Browse files
send user to service register page, if he is not registered yet
parent
3ddb17d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/SamlIdpServiceImpl.java
View file @
a0f239a6
...
...
@@ -70,13 +70,19 @@ import org.opensaml.xmlsec.signature.X509Data;
import
org.opensaml.xmlsec.signature.support.SignatureException
;
import
org.slf4j.Logger
;
import
edu.kit.scc.webreg.dao.RegistryDao
;
import
edu.kit.scc.webreg.dao.SamlAuthnRequestDao
;
import
edu.kit.scc.webreg.dao.SamlIdpConfigurationDao
;
import
edu.kit.scc.webreg.dao.SamlSpMetadataDao
;
import
edu.kit.scc.webreg.dao.ServiceSamlSpDao
;
import
edu.kit.scc.webreg.dao.UserDao
;
import
edu.kit.scc.webreg.entity.RegistryEntity
;
import
edu.kit.scc.webreg.entity.RegistryStatus
;
import
edu.kit.scc.webreg.entity.SamlAuthnRequestEntity
;
import
edu.kit.scc.webreg.entity.SamlIdpConfigurationEntity
;
import
edu.kit.scc.webreg.entity.SamlSpMetadataEntity
;
import
edu.kit.scc.webreg.entity.ServiceEntity
;
import
edu.kit.scc.webreg.entity.ServiceSamlSpEntity
;
import
edu.kit.scc.webreg.entity.UserEntity
;
import
edu.kit.scc.webreg.exc.SamlAuthenticationException
;
import
net.shibboleth.utilities.java.support.component.ComponentInitializationException
;
...
...
@@ -91,6 +97,9 @@ public class SamlIdpServiceImpl implements SamlIdpService {
@Inject
private
UserDao
userDao
;
@Inject
private
RegistryDao
registryDao
;
@Inject
private
SamlIdpConfigurationDao
idpConfigDao
;
...
...
@@ -101,6 +110,9 @@ public class SamlIdpServiceImpl implements SamlIdpService {
@Inject
private
SamlSpMetadataDao
spDao
;
@Inject
private
ServiceSamlSpDao
serviceSamlSpDao
;
@Inject
private
SamlHelper
samlHelper
;
...
...
@@ -136,6 +148,24 @@ public class SamlIdpServiceImpl implements SamlIdpService {
SamlSpMetadataEntity
spMetadata
=
spDao
.
findByEntityId
(
authnRequest
.
getIssuer
().
getValue
());
logger
.
debug
(
"Corresponding SP found in Metadata: {}"
,
spMetadata
.
getEntityId
());
List
<
ServiceSamlSpEntity
>
serviceSamlSpEntityList
=
serviceSamlSpDao
.
findBySamlSp
(
spMetadata
);
for
(
ServiceSamlSpEntity
serviceSamlSpEntity
:
serviceSamlSpEntityList
)
{
ServiceEntity
service
=
serviceSamlSpEntity
.
getService
();
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"
);
}
}
}
Response
samlResponse
=
ssoHelper
.
buildAuthnResponse
(
authnRequest
,
idpConfig
.
getEntityId
());
...
...
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