use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class PolicyDAOImpl method addApplicationPolicy.
/**
* Adds an Application Policy
*
* @param policy {@link ApplicationPolicy} instance
* @param connection DB Connection instance
* @throws SQLException if an error occurs while adding an Application Policy
*/
private static void addApplicationPolicy(ApplicationPolicy policy, Connection connection) throws SQLException {
final String query = "INSERT INTO AM_APPLICATION_POLICY (UUID, NAME, DISPLAY_NAME, " + "DESCRIPTION, QUOTA_TYPE, QUOTA, QUOTA_UNIT, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, CUSTOM_ATTRIBUTES) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)";
Limit limit = policy.getDefaultQuotaPolicy().getLimit();
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, policy.getUuid());
statement.setString(2, policy.getPolicyName());
statement.setString(3, policy.getDisplayName());
statement.setString(4, policy.getDescription());
statement.setString(5, policy.getDefaultQuotaPolicy().getType());
setDefaultThrottlePolicyDetailsPreparedStmt(limit, statement);
statement.setInt(8, policy.getDefaultQuotaPolicy().getLimit().getUnitTime());
statement.setString(9, policy.getDefaultQuotaPolicy().getLimit().getTimeUnit());
statement.setBoolean(10, policy.isDeployed());
statement.setBytes(11, policy.getCustomAttributes());
statement.execute();
}
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class PolicyDAOImpl method setJWTClaimConditions.
/**
* Add JWT claim conditions of pipeline with pipeline Id: <code>pipelineId</code> to a
* provided {@link Condition} array
*
* @param pipelineId Id of the pipeline
* @param conditions condition array to populate
* @throws SQLException
*/
private void setJWTClaimConditions(int pipelineId, ArrayList<Condition> conditions, Connection connection) throws SQLException {
final String query = "SELECT " + "CLAIM_URI, " + "CLAIM_ATTRIB , IS_CLAIM_MAPPING " + "FROM " + "AM_JWT_CLAIM_CONDITION " + "WHERE " + "CONDITION_GROUP_ID =?";
try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setInt(1, pipelineId);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
JWTClaimsCondition jwtClaimsCondition = new JWTClaimsCondition();
jwtClaimsCondition.setClaimUrl(resultSet.getString(APIMgtConstants.ThrottlePolicyConstants.COLUMN_CLAIM_URI));
jwtClaimsCondition.setAttribute(resultSet.getString(APIMgtConstants.ThrottlePolicyConstants.COLUMN_CLAIM_ATTRIBUTE));
jwtClaimsCondition.setInvertCondition(resultSet.getBoolean(APIMgtConstants.ThrottlePolicyConstants.COLUMN_IS_CLAIM_MAPPING));
conditions.add(jwtClaimsCondition);
}
}
}
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class PolicyDAOImpl method setHeaderConditions.
/**
* Add Header conditions of pipeline with pipeline Id: <code>pipelineId</code> to a
* provided {@link Condition} array
*
* @param connection Connection of the database
* @param pipelineId Id of the pipeline
* @param conditions condition array to populate
* @throws SQLException
*/
private void setHeaderConditions(int pipelineId, ArrayList<Condition> conditions, Connection connection) throws SQLException {
final String query = "SELECT " + "HEADER_FIELD_NAME, " + "HEADER_FIELD_VALUE , IS_HEADER_FIELD_MAPPING " + " FROM " + "AM_HEADER_FIELD_CONDITION " + "WHERE " + "CONDITION_GROUP_ID =?";
try (PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setInt(1, pipelineId);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
HeaderCondition headerCondition = new HeaderCondition();
headerCondition.setHeader(resultSet.getString(APIMgtConstants.ThrottlePolicyConstants.COLUMN_HEADER_FIELD_NAME));
headerCondition.setValue(resultSet.getString(APIMgtConstants.ThrottlePolicyConstants.COLUMN_HEADER_FIELD_VALUE));
headerCondition.setInvertCondition(resultSet.getBoolean(APIMgtConstants.ThrottlePolicyConstants.COLUMN_IS_HEADER_FIELD_MAPPING));
conditions.add(headerCondition);
}
}
}
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class ServiceDiscovererKubernetes method resolveToken.
/**
* Get the token after decrypting using {@link FileEncryptionUtility#readFromEncryptedFile(java.lang.String)}
*
* @return service account token
* @throws ServiceDiscoveryException if an error occurs while resolving the token
*/
private String resolveToken(String encryptedTokenFileName) throws ServiceDiscoveryException {
String token;
try {
String externalSATokenFilePath = System.getProperty(FileEncryptionUtility.CARBON_HOME) + FileEncryptionUtility.SECURITY_DIR + File.separator + encryptedTokenFileName;
token = FileEncryptionUtility.getInstance().readFromEncryptedFile(externalSATokenFilePath);
} catch (APIManagementException e) {
String msg = "Error occurred while resolving externally stored token";
throw new ServiceDiscoveryException(msg, e, ExceptionCodes.ERROR_INITIALIZING_SERVICE_DISCOVERY);
}
return StringUtils.replace(token, "\n", "");
}
use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in the provided Binding.
*
* @param binding WSDL binding
* @return a set of {@link WSDLOperation} defined in the provided Binding
*/
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
Set<WSDLOperation> allBindingOperations = new HashSet<>();
if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
String verb = httpBinding.getVerb();
for (Object opObj : binding.getBindingOperations()) {
if (opObj instanceof BindingOperation) {
BindingOperation bindingOperation = (BindingOperation) opObj;
WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
if (wsdlOperation != null) {
allBindingOperations.add(wsdlOperation);
}
}
}
}
}
return allBindingOperations;
}
Aggregations