Commit d2725e67 authored by michael.simon's avatar michael.simon
Browse files

Update IDP Status with WebSSO Login

parent ad4be90f
......@@ -14,6 +14,7 @@ import java.util.List;
import edu.kit.scc.webreg.entity.FederationEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntityStatus;
import edu.kit.scc.webreg.entity.SamlMetadataEntityStatus;
public interface SamlIdpMetadataService extends BaseService<SamlIdpMetadataEntity, Long> {
......@@ -32,4 +33,7 @@ public interface SamlIdpMetadataService extends BaseService<SamlIdpMetadataEntit
List<SamlIdpMetadataEntity> findAllByStatusOrderedByOrgname(
SamlMetadataEntityStatus status);
void updateIdpStatus(SamlIdpMetadataEntityStatus status,
SamlIdpMetadataEntity idpEntity);
}
......@@ -10,6 +10,7 @@
******************************************************************************/
package edu.kit.scc.webreg.service.impl;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
......@@ -19,6 +20,7 @@ import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.SamlIdpMetadataDao;
import edu.kit.scc.webreg.entity.FederationEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntityStatus;
import edu.kit.scc.webreg.entity.SamlMetadataEntityStatus;
import edu.kit.scc.webreg.service.SamlIdpMetadataService;
......@@ -30,6 +32,15 @@ public class SamlIdpMetadataServiceImpl extends BaseServiceImpl<SamlIdpMetadataE
@Inject
private SamlIdpMetadataDao dao;
@Override
public void updateIdpStatus(SamlIdpMetadataEntityStatus status, SamlIdpMetadataEntity idpEntity) {
idpEntity = dao.merge(idpEntity);
if (! status.equals(idpEntity.getIdIdpStatus())) {
idpEntity.setIdIdpStatus(status);
idpEntity.setLastIdStatusChange(new Date());
}
}
@Override
public List<SamlIdpMetadataEntity> findAllByFederation(FederationEntity federation) {
return dao.findAllByFederation(federation);
......
......@@ -33,6 +33,7 @@ import org.slf4j.Logger;
import edu.kit.scc.webreg.bootstrap.ApplicationConfig;
import edu.kit.scc.webreg.drools.KnowledgeSessionService;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntityStatus;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.SamlAuthenticationException;
......@@ -94,12 +95,24 @@ public class Saml2PostHandlerServlet {
EntityDescriptor idpEntityDescriptor = samlHelper.unmarshal(
idpEntity.getEntityDescriptor(), EntityDescriptor.class);
Response samlResponse = saml2DecoderService.decodePostMessage(request);
Assertion assertion;
String persistentId;
try {
Response samlResponse = saml2DecoderService.decodePostMessage(request);
Assertion assertion = saml2AssertionService.processSamlResponse(samlResponse, idpEntity, idpEntityDescriptor, spConfig);
String persistentId = saml2AssertionService.extractPersistentId(assertion, spConfig);
assertion = saml2AssertionService.processSamlResponse(samlResponse, idpEntity, idpEntityDescriptor, spConfig);
persistentId = saml2AssertionService.extractPersistentId(assertion, spConfig);
} catch (Exception e1) {
/*
* Catch Exception here for a probabyl faulty IDP. Register Exception and rethrow.
*/
idpService.updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw e1;
}
idpService.updateIdpStatus(SamlIdpMetadataEntityStatus.GOOD, idpEntity);
Map<String, List<Object>> attributeMap = saml2AssertionService.extractAttributes(assertion);
UserEntity user = userService.findByPersistentWithRoles(spConfig.getEntityId(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment