jetbrains.buildServer.serverSide.crypt.RSACipher Java Examples

The following examples show how to use jetbrains.buildServer.serverSide.crypt.RSACipher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginPropertiesUtil.java    From teamcity-kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
private static void setEncryptedProperty(final String paramName, final HttpServletRequest request,
                                         final BasePropertiesBean bean, final boolean includeEmptyValues) {
    String propName = paramName.substring(ENCRYPTED_PROPERTY_PREFIX.length());
    String propertyValue = RSACipher.decryptWebRequestData(request.getParameter(paramName));
    if (propertyValue != null && (includeEmptyValues || propertyValue.length() > 0)) {
        bean.setProperty(propName, toUnixLineFeeds(propertyValue));
    }
}
 
Example #2
Source File: SlackNotifierSettingsController.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
private HashMap<String, Object> handleConfigurationChange(HttpServletRequest request) throws IOException, SlackConfigValidationException {
    setRequestParams(request);
    if(!isNullOrEmpty(proxyPassword)){
        proxyPassword = RSACipher.decryptWebRequestData(proxyPassword);
    }

    Validate(teamName, token, botName, iconUrl, defaultChannel, maxCommitsToDisplay, showBuildAgent, proxyHost, proxyPort, proxyUser, proxyPassword);

    this.config.setTeamName(teamName);
    this.config.setToken(token);
    this.config.getContent().setBotName(botName);
    this.config.getContent().setIconUrl(iconUrl);
    this.config.setDefaultChannel(defaultChannel);
    this.config.getContent().setMaxCommitsToDisplay(Integer.parseInt(maxCommitsToDisplay));
    this.config.getContent().setShowBuildAgent(Boolean.parseBoolean(showBuildAgent));
    this.config.getContent().setShowCommits(Boolean.parseBoolean(showCommits));
    this.config.getContent().setShowCommitters(Boolean.parseBoolean(showCommitters));
    this.config.setFilterBranchName(filterBranchName);
    this.config.getContent().setShowTriggeredBy(Boolean.parseBoolean(showTriggeredBy));
    this.config.getContent().setShowElapsedBuildTime((Boolean.parseBoolean(showElapsedBuildTime)));
    this.config.getContent().setShowFailureReason((Boolean.parseBoolean(showFailureReason)));

    this.config.setProxyHost(proxyHost);
    this.config.setProxyPort(isNullOrEmpty(proxyPort) ? null : Integer.parseInt(proxyPort));
    this.config.setProxyUsername(proxyUser);
    this.config.setProxyPassword(proxyPassword);

    this.config.save();

    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("message", "Saved");
    return params;
}
 
Example #3
Source File: SlackNotifierAdminPage.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
@Override
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request){
    super.fillModel(model, request);
    slackMainSettings.refresh();
    model.put("teamName", this.slackMainSettings.getTeamName());
    model.put("token", this.slackMainSettings.getToken());
    model.put("botName", this.slackMainSettings.getBotName());
    model.put("iconUrl", this.slackMainSettings.getIconUrl());
    model.put("defaultChannel", this.slackMainSettings.getDefaultChannel());
    model.put("maxCommitsToDisplay", this.slackMainSettings.getMaxCommitsToDisplay());
    model.put("showBuildAgent", this.slackMainSettings.getShowBuildAgent());
    model.put("showCommits", this.slackMainSettings.getShowCommits());
    model.put("showCommitters", this.slackMainSettings.getShowCommitters());
    model.put("showTriggeredBy", this.slackMainSettings.getShowTriggeredBy());
    model.put("showElapsedBuildTime", this.slackMainSettings.getShowElapsedBuildTime());
    model.put("showFailureReason", this.slackMainSettings.getShowFailureReason());

    SlackNotificationProxyConfig proxyConfig = this.slackMainSettings.getProxyConfig();
    model.put("proxyHost", proxyConfig.getProxyHost());
    model.put("proxyPort", proxyConfig.getProxyPort());
    model.put("proxyUser", proxyConfig.getCreds() == null ? null : proxyConfig.getCreds().getUserPrincipal().getName());
    model.put("proxyPassword", proxyConfig.getCreds() == null ? null : proxyConfig.getCreds().getPassword());
    model.put("encryptedProxyPassword", proxyConfig.getCreds() == null || proxyConfig.getCreds().getPassword() == null ? null : RSACipher.encryptDataForWeb(proxyConfig.getCreds().getPassword()));
    model.put("hexEncodedPublicKey", RSACipher.getHexEncodedPublicKey());

    try {
        model.put("pluginVersion", this.slackMainSettings.getPluginVersion());
    } catch (IOException e) {
        Loggers.ACTIVITIES.error("Could not retrieve slack plugin version", e);
    }

    model.put("disabled", !this.slackMainSettings.getEnabled());
    model.put("jspHome", this.jspHome);
}
 
Example #4
Source File: TelegramSettingsBean.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
public String getHexEncodedPublicKey() {
  return RSACipher.getHexEncodedPublicKey();
}
 
Example #5
Source File: TelegramSettingsBean.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
public String getEncryptedBotToken() {
  return StringUtil.isEmpty(botToken) ? "" : RSACipher.encryptDataForWeb(botToken);
}
 
Example #6
Source File: TelegramSettingsBean.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
public void setEncryptedBotToken(String encrypted) {
  this.botToken = RSACipher.decryptWebRequestData(encrypted);
}
 
Example #7
Source File: TelegramSettingsBean.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
public String getEncryptedProxyPassword() {
  return StringUtil.isEmpty(proxyPassword) ? "" : RSACipher.encryptDataForWeb(proxyPassword);
}
 
Example #8
Source File: TelegramSettingsBean.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
public void setEncryptedProxyPassword(String encrypted) {
  this.proxyPassword = RSACipher.decryptWebRequestData(encrypted);
}
 
Example #9
Source File: S3StoragePropertiesUtil.java    From teamcity-s3-artifact-storage-plugin with Apache License 2.0 4 votes vote down vote up
@NotNull
private static Property encryptedProperty(@NotNull final String paramName, @NotNull final HttpServletRequest request) {
  final String encryptedValue = RSACipher.decryptWebRequestData(request.getParameter(paramName));
  return Property.of(encodedPropertyName(paramName), toUnixLineFeeds(encryptedValue));
}
 
Example #10
Source File: ManageSQSActionController.java    From TeamCity.SonarQubePlugin with Apache License 2.0 4 votes vote down vote up
private String decryptIfNeeded(@Nullable final String value) {
    return value != null ? RSACipher.decryptWebRequestData(value) : null;
}