當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。