当前位置: 首页>>代码示例>>Java>>正文


Java ModelField.getEncrypt方法代码示例

本文整理汇总了Java中org.ofbiz.entity.model.ModelField.getEncrypt方法的典型用法代码示例。如果您正苦于以下问题:Java ModelField.getEncrypt方法的具体用法?Java ModelField.getEncrypt怎么用?Java ModelField.getEncrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ofbiz.entity.model.ModelField的用法示例。


在下文中一共展示了ModelField.getEncrypt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encryptFields

import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
public void encryptFields(GenericEntity entity) throws GenericEntityException {
    ModelEntity model = entity.getModelEntity();
    String entityName = model.getEntityName();

    Iterator<ModelField> i = model.getFieldsIterator();
    while (i.hasNext()) {
        ModelField field = i.next();
        if (field.getEncrypt()) {
            Object obj = entity.get(field.getName());
            if (obj != null) {
                if (obj instanceof String && UtilValidate.isEmpty(obj)) {
                    continue;
                }
                entity.dangerousSetNoCheckButFast(field, this.encryptFieldValue(entityName, obj));
            }
        }
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:19,代码来源:GenericDelegator.java

示例2: decryptFields

import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
public void decryptFields(GenericEntity entity) throws GenericEntityException {
    ModelEntity model = entity.getModelEntity();
    String entityName = model.getEntityName();

    Iterator<ModelField> i = model.getFieldsIterator();
    while (i.hasNext()) {
        ModelField field = i.next();
        if (field.getEncrypt()) {
            String keyName = entityName;
            if (model instanceof ModelViewEntity) {
                ModelViewEntity modelView = (ModelViewEntity) model;
                keyName = modelView.getAliasedEntity(modelView.getAlias(field.getName()).getEntityAlias(), modelReader).getEntityName();
            }

            String encValue = (String) entity.get(field.getName());
            if (UtilValidate.isNotEmpty(encValue)) {
                try {
                    entity.dangerousSetNoCheckButFast(field, crypto.decrypt(keyName, encValue));
                } catch (EntityCryptoException e) {
                    // not fatal -- allow returning of the encrypted value
                    Debug.logWarning(e, "Problem decrypting field [" + entityName + " / " + field.getName() + "]", module);
                }
            }
        }
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:27,代码来源:GenericDelegator.java

示例3: toString

import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
/**
 * Creates a String for the entity, overrides the default toString
 * This method is secure, it will not display encrypted fields
 *
 *@return String corresponding to this entity
 */
@Override
public String toString() {
    StringBuilder theString = new StringBuilder();
    theString.append("[GenericEntity:");
    theString.append(getEntityName());
    theString.append(']');

    for (String curKey: new TreeSet<String>(fields.keySet())) {
        Object curValue = fields.get(curKey);
        ModelField field = this.getModelEntity().getField(curKey);
        if (field.getEncrypt() && curValue instanceof String) {
            String encryptField = (String) curValue;
            // the encryptField may not actually be UTF8, it could be any
            // random encoding; just treat it as a series of raw bytes.
            // This won't give the same output as the value stored in the
            // database, but should be good enough for printing
            curValue = HashCrypt.cryptBytes(null, null, encryptField.getBytes());
        }
        theString.append('[');
        theString.append(curKey);
        theString.append(',');
        theString.append(curValue);
        theString.append('(');
        theString.append(curValue != null ? curValue.getClass().getName() : "");
        theString.append(')');
        theString.append(']');
    }
    return theString.toString();
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:36,代码来源:GenericEntity.java

示例4: encryptConditionFields

import org.ofbiz.entity.model.ModelField; //导入方法依赖的package包/类
@Override
public void encryptConditionFields(ModelEntity modelEntity, Delegator delegator) {
    if (this.lhs instanceof String) {
        ModelField modelField = modelEntity.getField((String) this.lhs);
        if (modelField != null && modelField.getEncrypt()) {
            if (!(rhs instanceof EntityConditionValue)) {
                try {
                    this.rhs = delegator.encryptFieldValue(modelEntity.getEntityName(), this.rhs);
                } catch (EntityCryptoException e) {
                    Debug.logWarning(e, "Error encrypting field [" + modelEntity.getEntityName() + "." + modelField.getName() + "] with value: " + this.rhs, module);
                }
            }
        }
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:16,代码来源:EntityExpr.java


注:本文中的org.ofbiz.entity.model.ModelField.getEncrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。