Search in sources :

Example 6 with SecureMask

use of org.sagacity.sqltoy.config.model.SecureMask in project sagacity-sqltoy by chenrenfei.

the class ResultUtils method secureMask.

/**
 * @todo 对字段进行安全脱敏
 * @param desensitizeProvider
 * @param rows
 * @param masks
 * @param labelIndexMap
 */
private static void secureMask(DesensitizeProvider desensitizeProvider, List<List> rows, Iterator<SecureMask> masks, LabelIndexModel labelIndexMap) {
    Integer index;
    Object value;
    SecureMask mask;
    int columnIndex;
    while (masks.hasNext()) {
        mask = masks.next();
        index = labelIndexMap.get(mask.getColumn());
        if (index != null) {
            columnIndex = index.intValue();
            for (List row : rows) {
                value = row.get(columnIndex);
                if (value != null) {
                    row.set(columnIndex, desensitizeProvider.desensitize(value.toString(), mask));
                }
            }
        }
    }
}
Also used : SecureMask(org.sagacity.sqltoy.config.model.SecureMask) ReverseList(org.sagacity.sqltoy.plugins.calculator.ReverseList) List(java.util.List) ArrayList(java.util.ArrayList) UnpivotList(org.sagacity.sqltoy.plugins.calculator.UnpivotList)

Example 7 with SecureMask

use of org.sagacity.sqltoy.config.model.SecureMask in project sagacity-sqltoy by chenrenfei.

the class EntityQuery method secureMask.

/**
 * @TODO 对结果字段进行安全脱敏
 * @param maskType
 * @param columns
 * @return
 */
public EntityQuery secureMask(MaskType maskType, String... columns) {
    if (maskType != null && columns != null && columns.length > 0) {
        for (String column : columns) {
            SecureMask mask = new SecureMask();
            mask.setColumn(column);
            mask.setType(maskType.getValue());
            innerModel.secureMask.put(column, mask);
        }
    }
    return this;
}
Also used : SecureMask(org.sagacity.sqltoy.config.model.SecureMask)

Aggregations

SecureMask (org.sagacity.sqltoy.config.model.SecureMask)7 ArrayList (java.util.ArrayList)4 List (java.util.List)3 ReverseList (org.sagacity.sqltoy.plugins.calculator.ReverseList)2 UnpivotList (org.sagacity.sqltoy.plugins.calculator.UnpivotList)2 Element (org.dom4j.Element)1 ColsChainRelativeModel (org.sagacity.sqltoy.config.model.ColsChainRelativeModel)1 FormatModel (org.sagacity.sqltoy.config.model.FormatModel)1 LabelIndexModel (org.sagacity.sqltoy.config.model.LabelIndexModel)1 PivotModel (org.sagacity.sqltoy.config.model.PivotModel)1 ReverseModel (org.sagacity.sqltoy.config.model.ReverseModel)1 RowsChainRelativeModel (org.sagacity.sqltoy.config.model.RowsChainRelativeModel)1 SummaryModel (org.sagacity.sqltoy.config.model.SummaryModel)1 UnpivotModel (org.sagacity.sqltoy.config.model.UnpivotModel)1 Element (org.w3c.dom.Element)1