Search in sources :

Example 1 with PasswordReplacer

use of jetbrains.buildServer.util.PasswordReplacer in project teamcity-rest by JetBrains.

the class Build method calculateAllParameters.

private static ParametersProvider calculateAllParameters(@NotNull final BuildPromotion buildPromotion, @NotNull PasswordsSearcher searcher) {
    Set<String> passwords = searcher.collectPasswords(buildPromotion);
    ParametersProvider provider = ((BuildPromotionEx) buildPromotion).getParametersProvider();
    if (passwords.isEmpty()) {
        return provider;
    }
    PasswordReplacer passwordReplacer = PasswordParametersFilterCore.createPasswordReplacer(passwords);
    return new ParametersProvider() {

        @Nullable
        @Override
        public String get(@NotNull final String key) {
            return Util.resolveNull(provider.get(key), passwordReplacer::replacePasswords);
        }

        @Override
        public int size() {
            return provider.size();
        }

        @Override
        public Map<String, String> getAll() {
            return provider.getAll().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> passwordReplacer.replacePasswords(e.getValue())));
        }
    };
}
Also used : MetadataStorageEx(jetbrains.buildServer.serverSide.metadata.impl.MetadataStorageEx) BuildProblem(jetbrains.buildServer.serverSide.problems.BuildProblem) Files(jetbrains.buildServer.server.rest.model.files.Files) VcsModificationHistory(jetbrains.buildServer.vcs.VcsModificationHistory) Agent(jetbrains.buildServer.server.rest.model.agent.Agent) AuthorityHolder(jetbrains.buildServer.serverSide.auth.AuthorityHolder) BuildDependency(jetbrains.buildServer.serverSide.dependency.BuildDependency) PasswordReplacer(jetbrains.buildServer.util.PasswordReplacer) BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) ActionTypesFilter(jetbrains.buildServer.serverSide.impl.audit.filters.ActionTypesFilter) jetbrains.buildServer.server.rest.data(jetbrains.buildServer.server.rest.data) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) BigDecimal(java.math.BigDecimal) OperationException(jetbrains.buildServer.server.rest.errors.OperationException) ActionType(jetbrains.buildServer.serverSide.audit.ActionType) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) AccessDeniedException(jetbrains.buildServer.serverSide.auth.AccessDeniedException) RevisionsNotFoundException(jetbrains.buildServer.vcs.impl.RevisionsNotFoundException) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) StringUtil(jetbrains.buildServer.util.StringUtil) LogUtil(jetbrains.buildServer.serverSide.impl.LogUtil) Logger(com.intellij.openapi.diagnostic.Logger) CollectionsUtil(jetbrains.buildServer.util.CollectionsUtil) ModelDescription(jetbrains.buildServer.server.rest.swagger.annotations.ModelDescription) AuditLogAction(jetbrains.buildServer.serverSide.audit.AuditLogAction) CanceledInfo(jetbrains.buildServer.serverSide.userChanges.CanceledInfo) SelectPrevBuildPolicy(jetbrains.buildServer.vcs.SelectPrevBuildPolicy) WaitReason(jetbrains.buildServer.serverSide.buildDistribution.WaitReason) AgentTypeFinder(jetbrains.buildServer.serverSide.agentTypes.AgentTypeFinder) AgentRestrictor(jetbrains.buildServer.AgentRestrictor) ServiceLocator(jetbrains.buildServer.ServiceLocator) BaseBuild(jetbrains.buildServer.serverSide.impl.BaseBuild) UserModel(jetbrains.buildServer.users.UserModel) jetbrains.buildServer.serverSide(jetbrains.buildServer.serverSide) Changes(jetbrains.buildServer.server.rest.model.change.Changes) BuildProblemImpl(jetbrains.buildServer.serverSide.impl.problems.BuildProblemImpl) TagFinder(jetbrains.buildServer.server.rest.data.build.TagFinder) Revisions(jetbrains.buildServer.server.rest.model.change.Revisions) Collectors(java.util.stream.Collectors) ChangesBean(jetbrains.buildServer.controllers.changes.ChangesBean) ProblemOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.ProblemOccurrenceFinder) Nullable(org.jetbrains.annotations.Nullable) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) InvalidStateException(jetbrains.buildServer.server.rest.errors.InvalidStateException) BuildAgent(jetbrains.buildServer.BuildAgent) RevisionRule(jetbrains.buildServer.artifacts.RevisionRule) PasswordParametersFilterCore(jetbrains.buildServer.parameters.PasswordParametersFilterCore) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) AgentRestrictorType(jetbrains.buildServer.AgentRestrictorType) Branch(jetbrains.buildServer.serverSide.Branch) BuildChangeData(jetbrains.buildServer.server.rest.data.change.BuildChangeData) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) NotNull(org.jetbrains.annotations.NotNull) SVcsModification(jetbrains.buildServer.vcs.SVcsModification) ChangesPopupUtil(jetbrains.buildServer.controllers.changes.ChangesPopupUtil) java.util(java.util) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) User(jetbrains.buildServer.server.rest.model.user.User) Converter(jetbrains.buildServer.util.Converter) IssueUsages(jetbrains.buildServer.server.rest.model.issue.IssueUsages) Hex(org.apache.commons.codec.binary.Hex) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ParametersProvider(jetbrains.buildServer.parameters.ParametersProvider) jetbrains.buildServer.server.rest.model(jetbrains.buildServer.server.rest.model) Agents(jetbrains.buildServer.server.rest.model.agent.Agents) AgentPool(jetbrains.buildServer.serverSide.agentPools.AgentPool) Element(jetbrains.buildServer.util.browser.Element) PropEntitiesArtifactDep(jetbrains.buildServer.server.rest.model.buildType.PropEntitiesArtifactDep) XmlType(javax.xml.bind.annotation.XmlType) PasswordsSearcher(jetbrains.buildServer.serverSide.parameters.types.PasswordsSearcher) SAgentType(jetbrains.buildServer.serverSide.agentTypes.SAgentType) RevisionRules(jetbrains.buildServer.artifacts.RevisionRules) Revision(jetbrains.buildServer.server.rest.model.change.Revision) ProblemOccurrences(jetbrains.buildServer.server.rest.model.problem.ProblemOccurrences) XmlAttribute(javax.xml.bind.annotation.XmlAttribute) BuildChanges(jetbrains.buildServer.server.rest.model.change.BuildChanges) Properties(jetbrains.buildServer.server.rest.model.Properties) CachingValue(jetbrains.buildServer.server.rest.util.CachingValue) IOException(java.io.IOException) ArtifactDependencyChangesProvider(jetbrains.buildServer.serverSide.impl.changeProviders.ArtifactDependencyChangesProvider) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) ValueWithDefault(jetbrains.buildServer.server.rest.util.ValueWithDefault) DownloadedArtifacts(jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.DownloadedArtifacts) DownloadedArtifactsLoggerImpl(jetbrains.buildServer.serverSide.impl.DownloadedArtifactsLoggerImpl) jetbrains.buildServer.server.rest.request(jetbrains.buildServer.server.rest.request) MapParametersProviderImpl(jetbrains.buildServer.parameters.impl.MapParametersProviderImpl) VcsLabelManager(jetbrains.buildServer.serverSide.vcs.VcsLabelManager) FileApiUrlBuilder(jetbrains.buildServer.server.rest.model.files.FileApiUrlBuilder) Permission(jetbrains.buildServer.serverSide.auth.Permission) BuildMetadataEntry(jetbrains.buildServer.serverSide.metadata.BuildMetadataEntry) SUser(jetbrains.buildServer.users.SUser) XmlElement(javax.xml.bind.annotation.XmlElement) ParametersProvider(jetbrains.buildServer.parameters.ParametersProvider) NotNull(org.jetbrains.annotations.NotNull) PasswordReplacer(jetbrains.buildServer.util.PasswordReplacer)

Aggregations

Logger (com.intellij.openapi.diagnostic.Logger)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 java.util (java.util)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 XmlAttribute (javax.xml.bind.annotation.XmlAttribute)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)1 XmlType (javax.xml.bind.annotation.XmlType)1 AgentRestrictor (jetbrains.buildServer.AgentRestrictor)1 AgentRestrictorType (jetbrains.buildServer.AgentRestrictorType)1 BuildAgent (jetbrains.buildServer.BuildAgent)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 RevisionRule (jetbrains.buildServer.artifacts.RevisionRule)1 RevisionRules (jetbrains.buildServer.artifacts.RevisionRules)1 ChangesBean (jetbrains.buildServer.controllers.changes.ChangesBean)1 ChangesPopupUtil (jetbrains.buildServer.controllers.changes.ChangesPopupUtil)1 ParametersProvider (jetbrains.buildServer.parameters.ParametersProvider)1