Search in sources :

Example 1 with FilterTreeBuilder

use of org.wso2.carbon.identity.core.model.FilterTreeBuilder in project carbon-identity-framework by wso2.

the class IdentityProviderManager method getExpressionNodes.

/**
 * Get the filter node as a list.
 *
 * @param filter value of the filter.
 * @return node tree.
 * @throws IdentityProviderManagementClientException Error when validate filters.
 */
private List<ExpressionNode> getExpressionNodes(String filter) throws IdentityProviderManagementClientException {
    // Filter example : name sw "te" and name ew "st" and isEnabled eq "true".
    List<ExpressionNode> expressionNodes = new ArrayList<>();
    FilterTreeBuilder filterTreeBuilder;
    try {
        if (StringUtils.isNotBlank(filter)) {
            filterTreeBuilder = new FilterTreeBuilder(filter);
            Node rootNode = filterTreeBuilder.buildTree();
            setExpressionNodeList(rootNode, expressionNodes);
        }
    } catch (IOException | IdentityException e) {
        String message = "Error occurred while validate filter, filter: " + filter;
        throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_RETRIEVE_IDP, message, e);
    }
    return expressionNodes;
}
Also used : FilterTreeBuilder(org.wso2.carbon.identity.core.model.FilterTreeBuilder) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) OperationNode(org.wso2.carbon.identity.core.model.OperationNode) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) Node(org.wso2.carbon.identity.core.model.Node) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IdentityException(org.wso2.carbon.identity.base.IdentityException)

Example 2 with FilterTreeBuilder

use of org.wso2.carbon.identity.core.model.FilterTreeBuilder in project identity-api-server by wso2.

the class ServerApplicationManagementService method buildFilterNode.

private ExpressionNode buildFilterNode(String filter) {
    if (StringUtils.isNotBlank(filter)) {
        try {
            FilterTreeBuilder filterTreeBuilder = new FilterTreeBuilder(filter);
            Node rootNode = filterTreeBuilder.buildTree();
            if (rootNode instanceof ExpressionNode) {
                ExpressionNode expressionNode = (ExpressionNode) rootNode;
                if (SEARCH_SUPPORTED_FIELDS.contains(expressionNode.getAttributeValue())) {
                    return expressionNode;
                } else {
                    throw buildClientError(ErrorMessage.UNSUPPORTED_FILTER_ATTRIBUTE, expressionNode.getAttributeValue());
                }
            } else {
                throw buildClientError(ErrorMessage.INVALID_FILTER_FORMAT);
            }
        } catch (IOException | IdentityException e) {
            throw buildClientError(ApplicationManagementConstants.ErrorMessage.INVALID_FILTER_FORMAT, null);
        }
    } else {
        return null;
    }
}
Also used : FilterTreeBuilder(org.wso2.carbon.identity.core.model.FilterTreeBuilder) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) Node(org.wso2.carbon.identity.core.model.Node) IOException(java.io.IOException) IdentityException(org.wso2.carbon.identity.base.IdentityException)

Example 3 with FilterTreeBuilder

use of org.wso2.carbon.identity.core.model.FilterTreeBuilder in project identity-api-server by wso2.

the class ServerAuthenticatorManagementService method getExpressionNodesForIdp.

private List<ExpressionNode> getExpressionNodesForIdp(String filter) {
    // Filter example : name sw go and (tag eq 2fa or tag eq Social-Login)
    List<ExpressionNode> expressionNodes = new ArrayList<>();
    FilterTreeBuilder filterTreeBuilder;
    try {
        if (StringUtils.isNotBlank(filter)) {
            filterTreeBuilder = new FilterTreeBuilder(filter);
            Node rootNode = filterTreeBuilder.buildTree();
            setExpressionNodeListForIdp(rootNode, expressionNodes);
        }
    } catch (IOException | IdentityException e) {
        throw buildClientError(Constants.ErrorMessage.ERROR_CODE_INVALID_FILTER_FORMAT, null);
    }
    return expressionNodes;
}
Also used : FilterTreeBuilder(org.wso2.carbon.identity.core.model.FilterTreeBuilder) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) OperationNode(org.wso2.carbon.identity.core.model.OperationNode) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) Node(org.wso2.carbon.identity.core.model.Node) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IdentityException(org.wso2.carbon.identity.base.IdentityException)

Example 4 with FilterTreeBuilder

use of org.wso2.carbon.identity.core.model.FilterTreeBuilder in project identity-api-server by wso2.

the class ServerAuthenticatorManagementService method getExpressionNodesForAuthenticator.

private List<ExpressionNode> getExpressionNodesForAuthenticator(String filter) {
    // Filter example : name sw go and (tag eq 2fa or tag eq Social-Login)
    List<ExpressionNode> expressionNodes = new ArrayList<>();
    FilterTreeBuilder filterTreeBuilder;
    try {
        if (StringUtils.isNotBlank(filter)) {
            filterTreeBuilder = new FilterTreeBuilder(filter);
            Node rootNode = filterTreeBuilder.buildTree();
            validateFilter(rootNode);
            setExpressionNodeListForAuthenticator(rootNode, expressionNodes);
        }
    } catch (IOException | IdentityException e) {
        throw buildClientError(Constants.ErrorMessage.ERROR_CODE_INVALID_FILTER_FORMAT, null);
    }
    return expressionNodes;
}
Also used : FilterTreeBuilder(org.wso2.carbon.identity.core.model.FilterTreeBuilder) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) OperationNode(org.wso2.carbon.identity.core.model.OperationNode) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) Node(org.wso2.carbon.identity.core.model.Node) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IdentityException(org.wso2.carbon.identity.base.IdentityException)

Aggregations

IOException (java.io.IOException)4 IdentityException (org.wso2.carbon.identity.base.IdentityException)4 ExpressionNode (org.wso2.carbon.identity.core.model.ExpressionNode)4 FilterTreeBuilder (org.wso2.carbon.identity.core.model.FilterTreeBuilder)4 Node (org.wso2.carbon.identity.core.model.Node)4 ArrayList (java.util.ArrayList)3 OperationNode (org.wso2.carbon.identity.core.model.OperationNode)3