use of org.openkilda.store.auth.dao.entity.OauthConfigEntity in project open-kilda by telstra.
the class LinkStoreConfigValidator method validate.
/**
* Validate.
*
* @param linkStoreConfigDto the link store config dto
*/
public void validate(final LinkStoreConfigDto linkStoreConfigDto) {
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
if (CollectionUtil.isEmpty(oauthConfigEntityList)) {
LOGGER.warn(messageUtil.getStoreMustConfigured());
throw new RequestValidationException(messageUtil.getStoreMustConfigured());
}
List<String> urls = StoreUrl.getUrlName(StoreType.LINK_STORE.getCode());
for (Entry<String, UrlDto> urlEntrySet : linkStoreConfigDto.getUrls().entrySet()) {
if (!urls.contains(urlEntrySet.getKey())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getUrl())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotNull("url of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getMethodType())) {
LOGGER.warn("Validation fail for link store configuration. Error: " + messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
}
}
}
use of org.openkilda.store.auth.dao.entity.OauthConfigEntity in project open-kilda by telstra.
the class SwitchStoreConfigValidator method validate.
/**
* Validate.
*
* @param switchStoreConfigDto the link store config dto
*/
public void validate(final SwitchStoreConfigDto switchStoreConfigDto) {
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
if (CollectionUtil.isEmpty(oauthConfigEntityList)) {
LOGGER.warn(messageUtil.getStoreMustConfigured());
throw new RequestValidationException(messageUtil.getStoreMustConfigured());
}
List<String> urls = StoreUrl.getUrlName(StoreType.SWITCH_STORE.getCode());
for (Entry<String, UrlDto> urlEntrySet : switchStoreConfigDto.getUrls().entrySet()) {
if (!urls.contains(urlEntrySet.getKey())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotvalid(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getUrl())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotNull("url of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull(urlEntrySet.getKey()));
} else if (ValidatorUtil.isNull(urlEntrySet.getValue().getMethodType())) {
LOGGER.warn("Validation fail for switch store configuration. Error: " + messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
throw new RequestValidationException(messageUtil.getAttributeNotNull("method-type of " + urlEntrySet.getKey()));
}
}
}
use of org.openkilda.store.auth.dao.entity.OauthConfigEntity in project open-kilda by telstra.
the class AuthService method getOauthConfig.
/**
* Gets the oauth config.
*
* @return the oauth config
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public OauthTwoConfigDto getOauthConfig() {
LOGGER.info("Get oauth configuration");
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
OauthConfigEntity oauthConfigEntity = null;
if (oauthConfigEntityList.size() > 0) {
oauthConfigEntity = oauthConfigEntityList.get(0);
}
if (oauthConfigEntity == null) {
oauthConfigEntity = new OauthConfigEntity();
}
return OauthConfigConverter.toOauthTwoConfigDto(oauthConfigEntity);
}
use of org.openkilda.store.auth.dao.entity.OauthConfigEntity in project open-kilda by telstra.
the class AuthService method saveOrUpdateOauthConfig.
/**
* Save or update oauth config.
*
* @param oauthTwoConfigDto the oauth two config dto
* @return the oauth two config dto
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public OauthTwoConfigDto saveOrUpdateOauthConfig(final OauthTwoConfigDto oauthTwoConfigDto) {
LOGGER.info("Save or update oauth configuration");
List<OauthConfigEntity> oauthConfigEntityList = oauthConfigRepository.findByAuthType_authTypeId(AuthType.OAUTH_TWO.getAuthTypeEntity().getAuthTypeId());
OauthConfigEntity oauthConfigEntity = null;
if (oauthConfigEntityList.size() > 0) {
oauthConfigEntity = oauthConfigEntityList.get(0);
}
if (oauthConfigEntity == null) {
oauthConfigEntity = new OauthConfigEntity();
}
oauthConfigEntity = OauthConfigConverter.toOauthConfigEntity(oauthTwoConfigDto, oauthConfigEntity);
oauthConfigEntity = oauthConfigRepository.save(oauthConfigEntity);
return OauthConfigConverter.toOauthTwoConfigDto(oauthConfigEntity);
}
Aggregations