use of org.openkilda.saml.dao.entity.SamlConfigEntity in project open-kilda by telstra.
the class SamlService method update.
/**
* Updates the provider.
*
* @param uuid the uuid
* @param file the metadata file
* @param name the provider name
* @param url the metadata url
* @param entityId the entityId
* @param status the provider status
* @param attribute the attribute
* @param userCreation the userCreation
* @param roleIds the role Ids
* @return the SamlConfig
*/
public SamlConfig update(String uuid, MultipartFile file, String name, String url, String entityId, boolean status, String attribute, boolean userCreation, List<Long> roleIds) {
SamlConfigEntity samlConfigEntity = samlValidator.validateUpdateProvider(uuid, file, name, entityId, url, userCreation, roleIds);
Set<RoleEntity> roleEntities = roleService.getRolesById(roleIds);
boolean requireManagerUpdate = SamlConversionUtil.toUpdateSamlConfigEntity(samlConfigEntity, roleEntities, file, name, url, entityId, status, userCreation, attribute);
samlRepository.save(samlConfigEntity);
if (requireManagerUpdate) {
metadataManager.updateProviderToMetadataManager(samlConfigEntity.getUuid(), samlConfigEntity.getType().name());
}
return SamlConversionUtil.toSamlConfig(samlConfigEntity);
}
use of org.openkilda.saml.dao.entity.SamlConfigEntity in project open-kilda by telstra.
the class SamlService method getAllActiveIdp.
/**
* Gets all the active providers.
*
* @return the active providers
*/
public List<SamlConfig> getAllActiveIdp() {
List<SamlConfigEntity> samlConfigEntityList = samlRepository.findAllByStatus(true);
List<SamlConfig> samlConfigList = new ArrayList<>();
for (SamlConfigEntity samlConfigEntity : samlConfigEntityList) {
SamlConfig samlConfig = SamlConversionUtil.toSamlConfig(samlConfigEntity);
samlConfigList.add(samlConfig);
}
return samlConfigList;
}
use of org.openkilda.saml.dao.entity.SamlConfigEntity in project open-kilda by telstra.
the class SamlService method deleteByUuid.
/**
* Delete provider.
*
* @param uuid the uuid
* @return delete message
*/
public Message deleteByUuid(String uuid) {
SamlConfigEntity samlConfigEntity = samlValidator.getEntityByUuid(uuid);
samlRepository.delete(samlConfigEntity);
metadataManager.deleteProviderFromMetadataManager(samlConfigEntity);
return new Message("Provider deleted successfully");
}
use of org.openkilda.saml.dao.entity.SamlConfigEntity in project open-kilda by telstra.
the class SamlService method getById.
/**
* Gets the provider detail.
* @param uuid the uuid of provider.
* @return the SamlConfig
*/
@Transactional
public SamlConfig getById(String uuid) {
SamlConfigEntity samlConfigEntity = samlValidator.getEntityByUuid(uuid);
SamlConfig samlConfig = SamlConversionUtil.toSamlConfig(samlConfigEntity);
Blob blob = samlConfigEntity.getMetadata();
byte[] bdata;
if (blob != null) {
try {
bdata = blob.getBytes(1, (int) blob.length());
String metadata = new String(bdata);
samlConfig.setMetadata(metadata);
} catch (Exception e) {
LOGGER.error("Error occurred while getting provider detail" + e);
}
}
return samlConfig;
}
use of org.openkilda.saml.dao.entity.SamlConfigEntity in project open-kilda by telstra.
the class SamlConversionUtil method toSamlConfigEntity.
/**
* To saml config entity.
*
* @param file the metadata file
* @param name the provider name
* @param url the metadata url
* @param entityId the entityId
* @param status the provider status
* @param attribute the attribute
* @param userCreation the userCreation
* @param roleEntities the role entities
* @return the saml config entity
*/
public static SamlConfigEntity toSamlConfigEntity(MultipartFile file, String name, String url, String entityId, boolean status, String attribute, boolean userCreation, Set<RoleEntity> roleEntities) {
SamlConfigEntity samlConfigEntity = new SamlConfigEntity();
Blob blob = null;
try {
if (file != null) {
byte[] bytes = file.getBytes();
try {
blob = new SerialBlob(bytes);
} catch (SerialException e) {
LOGGER.error("Error occurred while saving saml provider" + e);
} catch (SQLException e) {
LOGGER.error("Error occurred while saving saml provider" + e);
}
samlConfigEntity.setType(IConstants.ProviderType.FILE);
} else if (url != null) {
samlConfigEntity.setType(IConstants.ProviderType.URL);
}
if (userCreation) {
samlConfigEntity.setUserCreation(true);
samlConfigEntity.setRoles(roleEntities);
}
samlConfigEntity.setMetadata(blob);
samlConfigEntity.setEntityId(entityId);
samlConfigEntity.setAttribute(attribute);
samlConfigEntity.setUrl(url);
samlConfigEntity.setName(name);
samlConfigEntity.setStatus(status);
samlConfigEntity.setUuid(UUID.randomUUID().toString());
return samlConfigEntity;
} catch (FileNotFoundException e) {
LOGGER.error("Error occurred while saving saml provider" + e);
} catch (IOException e) {
LOGGER.error("Error occurred while saving saml provider" + e);
}
return samlConfigEntity;
}
Aggregations