Search in sources :

Example 6 with SamlConfig

use of org.openkilda.saml.model.SamlConfig 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;
}
Also used : Blob(java.sql.Blob) SamlConfigEntity(org.openkilda.saml.dao.entity.SamlConfigEntity) SamlConfig(org.openkilda.saml.model.SamlConfig) MetadataProviderException(org.opensaml.saml2.metadata.provider.MetadataProviderException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with SamlConfig

use of org.openkilda.saml.model.SamlConfig in project open-kilda by telstra.

the class DbMetadataProvider method fetchMetadata.

// This example code simply does straight JDBC
@Override
protected byte[] fetchMetadata() throws MetadataProviderException {
    try {
        SamlService samlService = ApplicationContextProvider.getContext().getBean(SamlService.class);
        SamlConfig samlConfig = samlService.getById(getMetaDataEntityId());
        byte[] bytes = null;
        if (samlConfig.getMetadata() != null) {
            String metadata = samlConfig.getMetadata();
            bytes = metadata.getBytes();
        }
        return bytes;
    } catch (Exception e) {
        String errorMessage = "Unable to query metadata from database with entityId = " + getMetaDataEntityId();
        throw new MetadataProviderException(errorMessage, e);
    }
}
Also used : SamlService(org.openkilda.saml.service.SamlService) SamlConfig(org.openkilda.saml.model.SamlConfig) MetadataProviderException(org.opensaml.saml2.metadata.provider.MetadataProviderException) MetadataProviderException(org.opensaml.saml2.metadata.provider.MetadataProviderException)

Aggregations

SamlConfig (org.openkilda.saml.model.SamlConfig)7 SamlConfigEntity (org.openkilda.saml.dao.entity.SamlConfigEntity)3 ArrayList (java.util.ArrayList)2 SamlService (org.openkilda.saml.service.SamlService)2 MetadataProviderException (org.opensaml.saml2.metadata.provider.MetadataProviderException)2 RoleEntity (org.usermanagement.dao.entity.RoleEntity)2 Blob (java.sql.Blob)1 HashSet (java.util.HashSet)1 NameID (org.opensaml.saml2.core.NameID)1 AnonymousAuthenticationToken (org.springframework.security.authentication.AnonymousAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1 SAMLCredential (org.springframework.security.saml.SAMLCredential)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 UserInfo (org.usermanagement.model.UserInfo)1