use of org.wso2.carbon.apimgt.core.api.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImpl method deletePolicy.
@Override
public void deletePolicy(PolicyValidationData policyValidationData) throws GatewayException {
if (policyValidationData != null) {
PolicyEvent policyEvent = new PolicyEvent(APIMgtConstants.GatewayEventTypes.POLICY_DELETE);
policyEvent.setId(policyValidationData.getId());
policyEvent.setName(policyValidationData.getName());
policyEvent.setStopOnQuotaReach(policyValidationData.isStopOnQuotaReach());
publishToThrottleTopic(policyEvent);
if (log.isDebugEnabled()) {
log.debug("Policy : " + policyValidationData.getName() + " delete event has been successfully " + "published " + "to broker");
}
}
}
use of org.wso2.carbon.apimgt.core.api.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImpl method deleteBlockCondition.
@Override
public void deleteBlockCondition(BlockConditions blockConditions) throws GatewayException {
if (blockConditions != null) {
BlockEvent blockEvent = new BlockEvent(APIMgtConstants.GatewayEventTypes.BLOCK_CONDITION_ADD);
blockEvent.setConditionId(blockConditions.getConditionId());
blockEvent.setUuid(blockConditions.getUuid());
blockEvent.setConditionType(blockConditions.getConditionType());
blockEvent.setEnabled(blockConditions.isEnabled());
blockEvent.setConditionValue(blockConditions.getConditionValue());
if (APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_IP.equals(blockConditions.getConditionType())) {
blockEvent.setFixedIp(APIUtils.ipToLong(blockConditions.getConditionValue()));
}
if (APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITION_IP_RANGE.equals(blockConditions.getConditionType())) {
blockEvent.setStartingIP(APIUtils.ipToLong(blockConditions.getStartingIP()));
blockEvent.setEndingIP(APIUtils.ipToLong(blockConditions.getEndingIP()));
}
publishToThrottleTopic(blockEvent);
if (log.isDebugEnabled()) {
log.debug("BlockCondition : " + blockConditions.getUuid() + " delete event has been successfully " + "published " + "to broker");
}
}
}
use of org.wso2.carbon.apimgt.core.api.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImpl method addPolicy.
@Override
public void addPolicy(PolicyValidationData policyValidationData) throws GatewayException {
if (policyValidationData != null) {
PolicyEvent policyEvent = new PolicyEvent(APIMgtConstants.GatewayEventTypes.POLICY_CREATE);
policyEvent.setId(policyValidationData.getId());
policyEvent.setName(policyValidationData.getName());
policyEvent.setStopOnQuotaReach(policyValidationData.isStopOnQuotaReach());
publishToThrottleTopic(policyEvent);
if (log.isDebugEnabled()) {
log.debug("Policy : " + policyValidationData.getName() + " add event has been successfully published " + "to broker");
}
}
}
use of org.wso2.carbon.apimgt.core.api.Broker in project carbon-apimgt by wso2.
the class APIGatewayPublisherImpl method addAPISubscription.
@Override
public void addAPISubscription(List<SubscriptionValidationData> subscriptionValidationDataList) throws GatewayException {
SubscriptionEvent subscriptionAddEvent = new SubscriptionEvent(APIMgtConstants.GatewayEventTypes.SUBSCRIPTION_CREATE);
subscriptionAddEvent.setSubscriptionsList(subscriptionValidationDataList);
publishToStoreTopic(subscriptionAddEvent);
if (log.isDebugEnabled()) {
log.debug("Subscription created event has been successfully published to broker");
}
}
use of org.wso2.carbon.apimgt.core.api.Broker in project carbon-apimgt by wso2.
the class BrokerManager method loadUsers.
/**
* Loads the users from users.yaml during broker startup
*/
private static void loadUsers() throws ConfigurationException {
Path usersYamlFile;
String usersFilePath = System.getProperty(BrokerSecurityConstants.SYSTEM_PARAM_USERS_CONFIG);
if (usersFilePath == null || usersFilePath.trim().isEmpty()) {
// use current path.
usersYamlFile = Paths.get("", BrokerSecurityConstants.USERS_FILE_NAME).toAbsolutePath();
} else {
usersYamlFile = Paths.get(usersFilePath).toAbsolutePath();
}
ConfigProvider configProvider = ConfigProviderFactory.getConfigProvider(usersYamlFile, null);
UsersFile usersFile = configProvider.getConfigurationObject(BrokerSecurityConstants.USERS_CONFIG_NAMESPACE, UsersFile.class);
if (usersFile != null) {
List<User> users = usersFile.getUsers();
for (User user : users) {
UserStoreManager.addUser(user);
}
}
}
Aggregations