org.sonar.api.config.Encryption.setPathToSecretKey()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.sonar.api.config.Encryption.setPathToSecretKey()方法的一些代码示例,展示了Encryption.setPathToSecretKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Encryption.setPathToSecretKey()方法的具体详情如下:
包路径:org.sonar.api.config.Encryption
类名称:Encryption
方法名:setPathToSecretKey

Encryption.setPathToSecretKey介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@VisibleForTesting
ThreadLocalSettings(PropertyDefinitions definitions, Properties props, SettingLoader settingLoader) {
 super(definitions, new Encryption(null));
 this.settingLoader = settingLoader;
 props.forEach((k, v) -> systemProps.put(k, v == null ? null : v.toString().trim()));
 // TODO something wrong about lifecycle here. It could be improved
 getEncryption().setPathToSecretKey(props.getProperty(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
}

代码示例来源:origin: SonarSource/sonarqube

@Before
public void setUpSecretKey() throws Exception {
 logInAsSystemAdministrator();
 File secretKeyFile = folder.newFile();
 FileUtils.writeStringToFile(secretKeyFile, "fCVFf/JHRi8Qwu5KLNva7g==");
 encryption.setPathToSecretKey(secretKeyFile.getAbsolutePath());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void false_when_no_secret_key() {
 logInAsSystemAdministrator();
 encryption.setPathToSecretKey("unknown/path/to_secret_key.txt");
 CheckSecretKeyWsResponse result = call();
 assertThat(result.getSecretKeyAvailable()).isFalse();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void generate_valid_secret_key() throws IOException {
 GenerateSecretKeyWsResponse result = call();
 String secretKey = result.getSecretKey();
 File file = temporaryFolder.newFile();
 FileUtils.writeStringToFile(file, secretKey);
 encryption.setPathToSecretKey(file.getAbsolutePath());
 String encryptedValue = encryption.encrypt("my value");
 String decryptedValue = encryption.decrypt(encryptedValue);
 assertThat(decryptedValue).isEqualTo("my value");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_secret_key_available() {
 logInAsSystemAdministrator();
 encryption.setPathToSecretKey("unknown/path/to/secret/key");
 expectedException.expect(BadRequestException.class);
 expectedException.expectMessage("No secret key available");
 call("my value");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void json_example() throws IOException {
 logInAsSystemAdministrator();
 File secretKeyFile = temporaryFolder.newFile();
 FileUtils.writeStringToFile(secretKeyFile, "fCVFf/JHRi8Qwu5KLNva7g==");
 encryption.setPathToSecretKey(secretKeyFile.getAbsolutePath());
 String result = ws.newRequest().execute().getInput();
 assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@VisibleForTesting
ThreadLocalSettings(PropertyDefinitions definitions, Properties props, SettingLoader settingLoader) {
 super(definitions, new Encryption(null));
 this.settingLoader = settingLoader;
 this.systemProps = new Properties();
 props.forEach((k, v) -> systemProps.put(k, v == null ? null : v.toString().trim()));
 // TODO something wrong about lifecycle here. It could be improved
 getEncryption().setPathToSecretKey(props.getProperty(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectReferentials,
 DefaultAnalysisMode analysisMode) {
 super(batchSettings.getDefinitions());
 this.projectReferentials = projectReferentials;
 this.analysisMode = analysisMode;
 getEncryption().setPathToSecretKey(batchSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 LoggerFactory.getLogger(ModuleSettings.class).info("Load module settings");
 init(moduleDefinition, batchSettings);
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

public ProjectSettings(ProjectReactor reactor, GlobalSettings globalSettings, PropertyDefinitions propertyDefinitions,
 ProjectRepositories projectReferentials, DefaultAnalysisMode mode) {
 super(propertyDefinitions);
 this.mode = mode;
 getEncryption().setPathToSecretKey(globalSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 this.globalSettings = globalSettings;
 this.projectReferentials = projectReferentials;
 init(reactor);
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

public GlobalSettings(BootstrapProperties bootstrapProps, PropertyDefinitions propertyDefinitions,
 GlobalRepositories globalReferentials, DefaultAnalysisMode mode) {
 super(propertyDefinitions);
 this.mode = mode;
 getEncryption().setPathToSecretKey(bootstrapProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 this.bootstrapProps = bootstrapProps;
 this.globalReferentials = globalReferentials;
 init();
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

public ProjectSettings(ProjectReactor reactor, GlobalSettings globalSettings, PropertyDefinitions propertyDefinitions,
 ProjectRepositories projectRepositories, DefaultAnalysisMode mode) {
 super(propertyDefinitions);
 this.mode = mode;
 getEncryption().setPathToSecretKey(globalSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 this.globalSettings = globalSettings;
 this.projectRepositories = projectRepositories;
 init(reactor);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

public ModuleSettings(GlobalSettings batchSettings, ProjectDefinition moduleDefinition, ProjectRepositories projectSettingsRepo,
 DefaultAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) {
 super(batchSettings.getDefinitions());
 this.projectRepos = projectSettingsRepo;
 this.analysisMode = analysisMode;
 getEncryption().setPathToSecretKey(batchSettings.getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 init(moduleDefinition, batchSettings);
 contextReportPublisher.dumpSettings(moduleDefinition, this);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

public GlobalSettings(GlobalProperties bootstrapProps, PropertyDefinitions propertyDefinitions,
 GlobalRepositories globalReferentials, GlobalMode mode) {
 super(propertyDefinitions);
 this.mode = mode;
 getEncryption().setPathToSecretKey(bootstrapProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
 this.bootstrapProps = bootstrapProps;
 this.globalReferentials = globalReferentials;
 init();
 new DroppedPropertyChecker(this.getProperties(), DROPPED_PROPERTIES).checkDroppedProperties();
}

相关文章