本文整理汇总了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);
}
示例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()));
}
}
示例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()));
}
}
示例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()));
}
}
示例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());
}