Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
551f83b9
Commit
551f83b9
authored
Nov 30, 2020
by
michael.simon
Browse files
get Display Infos from SP in Metadata
parent
09ffea52
Changes
7
Hide whitespace changes
Inline
Side-by-side
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/SamlIdpConfigurationDao.java
View file @
551f83b9
...
...
@@ -10,11 +10,13 @@
******************************************************************************/
package
edu.kit.scc.webreg.dao
;
import
java.util.List
;
import
edu.kit.scc.webreg.entity.SamlIdpConfigurationEntity
;
public
interface
SamlIdpConfigurationDao
extends
BaseDao
<
SamlIdpConfigurationEntity
,
Long
>
{
SamlIdpConfigurationEntity
findByHostname
(
String
hostname
);
List
<
SamlIdpConfigurationEntity
>
findByHostname
(
String
hostname
);
SamlIdpConfigurationEntity
findByEntityId
(
String
entityId
);
...
...
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/jpa/JpaSamlIdpConfigurationDao.java
View file @
551f83b9
...
...
@@ -10,6 +10,8 @@
******************************************************************************/
package
edu.kit.scc.webreg.dao.jpa
;
import
java.util.List
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.inject.Named
;
import
javax.persistence.NoResultException
;
...
...
@@ -43,7 +45,7 @@ public class JpaSamlIdpConfigurationDao extends JpaBaseDao<SamlIdpConfigurationE
}
@Override
public
SamlIdpConfigurationEntity
findByHostname
(
String
hostname
)
{
public
List
<
SamlIdpConfigurationEntity
>
findByHostname
(
String
hostname
)
{
CriteriaBuilder
builder
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
SamlIdpConfigurationEntity
>
criteria
=
builder
.
createQuery
(
SamlIdpConfigurationEntity
.
class
);
Root
<
SamlIdpConfigurationEntity
>
root
=
criteria
.
from
(
SamlIdpConfigurationEntity
.
class
);
...
...
@@ -54,7 +56,7 @@ public class JpaSamlIdpConfigurationDao extends JpaBaseDao<SamlIdpConfigurationE
builder
.
equal
(
elementJoin
.
as
(
String
.
class
),
hostname
));
try
{
return
em
.
createQuery
(
criteria
).
get
Single
Result
();
return
em
.
createQuery
(
criteria
).
getResult
List
();
}
catch
(
NoResultException
e
)
{
return
null
;
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/SamlIdpConfigurationService.java
View file @
551f83b9
...
...
@@ -18,7 +18,7 @@ import edu.kit.scc.webreg.entity.ServiceSamlSpEntity;
public
interface
SamlIdpConfigurationService
extends
BaseService
<
SamlIdpConfigurationEntity
,
Long
>
{
SamlIdpConfigurationEntity
findByHostname
(
String
hostname
);
List
<
SamlIdpConfigurationEntity
>
findByHostname
(
String
hostname
);
SamlIdpConfigurationEntity
findByEntityId
(
String
entityId
);
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/impl/FederationServiceImpl.java
View file @
551f83b9
...
...
@@ -251,32 +251,10 @@ public class FederationServiceImpl extends BaseServiceImpl<FederationEntity, Lon
sp
.
getFederations
().
add
(
entity
);
sp
.
setStatus
(
SamlMetadataEntityStatus
.
ACTIVE
);
// metadataHelper.fillDisplayData(ed, sp);
// sp.setEntityCategoryList(metadataHelper.getEntityCategoryList(ed));
metadataHelper
.
fillDisplayData
(
ed
,
sp
);
sp
=
spDao
.
persist
(
sp
);
// Set<SamlIdpScopeEntity> scopes = metadataHelper.getScopes(ed, idp);
//
// List<SamlIdpScopeEntity> oldScopes;
// if (newIdp)
// oldScopes = new ArrayList<SamlIdpScopeEntity>();
// else
// oldScopes = idpScopeService.findByIdp(idp);
//
// Set<SamlIdpScopeEntity> deleteScopes = new HashSet<SamlIdpScopeEntity>(oldScopes);
// deleteScopes.removeAll(scopes);
// for (SamlIdpScopeEntity scope : deleteScopes) {
// logger.info("Deleting idp scope {}", scope.getScope());
// idpScopeService.delete(scope);
// }
//
// scopes.removeAll(oldScopes);
// for (SamlIdpScopeEntity scope : scopes) {
// logger.info("Creating new idp scope {}", scope.getScope());
// idpScopeService.save(scope);
// }
updatedList
.
add
(
sp
);
}
...
...
@@ -284,7 +262,7 @@ public class FederationServiceImpl extends BaseServiceImpl<FederationEntity, Lon
for
(
SamlSpMetadataEntity
sp
:
oldList
)
{
sp
.
getFederations
().
remove
(
entity
);
entity
.
get
Id
ps
().
remove
(
sp
);
entity
.
get
S
ps
().
remove
(
sp
);
if
(
sp
.
getFederations
().
size
()
==
0
)
{
//SP is orphaned, set Status to DELETED
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/impl/SamlIdpConfigurationServiceImpl.java
View file @
551f83b9
...
...
@@ -40,7 +40,7 @@ public class SamlIdpConfigurationServiceImpl extends BaseServiceImpl<SamlIdpConf
}
@Override
public
SamlIdpConfigurationEntity
findByHostname
(
String
hostname
)
{
public
List
<
SamlIdpConfigurationEntity
>
findByHostname
(
String
hostname
)
{
return
dao
.
findByHostname
(
hostname
);
}
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/saml/MetadataHelper.java
View file @
551f83b9
...
...
@@ -56,6 +56,7 @@ import org.w3c.dom.Document;
import
edu.kit.scc.webreg.bootstrap.ApplicationConfig
;
import
edu.kit.scc.webreg.entity.SamlIdpMetadataEntity
;
import
edu.kit.scc.webreg.entity.SamlIdpScopeEntity
;
import
edu.kit.scc.webreg.entity.SamlSpMetadataEntity
;
import
net.shibboleth.utilities.java.support.xml.BasicParserPool
;
import
net.shibboleth.utilities.java.support.xml.XMLParserException
;
...
...
@@ -294,6 +295,32 @@ public class MetadataHelper implements Serializable {
}
}
public
void
fillDisplayData
(
EntityDescriptor
entityDesc
,
SamlSpMetadataEntity
sp
)
{
SPSSODescriptor
spsso
=
entityDesc
.
getSPSSODescriptor
(
SAMLConstants
.
SAML20P_NS
);
if
(
spsso
!=
null
)
{
Extensions
extensions
=
spsso
.
getExtensions
();
if
(
extensions
!=
null
)
{
List
<
XMLObject
>
uiInfoList
=
extensions
.
getUnknownXMLObjects
(
UIInfo
.
DEFAULT_ELEMENT_NAME
);
if
(
uiInfoList
.
size
()
>
0
)
{
XMLObject
xmlObject
=
uiInfoList
.
get
(
0
);
if
(
xmlObject
instanceof
UIInfo
)
{
UIInfo
uiInfo
=
(
UIInfo
)
xmlObject
;
if
(
uiInfo
.
getDescriptions
().
size
()
>
0
)
{
sp
.
setDescription
(
uiInfo
.
getDescriptions
().
get
(
0
).
getValue
());
}
if
(
uiInfo
.
getDisplayNames
().
size
()
>
0
)
{
sp
.
setDisplayName
(
uiInfo
.
getDisplayNames
().
get
(
0
).
getValue
());
}
if
(
uiInfo
.
getInformationURLs
().
size
()
>
0
)
{
sp
.
setInformationUrl
(
uiInfo
.
getInformationURLs
().
get
(
0
).
getValue
());
}
}
}
}
}
}
public
SingleSignOnService
getSSO
(
EntityDescriptor
entityDesc
,
String
binding
)
{
IDPSSODescriptor
idpSsoDesc
=
entityDesc
.
getIDPSSODescriptor
(
SAMLConstants
.
SAML20P_NS
);
if
(
idpSsoDesc
!=
null
)
{
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/Saml2IdpRedirectHandler.java
View file @
551f83b9
...
...
@@ -11,6 +11,7 @@
package
edu.kit.scc.webreg.sec
;
import
java.io.IOException
;
import
java.util.List
;
import
javax.faces.bean.ApplicationScoped
;
import
javax.inject.Inject
;
...
...
@@ -64,8 +65,16 @@ public class Saml2IdpRedirectHandler {
public
void
service
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
SamlIdpConfigurationEntity
idpConfig
=
idpConfigService
.
findByHostname
(
request
.
getServerName
());
if
(!
request
.
getRequestURI
().
equals
(
idpConfig
.
getRedirect
()))
{
List
<
SamlIdpConfigurationEntity
>
idpConfigList
=
idpConfigService
.
findByHostname
(
request
.
getServerName
());
SamlIdpConfigurationEntity
idpConfig
=
null
;
for
(
SamlIdpConfigurationEntity
tempIdpConfig
:
idpConfigList
)
{
if
(
request
.
getRequestURI
().
equals
(
tempIdpConfig
.
getRedirect
()))
{
idpConfig
=
tempIdpConfig
;
break
;
}
}
if
(
idpConfig
==
null
)
{
throw
new
ServletException
(
"Unknown redirect uri"
);
}
...
...
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