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


Java AESEncrypter.encrypt方法代码示例

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


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

示例1: createServiceInstance

import org.oscm.encrypter.AESEncrypter; //导入方法依赖的package包/类
/**
 * Creates and persists a service instance object.
 * 
 * @param status
 *            the status to be set for the service instance
 * @param parameters
 *            the keys for the parameters to be created
 */
private ServiceInstance createServiceInstance(
        final ProvisioningStatus status, final String... parameter)
        throws Exception {

    // Use linked hash map to keep order of entries (for asserts)
    Map<String, Setting> parameters = new LinkedHashMap<>();
    for (String parameterKey : parameter) {
        if (InstanceParameter.PUBLIC_IP.equals(parameterKey)) {
            parameters.put(InstanceParameter.PUBLIC_IP,
                    new Setting(InstanceParameter.PUBLIC_IP, "4.3.2.1"));
        } else {
            String pValue = parameterKey + "Value";
            Setting setting = new Setting(parameterKey, pValue);
            if (parameterKey.endsWith("_PWD")) {
                pValue = AESEncrypter.encrypt(pValue);
                setting.setEncrypted(true);
            }
            parameters.put(parameterKey, setting);
        }
    }
    return createServiceInstance(status, parameters);
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:31,代码来源:APPTimerServiceBeanIT.java

示例2: setDecryptedValue

import org.oscm.encrypter.AESEncrypter; //导入方法依赖的package包/类
public void setDecryptedValue(String parameterValue)
        throws BadResultException {
    try {
        this.attributeValue = isEncrypted()
                ? AESEncrypter.encrypt(parameterValue) : parameterValue;
    } catch (GeneralSecurityException e) {
        throw new BadResultException(String.format(
                "Attribute for key '%s' could not be encrypted",
                getAttributeKey()));
    }
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:12,代码来源:InstanceAttribute.java

示例3: setDecryptedValue

import org.oscm.encrypter.AESEncrypter; //导入方法依赖的package包/类
public void setDecryptedValue(String parameterValue)
        throws BadResultException {
    try {
        this.parameterValue = isEncrypted()
                ? AESEncrypter.encrypt(parameterValue) : parameterValue;
    } catch (GeneralSecurityException e) {
        throw new BadResultException(String.format(
                "Parameter for key '%s' could not be encrypted",
                getParameterKey()));
    }
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:12,代码来源:InstanceParameter.java

示例4: setDecryptedValue

import org.oscm.encrypter.AESEncrypter; //导入方法依赖的package包/类
public void setDecryptedValue(String settingValue)
        throws ConfigurationException {
    try {
        this.settingValue = isEncrypted()
                ? AESEncrypter.encrypt(settingValue) : settingValue;
    } catch (GeneralSecurityException e) {
        throw new ConfigurationException(
                String.format("Setting for key '%s' could not be encrypted",
                        getSettingKey()));
    }
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:12,代码来源:ConfigurationSetting.java

示例5: testEncryptSettingsWithPrefix

import org.oscm.encrypter.AESEncrypter; //导入方法依赖的package包/类
@Test
public void testEncryptSettingsWithPrefix() throws Exception {

    AESEncrypter.generateKey();
    byte[] key = AESEncrypter.getKey();
    Files.write(file.toPath(), key, StandardOpenOption.CREATE_NEW,
            StandardOpenOption.WRITE);

    createContorllerConfigSetting("ctrlId", "key_crypt_PWD",
            "_crypt:secret");
    final Long siKey = createServiceInstanceWithAttributesAndParameters(
            "orgId", "subId", "ctrlId", "key",
            AESEncrypter.encrypt("secret"), true);

    PlatformConfigurationKey[] keys = PlatformConfigurationKey.values();
    for (int i = 0; i < keys.length; i++) {
        if (keys[i] != PlatformConfigurationKey.APP_KEY_PATH) {
            String value = "testValue";
            if (keys[i].name().endsWith(PasswordSetup.CRYPT_KEY_SUFFIX)
                    || keys[i].name().endsWith(
                            PasswordSetup.CRYPT_KEY_SUFFIX_PASS)) {
                value = AESEncrypter.encrypt(value);
            }
            createConfigSetting(keys[i].name(), value);
        }
    }

    createContorllerConfigSetting("ctrlId",
            ControllerConfigurationKey.BSS_USER_KEY.name(), "key");
    createContorllerConfigSetting("ctrlId",
            ControllerConfigurationKey.BSS_USER_ID.name(), "name");
    createContorllerConfigSetting("ctrlId",
            ControllerConfigurationKey.BSS_USER_PWD.name(),
            AESEncrypter.encrypt("secret"));
    createContorllerConfigSetting("ctrlId",
            ControllerConfigurationKey.BSS_ORGANIZATION_ID.name(), "orgId");

    ProvisioningSettings settings = runTX(
            new Callable<ProvisioningSettings>() {
                @Override
                public ProvisioningSettings call() throws Exception {
                    PwdSetup setup = new PwdSetup();
                    setup.em = em;
                    setup.config = config;
                    setup.startUp();

                    ServiceInstance instance = em
                            .getReference(ServiceInstance.class, siKey);
                    return config.getProvisioningSettings(instance, null);
                }
            });

    assertEquals("secret",
            settings.getConfigSettings().get("key_crypt_PWD").getValue());

    assertEquals("secret", settings.getAttributes().get("key").getValue());
    assertEquals("secret", settings.getParameters().get("key").getValue());

}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:60,代码来源:PasswordSetupIT.java


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