├── .gitignore ├── .travis.yml ├── DEVELOPER_README.txt ├── EULA.txt ├── Hub Workflow.png ├── LICENSE ├── README.md ├── Synopsys Privacy Policy.txt ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── blackducksoftware │ │ └── integration │ │ └── jira │ │ ├── blackduck │ │ ├── BlackDuckAssignUtil.java │ │ ├── BlackDuckConnectionHelper.java │ │ └── BlackDuckDataHelper.java │ │ ├── common │ │ ├── BlackDuckJiraConstants.java │ │ ├── BlackDuckPluginDateFormatter.java │ │ ├── BlackDuckWorkflowStatus.java │ │ ├── JiraUserContext.java │ │ ├── WorkflowHelper.java │ │ ├── exception │ │ │ ├── ConfigurationException.java │ │ │ ├── IssueModelBuilderException.java │ │ │ ├── JiraException.java │ │ │ └── JiraIssueException.java │ │ └── model │ │ │ ├── PluginBlackDuckServerConfigModel.java │ │ │ ├── PluginField.java │ │ │ └── PluginGroupsConfigModel.java │ │ ├── data │ │ ├── BlackDuckConfigKeys.java │ │ ├── PluginConfigKeys.java │ │ └── accessor │ │ │ ├── GlobalConfigurationAccessor.java │ │ │ ├── JiraSettingsAccessor.java │ │ │ ├── MigrationAccessor.java │ │ │ ├── PluginConfigurationAccessor.java │ │ │ └── PluginErrorAccessor.java │ │ ├── issue │ │ ├── conversion │ │ │ ├── BomNotificationToIssueModelConverter.java │ │ │ ├── TicketGenerator.java │ │ │ └── output │ │ │ │ ├── AlertIssueSearchProperties.java │ │ │ │ ├── BlackDuckIssueAction.java │ │ │ │ ├── IssueProperties.java │ │ │ │ └── OldIssueProperties.java │ │ ├── handler │ │ │ ├── BlackDuckProjectMappings.java │ │ │ ├── DataFormatHelper.java │ │ │ ├── IssueEditor.java │ │ │ ├── IssueFieldCopyMappingHandler.java │ │ │ ├── JiraIssueHandler.java │ │ │ ├── JiraIssuePropertyWrapper.java │ │ │ ├── JiraIssueServiceWrapper.java │ │ │ └── NotificationVulnerability.java │ │ ├── model │ │ │ ├── BlackDuckIssueFieldTemplate.java │ │ │ ├── BlackDuckIssueModel.java │ │ │ ├── BlackDuckIssueModelBuilder.java │ │ │ ├── GeneralIssueCreationConfigModel.java │ │ │ ├── IssueCategory.java │ │ │ ├── JiraIssueFieldTemplate.java │ │ │ ├── PluginIssueCreationConfigModel.java │ │ │ ├── PluginIssueFieldConfigModel.java │ │ │ ├── ProjectMappingConfigModel.java │ │ │ └── TicketCriteriaConfigModel.java │ │ ├── tracker │ │ │ ├── IssueEventListener.java │ │ │ ├── IssueTrackerHandler.java │ │ │ ├── IssueTrackerProperties.java │ │ │ └── IssueTrackerTask.java │ │ └── ui │ │ │ ├── BlackDuckIssuePanel.java │ │ │ ├── BlackDuckIssuePanelCondition.java │ │ │ └── JiraFieldUtils.java │ │ ├── task │ │ ├── BlackDuckJiraTask.java │ │ ├── BlackDuckJobRunner.java │ │ ├── BlackDuckJobRunnerUtil.java │ │ ├── BlackDuckMonitor.java │ │ ├── JiraDeploymentType.java │ │ ├── JiraTaskTimed.java │ │ ├── NotificationMonitor.java │ │ ├── maintenance │ │ │ ├── AlertMigrationRunner.java │ │ │ ├── BlackDuckMaintenanceJobRunner.java │ │ │ └── CleanUpOrphanedTicketsTask.java │ │ └── thread │ │ │ └── PluginExecutorService.java │ │ ├── web │ │ ├── BlackDuckPluginVersion.java │ │ ├── ErrorTracking.java │ │ ├── JiraConfigDeserializer.java │ │ ├── JiraConfigErrorStrings.java │ │ ├── JiraServices.java │ │ ├── TicketCreationError.java │ │ ├── action │ │ │ ├── AccessConfigActions.java │ │ │ ├── BlackDuckConfigActions.java │ │ │ ├── IssueCreationConfigActions.java │ │ │ ├── IssueFieldMappingConfigActions.java │ │ │ ├── MigrationActions.java │ │ │ ├── ProjectMappingConfigActions.java │ │ │ └── UserAssignThread.java │ │ ├── controller │ │ │ ├── AccessConfigController.java │ │ │ ├── AuthorizationChecker.java │ │ │ ├── BlackDuckConfigController.java │ │ │ ├── BlackDuckJiraConfigController.java │ │ │ ├── ConfigController.java │ │ │ ├── IssueCreationConfigController.java │ │ │ ├── IssueFieldMappingConfigController.java │ │ │ └── MigrationController.java │ │ ├── model │ │ │ ├── BlackDuckAdminConfigSerializable.java │ │ │ ├── BlackDuckJiraConfigSerializable.java │ │ │ ├── BlackDuckJiraFieldCopyConfigSerializable.java │ │ │ ├── BlackDuckProject.java │ │ │ ├── BlackDuckProjectMapping.java │ │ │ ├── BlackDuckServerConfigSerializable.java │ │ │ ├── Fields.java │ │ │ ├── IdToNameMapping.java │ │ │ ├── JiraProject.java │ │ │ ├── MigrationDetails.java │ │ │ ├── PolicyRuleSerializable.java │ │ │ ├── ProjectFieldCopyMapping.java │ │ │ ├── ProjectPatternRestModel.java │ │ │ └── TicketCreationErrorSerializable.java │ │ └── servlet │ │ │ ├── BlackDuckJiraServlet.java │ │ │ └── LoginRedirect.java │ │ └── workflow │ │ ├── notification │ │ ├── CommonNotificationService.java │ │ ├── CommonNotificationView.java │ │ ├── CommonNotificationViewResults.java │ │ ├── NotificationContentDetail.java │ │ ├── NotificationContentDetailFactory.java │ │ ├── NotificationDetailResult.java │ │ ├── NotificationDetailResults.java │ │ └── NotificationResults.java │ │ └── setup │ │ ├── BlackDuckAvatars.java │ │ ├── BlackDuckFieldConfigurationSetup.java │ │ ├── BlackDuckFieldScreenSchemeSetup.java │ │ ├── BlackDuckIssueTypeSetup.java │ │ ├── BlackDuckWorkflowSetup.java │ │ ├── PreTaskSetup.java │ │ └── UpgradeSteps.java └── resources │ ├── Design_v01.png │ ├── Hub Workflow.xml │ ├── atlassian-plugin.xml │ ├── com │ └── blackducksoftware │ │ └── integration │ │ └── jira │ │ └── i18n_6.properties │ ├── css │ ├── blackduck-jira-issue-panel.css │ └── blackduck-jira.css │ ├── font-awesome-4.5.0 │ ├── css │ │ ├── font-awesome.css │ │ └── font-awesome.min.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── less │ │ ├── animated.less │ │ ├── bordered-pulled.less │ │ ├── core.less │ │ ├── fixed-width.less │ │ ├── font-awesome.less │ │ ├── icons.less │ │ ├── larger.less │ │ ├── list.less │ │ ├── mixins.less │ │ ├── path.less │ │ ├── rotated-flipped.less │ │ ├── stacked.less │ │ └── variables.less │ └── scss │ │ ├── _animated.scss │ │ ├── _bordered-pulled.scss │ │ ├── _core.scss │ │ ├── _fixed-width.scss │ │ ├── _icons.scss │ │ ├── _larger.scss │ │ ├── _list.scss │ │ ├── _mixins.scss │ │ ├── _path.scss │ │ ├── _rotated-flipped.scss │ │ ├── _stacked.scss │ │ ├── _variables.scss │ │ └── font-awesome.scss │ ├── images │ ├── 180 - duck_policy.png │ ├── 180 - duck_vulnerability.png │ └── Ducky-200.png │ ├── js │ ├── access │ │ ├── access-request.js │ │ └── access-utilities.js │ ├── blackduck-jira-issue-panel.js │ ├── blackduck-jira.js │ ├── blackduck │ │ ├── blackduck-request.js │ │ └── blackduck-utilities.js │ ├── common.js │ ├── creator │ │ ├── creator-request.js │ │ └── creator-utilities.js │ ├── mappings │ │ ├── field-mapping-request.js │ │ └── field-mapping-utilities.js │ └── migration │ │ ├── migration-request.js │ │ └── migration-utilities.js │ └── templates │ ├── blackduck-config.vm │ ├── blackduck-issue-panel.vm │ ├── blackduck-jira.vm │ ├── field-mapping.vm │ ├── issue-creation.vm │ ├── issue-migration.vm │ └── jira-access.vm └── test ├── java └── com │ └── blackducksoftware │ └── integration │ └── jira │ ├── GenerateNotificationsForPerformanceTest.java │ ├── common │ └── WorkflowHelperTest.java │ ├── issue │ ├── conversion │ │ ├── BomNotificationToIssueModelConverterTest.java │ │ ├── ConverterTestUtils.java │ │ ├── NotificationConverterTest.java │ │ └── output │ │ │ └── BlackDuckIssueModelTest.java │ └── event │ │ ├── IssueEventListenerTest.java │ │ ├── IssueListenerWithMocks.java │ │ ├── IssueTrackerHandlerTest.java │ │ └── IssueTrackerTaskWithMocks.java │ ├── mocks │ ├── ApplicationUserMock.java │ ├── AvatarManagerMock.java │ ├── ConstantsManagerMock.java │ ├── EntityPropertyMock.java │ ├── EntityPropertyQueryMock.java │ ├── EventPublisherMock.java │ ├── ExecutableQueryMock.java │ ├── GroupPickerSearchServiceMock.java │ ├── HttpServletRequestMock.java │ ├── HttpServletResponseMock.java │ ├── JSonEntityPropertyManagerMock.java │ ├── JiraServicesMock.java │ ├── LoginUriProviderMock.java │ ├── MockBuildUtilsInfoImpl.java │ ├── PluginSettingsFactoryMock.java │ ├── PluginSettingsMock.java │ ├── ProjectManagerMock.java │ ├── ProjectMock.java │ ├── SearchServiceMock.java │ ├── StatusMock.java │ ├── TemplateRendererMock.java │ ├── TransactionTemplateMock.java │ ├── UserManagerMock.java │ ├── UserManagerUIMock.java │ ├── UserMock.java │ ├── UserUtilMock.java │ ├── field │ │ ├── CustomFieldManagerMock.java │ │ ├── CustomFieldMock.java │ │ ├── CustomFieldSearcherMock.java │ │ ├── CustomFieldTypeMock.java │ │ ├── EditableDefaultFieldLayoutMock.java │ │ ├── EditableFieldLayoutMock.java │ │ ├── FieldConfigSchemeManagerMock.java │ │ ├── FieldConfigSchemeMock.java │ │ ├── FieldConfigurationSchemeMock.java │ │ ├── FieldLayoutItemMock.java │ │ ├── FieldLayoutManagerMock.java │ │ ├── FieldLayoutSchemeMock.java │ │ ├── FieldManagerMock.java │ │ ├── FieldScreenLayoutItemMock.java │ │ ├── FieldScreenManagerMock.java │ │ ├── FieldScreenMock.java │ │ ├── FieldScreenSchemeItemMock.java │ │ ├── FieldScreenSchemeManagerMock.java │ │ ├── FieldScreenSchemeMock.java │ │ ├── FieldScreenTabMock.java │ │ └── OrderableFieldMock.java │ ├── issue │ │ ├── ExecutorServiceMock.java │ │ ├── HubServerConfigBuilderMock.java │ │ ├── IssueInputParametersMock.java │ │ ├── IssueMock.java │ │ ├── IssueServiceMock.java │ │ ├── IssueTypeMock.java │ │ ├── IssueTypeSchemeManagerMock.java │ │ ├── IssueTypeScreenSchemeManagerMock.java │ │ ├── IssueTypeScreenSchemeMock.java │ │ ├── JiraIssuePropertyWrapperMock.java │ │ └── JiraIssueServiceMock.java │ └── workflow │ │ ├── AssignableWorkflowSchemeBuilderMock.java │ │ ├── AssignableWorkflowSchemeMock.java │ │ ├── JiraWorkflowMock.java │ │ ├── WorkflowManagerMock.java │ │ └── WorkflowSchemeManagerMock.java │ ├── task │ └── JiraSettingsServiceTest.java │ ├── web │ ├── BlackDuckJiraConfigSerializableTest.java │ ├── BlackDuckJiraFieldCopyConfigSerializableTest.java │ ├── BlackDuckJiraServletTest.java │ ├── BlackDuckProjectMappingTest.java │ ├── BlackDuckProjectMappingsTest.java │ ├── JiraProjectTest.java │ ├── PolicyRuleSerializableTest.java │ └── TicketCreationErrorTest.java │ └── workflow │ └── setup │ ├── BlackDuckFieldConfigurationSetupTest.java │ ├── BlackDuckFieldScreenSchemeSetupTest.java │ ├── BlackDuckWorkflowSetupTest.java │ └── JiraTaskSetupTest.java └── resources ├── issueEventLoadTest └── performanceTest.sh ├── json ├── VulnerabilityNotificationContent_2Vulns.json ├── VulnerabilityNotificationContent_AddUpdateDelete.json ├── VulnerabilityNotificationContent_Linux.json ├── VulnerabilityNotificationContent_MultipleProjects.json └── VulnerabilityNotificationContent_new.json └── log4j.properties /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | /pom.xml.bak 6 | /hub-jira-integration.log 7 | /bin/ 8 | /target/ 9 | /target/ 10 | /target/ 11 | *.log.* 12 | /target/ 13 | .DS_Store 14 | *.iml 15 | /.idea/ 16 | /src/test/resources/test.properties -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | install: true 4 | 5 | addons: 6 | sonarcloud: 7 | organization: "black-duck-software" 8 | token: 9 | secure: "TcwyqoPZ0zdEZwMBwJ7xIMLO76sgdaYf6dk6HTjqC6a0aWRk64HJxI3F11weVaL4scVltPNrnz9t86SekGOGTSLKqPmxnJxnpENQ4Agvp1452nOW816q/AZvb7rC1QGOzeofrM3YOsi2yEyzfoHLA2tyZdraatddupa1ybC0f2bes8P5N+jxOplKxb9dCv6lyqlL2DL5AtjZpkLwlAO3J88ftYoEA8DlQrQYhZjeVgyh2oRgX7K1WFRQlGNLgBVPle7rlJsZ4IjYXYKgokzg3LJ1Bfj5YMcqTjupeOz3r3fQercuMUtvl2oDpFi6uJ2SWCcmmBZJclSLg664Vfgexh4W5DPiGHPhxZP9Ey1QTFZx9CmLYm+REnsnB78kEhQl53uapzV2K1RP+ijz4b9qgsp7JtgdKFvmAH1Gx16f0AtTlz+KUObAQLQjEbYIhT3WsHxFo7TpWBHomJHW2THWM2j8ozvRrnlnxy/8oo9HFWWZg6fWOaGWDSOhPqhuUuRuLopNy3/WR7lIjVHpN1oo5XXpIxgfL38lWZu91rZoNGzqNf40amQNfc0mW6sz9GUktaztdqEjuCsY0vFp6UWkpzAEKRTBbpNZbbGtMn50Kv2DJJfzZbOm+4RZ68VOwK9mooN8V00OQVNvIj8paE8OclIrXmokiq+c7PNXc4CHIJI=" 10 | 11 | jdk: 12 | - oraclejdk8 13 | 14 | notifications: 15 | email: 16 | recipients: 17 | - akamen@blackducksoftware.com 18 | - ekerwin@blackducksoftware.com 19 | - sbillings@blackducksoftware.com 20 | 21 | script: 22 | - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar 23 | 24 | after_success: 25 | - export DETECT_MAVEN_SCOPE=runtime 26 | - bash <(curl -s https://copilot.blackducksoftware.com/ci/travis/scripts/upload) 27 | -------------------------------------------------------------------------------- /DEVELOPER_README.txt: -------------------------------------------------------------------------------- 1 | Resources : 2 | In order to get FontAwesome to load properly I had to change ALL of the URL's in the min.css file. 3 | I removed the preceding ../ from all of the URL's becasue that was causing the browser to load the Fonts from the wrong URL path. -------------------------------------------------------------------------------- /Hub Workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/Hub Workflow.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Overview ## 2 | Black Duck plugin for Atlassian JIRA. This plugin provides the ability to create JIRA issues based on vulnerabilities and Policy violations in Black Duck, and close them based on violation overrides. Tickets will only be created for Black Duck projects that are mapped to JIRA projects and only for the violations that are selected. 3 | 4 | ## Build ## 5 | 6 | [![Build Status](https://travis-ci.org/blackducksoftware/blackduck-jira.svg?branch=master)](https://travis-ci.org/blackducksoftware/blackduck-jira) 7 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 8 | [![Black Duck Security Risk](https://copilot.blackducksoftware.com/github/repos/blackducksoftware/blackduck-jira/branches/master/badge-risk.svg)](https://copilot.blackducksoftware.com/github/repos/blackducksoftware/blackduck-jira/branches/master) 9 | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.blackducksoftware.integration%3Ahub-jira&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.blackducksoftware.integration%3Ahub-jira) 10 | ## Where can I get the latest release? ## 11 | You can always get the latest from the [Atlassian Marketplace](https://marketplace.atlassian.com/plugins/com.blackducksoftware.integration.blackduck-jira/server/overview) 12 | 13 | Alternatively, you can download the latest from GitHub: https://github.com/blackducksoftware/blackduck-jira/releases 14 | 15 | 16 | ## Documentation ## 17 | All documentation for blackduck-jira can be found on our public [Confluence](https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/231833603/Black+Duck+JIRA+6.3.0) 18 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/BlackDuckPluginDateFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common; 25 | 26 | import java.text.ParseException; 27 | import java.text.SimpleDateFormat; 28 | import java.time.LocalDateTime; 29 | import java.util.Date; 30 | 31 | import com.synopsys.integration.rest.RestConstants; 32 | 33 | public final class BlackDuckPluginDateFormatter { 34 | private static final String INTERNAL_PLUGIN_TIME_ZONE = "Zulu"; 35 | 36 | private final SimpleDateFormat dateFormat; 37 | 38 | public BlackDuckPluginDateFormatter() { 39 | dateFormat = new SimpleDateFormat(RestConstants.JSON_DATE_FORMAT); 40 | dateFormat.setTimeZone(java.util.TimeZone.getTimeZone(INTERNAL_PLUGIN_TIME_ZONE)); 41 | } 42 | 43 | public String format(final Date date) { 44 | return dateFormat.format(date); 45 | } 46 | 47 | public Date parse(final String dateString) throws ParseException { 48 | return dateFormat.parse(dateString); 49 | } 50 | 51 | public Date fromLocalDateTime(final LocalDateTime localDateTime) { 52 | return Date.from( 53 | localDateTime 54 | .atZone(dateFormat.getTimeZone().toZoneId()) 55 | .toInstant() 56 | ); 57 | } 58 | 59 | public LocalDateTime toLocalDateTime(final Date date) { 60 | return LocalDateTime.ofInstant( 61 | date.toInstant(), 62 | dateFormat.getTimeZone().toZoneId() 63 | ); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/BlackDuckWorkflowStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common; 25 | 26 | import java.util.EnumSet; 27 | import java.util.List; 28 | import java.util.stream.Collectors; 29 | 30 | import org.apache.commons.lang.StringUtils; 31 | 32 | import com.blackducksoftware.integration.jira.common.exception.JiraException; 33 | 34 | public enum BlackDuckWorkflowStatus { 35 | ENABLED("Enabled"), 36 | POLICY("Policy"), 37 | SECURITY_POLICY("Security Policy"), 38 | VULN("Vulnerability"), 39 | DISABLED("Disabled"); 40 | 41 | private final String prettyPrintName; 42 | 43 | BlackDuckWorkflowStatus(final String prettyPrintName) { 44 | this.prettyPrintName = prettyPrintName; 45 | } 46 | 47 | public String getPrettyPrintName() { 48 | return prettyPrintName; 49 | } 50 | 51 | public static String getPrettyListNames(final EnumSet statuses) throws JiraException { 52 | if (statuses.contains(POLICY) || statuses.contains(SECURITY_POLICY) || statuses.contains(VULN)) { 53 | final List prettyStatuses = statuses.stream().map(BlackDuckWorkflowStatus::getPrettyPrintName).collect(Collectors.toList()); 54 | final String joinedStatus = StringUtils.join(prettyStatuses, ", "); 55 | return joinedStatus + " Only"; 56 | } else if (1 == statuses.size()) { 57 | return statuses.stream().map(BlackDuckWorkflowStatus::getPrettyPrintName).findFirst().orElse(""); 58 | } 59 | final List names = statuses.stream().map(BlackDuckWorkflowStatus::name).collect(Collectors.toList()); 60 | final String joinedNames = StringUtils.join(names, ", "); 61 | throw new JiraException("This is an invalid list of status's. " + joinedNames); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/JiraUserContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common; 25 | 26 | import java.util.Optional; 27 | 28 | import org.slf4j.Logger; 29 | import org.slf4j.LoggerFactory; 30 | 31 | import com.atlassian.jira.user.ApplicationUser; 32 | import com.atlassian.jira.user.util.UserManager; 33 | 34 | public class JiraUserContext { 35 | private static final Logger logger = LoggerFactory.getLogger(JiraUserContext.class); 36 | 37 | private final ApplicationUser jiraAdminUser; 38 | private final ApplicationUser defaultJiraIssueCreatorUser; 39 | 40 | // This could be moved to a static factory class if preferred. 41 | public static Optional create(final String jiraAdminUsername, String jiraIssueCreatorUsername, final UserManager userManager) { 42 | logger.debug(String.format("Checking JIRA users: Admin: %s; Issue creator: %s", jiraAdminUsername, jiraIssueCreatorUsername)); 43 | if (jiraIssueCreatorUsername == null) { 44 | logger.warn(String.format("The JIRA Issue Creator user has not been configured, using the admin user (%s) to create issues. This can be changed via the Issue Creation configuration", jiraAdminUsername)); 45 | jiraIssueCreatorUsername = jiraAdminUsername; 46 | } 47 | final Optional jiraAdminUser = getJiraUser(jiraAdminUsername, userManager); 48 | final Optional jiraIssueCreatorUser = getJiraUser(jiraIssueCreatorUsername, userManager); 49 | if (!jiraAdminUser.isPresent() || !jiraIssueCreatorUser.isPresent()) { 50 | return Optional.empty(); 51 | } 52 | final JiraUserContext jiraContext = new JiraUserContext(jiraAdminUser.get(), jiraIssueCreatorUser.get()); 53 | return Optional.of(jiraContext); 54 | } 55 | 56 | private static Optional getJiraUser(final String jiraUsername, final UserManager userManager) { 57 | final ApplicationUser jiraUser = userManager.getUserByName(jiraUsername); 58 | if (jiraUser == null) { 59 | logger.error(String.format("Could not find the JIRA user %s", jiraUsername)); 60 | } 61 | return Optional.ofNullable(jiraUser); 62 | } 63 | 64 | public JiraUserContext(final ApplicationUser jiraAdminUser, final ApplicationUser defaultJiraIssueCreatorUser) { 65 | this.jiraAdminUser = jiraAdminUser; 66 | this.defaultJiraIssueCreatorUser = defaultJiraIssueCreatorUser; 67 | } 68 | 69 | public ApplicationUser getJiraAdminUser() { 70 | return jiraAdminUser; 71 | } 72 | 73 | public ApplicationUser getDefaultJiraIssueCreatorUser() { 74 | return defaultJiraIssueCreatorUser; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/exception/ConfigurationException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common.exception; 25 | 26 | public class ConfigurationException extends Exception { 27 | private static final long serialVersionUID = -9146861663735413869L; 28 | 29 | public ConfigurationException(final String message) { 30 | super(message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/exception/IssueModelBuilderException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common.exception; 25 | 26 | import com.synopsys.integration.exception.IntegrationException; 27 | 28 | public class IssueModelBuilderException extends IntegrationException { 29 | public IssueModelBuilderException(String message) { 30 | super(message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/exception/JiraException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common.exception; 25 | 26 | public class JiraException extends Exception { 27 | private static final long serialVersionUID = -8266124446156847454L; 28 | 29 | // This value stores the name of the method that was called and resulted in error. 30 | private String methodAttempt = "unknown"; 31 | 32 | public JiraException() { 33 | super(); 34 | } 35 | 36 | public JiraException(final String message) { 37 | super(message); 38 | } 39 | 40 | public JiraException(final String message, final Throwable cause) { 41 | super(message, cause); 42 | } 43 | 44 | public String getMethodAttempt() { 45 | return methodAttempt; 46 | } 47 | 48 | public void setMethodAttempt(final String methodAttempt) { 49 | this.methodAttempt = methodAttempt; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/exception/JiraIssueException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common.exception; 25 | 26 | import com.atlassian.jira.util.ErrorCollection; 27 | import com.atlassian.jira.util.ErrorCollections; 28 | 29 | public class JiraIssueException extends JiraException { 30 | private static final long serialVersionUID = -2838852966435691111L; 31 | 32 | private ErrorCollection errorCollection = ErrorCollections.empty(); 33 | 34 | // FIXME make the constructor methodAttempt param in the same place for both constructors. 35 | public JiraIssueException(final String message, final String methodAttempt) { 36 | super(message); 37 | super.setMethodAttempt(methodAttempt); 38 | } 39 | 40 | public JiraIssueException(final String methodAttempt, final ErrorCollection errorCollection) { 41 | super(); 42 | super.setMethodAttempt(methodAttempt); 43 | this.errorCollection = errorCollection; 44 | } 45 | 46 | public ErrorCollection getErrorCollection() { 47 | return errorCollection; 48 | } 49 | 50 | public void setErrorCollection(final ErrorCollection errorCollection) { 51 | this.errorCollection = errorCollection; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/common/model/PluginGroupsConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.common.model; 25 | 26 | import java.util.Arrays; 27 | import java.util.Collection; 28 | import java.util.Collections; 29 | 30 | import org.apache.commons.lang3.StringUtils; 31 | 32 | import com.synopsys.integration.util.Stringable; 33 | 34 | public class PluginGroupsConfigModel extends Stringable { 35 | public static final String BLACK_DUCK_GROUPS_LIST_DELIMETER = ","; 36 | 37 | private final Collection groups; 38 | 39 | public static PluginGroupsConfigModel fromDelimitedString(final String delimitedString) { 40 | if (StringUtils.isNotBlank(delimitedString)) { 41 | final String[] groups = delimitedString.split(PluginGroupsConfigModel.BLACK_DUCK_GROUPS_LIST_DELIMETER); 42 | return PluginGroupsConfigModel.of(groups); 43 | } 44 | return none(); 45 | } 46 | 47 | public static PluginGroupsConfigModel of(final String[] groups) { 48 | if (groups != null) { 49 | return new PluginGroupsConfigModel(Arrays.asList(groups)); 50 | } 51 | return none(); 52 | } 53 | 54 | public static PluginGroupsConfigModel none() { 55 | return new PluginGroupsConfigModel(Collections.emptySet()); 56 | } 57 | 58 | private PluginGroupsConfigModel(final Collection groups) { 59 | this.groups = groups; 60 | } 61 | 62 | public Collection getGroups() { 63 | return groups; 64 | } 65 | 66 | public String getGroupsStringDelimited() { 67 | return StringUtils.join(groups, BLACK_DUCK_GROUPS_LIST_DELIMETER); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/data/BlackDuckConfigKeys.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.data; 25 | 26 | public class BlackDuckConfigKeys { 27 | public static final String BLACKDUCK_CONFIG_KEY_PREFIX = "com.blackducksoftware.integration.hub.configuration"; 28 | 29 | public static final String CONFIG_BLACKDUCK_URL = BLACKDUCK_CONFIG_KEY_PREFIX + ".huburl"; 30 | public static final String CONFIG_BLACKDUCK_API_TOKEN = BLACKDUCK_CONFIG_KEY_PREFIX + ".bdApiToken"; 31 | public static final String CONFIG_BLACKDUCK_TIMEOUT = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubtimeout"; 32 | public static final String CONFIG_BLACKDUCK_TRUST_CERT = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubtrustcert"; 33 | 34 | public static final String CONFIG_PROXY_HOST = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubproxyhost"; 35 | public static final String CONFIG_PROXY_PORT = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubproxyport"; 36 | public static final String CONFIG_PROXY_USER = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubproxyuser"; 37 | public static final String CONFIG_PROXY_PASS = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubproxypass"; 38 | public static final String CONFIG_PROXY_PASS_LENGTH = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubproxypasslength"; 39 | 40 | public static final String BLACKDUCK_CONFIG_GROUPS = BLACKDUCK_CONFIG_KEY_PREFIX + ".hubGroups"; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/data/PluginConfigKeys.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.data; 25 | 26 | public class PluginConfigKeys { 27 | public static final String BLACKDUCK_CONFIG_JIRA_KEY_PREFIX = "com.blackducksoftware.integration.hub.jira"; 28 | public static final String BLACKDUCK_CONFIG_JIRA_INTERVAL_BETWEEN_CHECKS = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".intervalBetweenChecks"; 29 | public static final String BLACKDUCK_CONFIG_JIRA_PROJECT_MAPPINGS_JSON = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".hubProjectMappings"; 30 | public static final String BLACKDUCK_CONFIG_FIELD_COPY_MAPPINGS_JSON = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".fieldCopyMappings"; 31 | public static final String BLACKDUCK_CONFIG_JIRA_FIRST_SAVE_TIME = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".firstSaveTime"; 32 | public static final String BLACKDUCK_CONFIG_JIRA_POLICY_RULES_JSON = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".policyRules"; 33 | public static final String BLACKDUCK_CONFIG_CREATE_VULN_ISSUES_CHOICE = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".createVulnIssuesChoice"; 34 | public static final String BLACKDUCK_CONFIG_COMMENT_ON_ISSUE_UPDATES_CHOICE = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".commentOnIssueUpdatesChoice"; 35 | public static final String BLACKDUCK_CONFIG_LAST_RUN_DATE = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".lastRunDate"; 36 | public static final String BLACKDUCK_CONFIG_JIRA_ADMIN_USER = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".jiraUser"; 37 | public static final String BLACKDUCK_CONFIG_JIRA_ISSUE_CREATOR_USER = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".creator"; 38 | public static final String BLACKDUCK_CONFIG_CREATOR_CANDIDATES_JSON = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".creatorCandidates"; 39 | public static final String PROJECTS_MIGRATED_TO_ALERT = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".projectsMigratedToAlert"; 40 | public static final String BLACKDUCK_CONFIG_GROUPS = "com.blackducksoftware.integration.hub.configuration.hubGroups"; 41 | public static final String BLACKDUCK_CONFIG_PROJECT_REVIEWER_NOTIFICATIONS_CHOICE = BLACKDUCK_CONFIG_JIRA_KEY_PREFIX + ".projectReviewerNotificationsChoice"; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/data/accessor/JiraSettingsAccessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.data.accessor; 25 | 26 | import java.util.Optional; 27 | 28 | import org.apache.commons.lang3.StringUtils; 29 | import org.apache.commons.lang3.math.NumberUtils; 30 | 31 | import com.atlassian.sal.api.pluginsettings.PluginSettings; 32 | 33 | public class JiraSettingsAccessor { 34 | private final PluginSettings pluginSettings; 35 | 36 | public JiraSettingsAccessor(final PluginSettings pluginSettings) { 37 | this.pluginSettings = pluginSettings; 38 | } 39 | 40 | public PluginConfigurationAccessor createPluginConfigurationAccessor() { 41 | return new PluginConfigurationAccessor(this); 42 | } 43 | 44 | public PluginErrorAccessor createPluginErrorAccessor() { 45 | return new PluginErrorAccessor(this); 46 | } 47 | 48 | public GlobalConfigurationAccessor createGlobalConfigurationAccessor() { 49 | return new GlobalConfigurationAccessor(this); 50 | } 51 | 52 | public Object getObjectValue(final String key) { 53 | return pluginSettings.get(key); 54 | } 55 | 56 | public String getStringValue(final String key) { 57 | final Object foundObject = pluginSettings.get(key); 58 | if (foundObject == null) { 59 | return null; 60 | } 61 | return String.valueOf(foundObject); 62 | } 63 | 64 | public Optional getIntegerValue(final String key) { 65 | final String value = getStringValue(key); 66 | if (NumberUtils.isParsable(value)) { 67 | return Optional.of(Integer.parseInt(value)); 68 | } 69 | return Optional.empty(); 70 | } 71 | 72 | public Boolean getBooleanValue(final String key) { 73 | return getBooleanValue(key, false); 74 | } 75 | 76 | public Boolean getBooleanValue(final String key, final Boolean defaultValue) { 77 | final String stringValue = getStringValue(key); 78 | if (StringUtils.isBlank(stringValue)) { 79 | return defaultValue; 80 | } 81 | return Boolean.parseBoolean(stringValue); 82 | } 83 | 84 | public void setValue(final String key, final Object value) { 85 | if (value == null) { 86 | pluginSettings.remove(key); 87 | } else { 88 | pluginSettings.put(key, String.valueOf(value)); 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/data/accessor/MigrationAccessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.data.accessor; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import java.util.stream.Collectors; 29 | import java.util.stream.Stream; 30 | 31 | import org.apache.commons.lang3.StringUtils; 32 | 33 | import com.blackducksoftware.integration.jira.data.PluginConfigKeys; 34 | 35 | public class MigrationAccessor { 36 | private final JiraSettingsAccessor jiraSettingsAccessor; 37 | 38 | public MigrationAccessor(JiraSettingsAccessor jiraSettingsAccessor) { 39 | this.jiraSettingsAccessor = jiraSettingsAccessor; 40 | } 41 | 42 | public List getMigratedProjects() { 43 | String storedMigratedProjects = jiraSettingsAccessor.getStringValue(PluginConfigKeys.PROJECTS_MIGRATED_TO_ALERT); 44 | if (null == storedMigratedProjects) { 45 | return new ArrayList<>(); 46 | } 47 | return Stream.of(storedMigratedProjects.split(",")).collect(Collectors.toCollection(ArrayList::new)); 48 | } 49 | 50 | public void updateMigratedProjects(List migratedProjects) { 51 | if (null == migratedProjects || migratedProjects.isEmpty()) { 52 | jiraSettingsAccessor.setValue(PluginConfigKeys.PROJECTS_MIGRATED_TO_ALERT, ""); 53 | } 54 | String migratedProjectsToStore = StringUtils.join(migratedProjects, ","); 55 | jiraSettingsAccessor.setValue(PluginConfigKeys.PROJECTS_MIGRATED_TO_ALERT, migratedProjectsToStore); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/conversion/output/BlackDuckIssueAction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.conversion.output; 25 | 26 | import com.synopsys.integration.blackduck.api.generated.enumeration.NotificationType; 27 | 28 | public enum BlackDuckIssueAction { 29 | ADD_COMMENT, 30 | ADD_COMMENT_IF_EXISTS, 31 | OPEN, 32 | RESOLVE, 33 | RESOLVE_ALL, 34 | UPDATE_OR_OPEN; 35 | 36 | public static BlackDuckIssueAction fromNotificationType(final NotificationType notificationType) { 37 | if (NotificationType.POLICY_OVERRIDE.equals(notificationType) || NotificationType.RULE_VIOLATION_CLEARED.equals(notificationType)) { 38 | return RESOLVE; 39 | } else if (NotificationType.RULE_VIOLATION.equals(notificationType)) { 40 | return OPEN; 41 | } else if (NotificationType.VULNERABILITY.equals(notificationType)) { 42 | // This seems to be the safest option of the many possibilities for vulnerability notifications 43 | return ADD_COMMENT_IF_EXISTS; 44 | } else if (NotificationType.BOM_EDIT.equals(notificationType)) { 45 | return UPDATE_OR_OPEN; 46 | } else { 47 | throw new IllegalArgumentException(String.format("Cannot determine an action from non-policy NotificationType: %s", notificationType)); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/conversion/output/IssueProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.conversion.output; 25 | 26 | import java.util.Optional; 27 | 28 | import com.blackducksoftware.integration.jira.issue.model.IssueCategory; 29 | import com.synopsys.integration.util.Stringable; 30 | 31 | public class IssueProperties extends Stringable { 32 | private final IssueCategory type; 33 | private final String bomComponentUri; 34 | private final String ruleName; 35 | private final Long jiraIssueId; 36 | 37 | public IssueProperties(final IssueCategory type, final String bomComponentUri, final String ruleName, final Long jiraIssueId) { 38 | this.type = type; 39 | this.bomComponentUri = bomComponentUri; 40 | this.ruleName = ruleName; 41 | this.jiraIssueId = jiraIssueId; 42 | } 43 | 44 | public IssueCategory getType() { 45 | return type; 46 | } 47 | 48 | public String getBomComponentUri() { 49 | return bomComponentUri; 50 | } 51 | 52 | public Optional getRuleName() { 53 | return Optional.ofNullable(ruleName); 54 | } 55 | 56 | public Long getJiraIssueId() { 57 | return jiraIssueId; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/conversion/output/OldIssueProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.conversion.output; 25 | 26 | import com.blackducksoftware.integration.jira.issue.model.BlackDuckIssueFieldTemplate; 27 | import com.blackducksoftware.integration.jira.issue.model.BlackDuckIssueModel; 28 | import com.blackducksoftware.integration.jira.issue.model.IssueCategory; 29 | 30 | public class OldIssueProperties extends IssueProperties { 31 | private final String projectName; 32 | private final String projectVersionName; 33 | private final String componentName; 34 | private final String componentVersionName; 35 | 36 | public OldIssueProperties(final String projectName, final String projectVersionName, final String componentName, final String componentVersionName, final String ruleName, final IssueCategory type, final String bomComponentUri, 37 | final Long jiraIssueId) { 38 | super(type, bomComponentUri, ruleName, jiraIssueId); 39 | this.projectName = projectName; 40 | this.projectVersionName = projectVersionName; 41 | this.componentName = componentName; 42 | this.componentVersionName = componentVersionName; 43 | } 44 | // @formatter:on 45 | 46 | // @formatter:off 47 | public static OldIssueProperties fromBlackDuckIssueWrapper(final BlackDuckIssueModel blackDuckIssueModel) { 48 | final BlackDuckIssueFieldTemplate template = blackDuckIssueModel.getBlackDuckIssueTemplate(); 49 | return new OldIssueProperties( 50 | template.getProjectName() 51 | ,template.getProjectVersionName() 52 | ,template.getComponentName() 53 | ,template.getComponentVersionName() 54 | ,template.getPolicyRuleName() 55 | ,template.getIssueCategory() 56 | ,blackDuckIssueModel.getBomComponentUri() 57 | ,blackDuckIssueModel.getJiraIssueId()); 58 | } 59 | // @formatter:on 60 | 61 | public String getProjectName() { 62 | return projectName; 63 | } 64 | 65 | public String getProjectVersion() { 66 | return projectVersionName; 67 | } 68 | 69 | public String getComponentName() { 70 | return componentName; 71 | } 72 | 73 | public String getComponentVersion() { 74 | return componentVersionName; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/handler/NotificationVulnerability.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.handler; 25 | 26 | import com.synopsys.integration.util.Stringable; 27 | 28 | public class NotificationVulnerability extends Stringable { 29 | private String source; 30 | private String vulnerabilityId; 31 | 32 | public NotificationVulnerability(final String source, final String vulnerabilityId) { 33 | this.source = source; 34 | this.vulnerabilityId = vulnerabilityId; 35 | } 36 | 37 | public String getSource() { 38 | return source; 39 | } 40 | 41 | public void setSource(final String source) { 42 | this.source = source; 43 | } 44 | 45 | public String getVulnerabilityId() { 46 | return vulnerabilityId; 47 | } 48 | 49 | public void setVulnerabilityId(final String vulnerabilityId) { 50 | this.vulnerabilityId = vulnerabilityId; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/GeneralIssueCreationConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | import java.util.Optional; 27 | 28 | public class GeneralIssueCreationConfigModel { 29 | private final Integer interval; 30 | private final String defaultIssueCreator; 31 | 32 | public GeneralIssueCreationConfigModel(final Integer interval, final String defaultIssueCreator) { 33 | this.interval = interval; 34 | this.defaultIssueCreator = defaultIssueCreator; 35 | } 36 | 37 | public Optional getInterval() { 38 | return Optional.ofNullable(interval); 39 | } 40 | 41 | public String getDefaultIssueCreator() { 42 | return defaultIssueCreator; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/IssueCategory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | public enum IssueCategory { 27 | POLICY, 28 | SECURITY_POLICY, 29 | VULNERABILITY, 30 | SPECIAL 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/PluginIssueCreationConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | public class PluginIssueCreationConfigModel { 27 | private final GeneralIssueCreationConfigModel general; 28 | private final ProjectMappingConfigModel projectMapping; 29 | private final TicketCriteriaConfigModel ticketCriteria; 30 | 31 | public PluginIssueCreationConfigModel(final GeneralIssueCreationConfigModel general, final ProjectMappingConfigModel projectMapping, final TicketCriteriaConfigModel ticketCriteria) { 32 | this.general = general; 33 | this.projectMapping = projectMapping; 34 | this.ticketCriteria = ticketCriteria; 35 | } 36 | 37 | public GeneralIssueCreationConfigModel getGeneral() { 38 | return general; 39 | } 40 | 41 | public ProjectMappingConfigModel getProjectMapping() { 42 | return projectMapping; 43 | } 44 | 45 | public TicketCriteriaConfigModel getTicketCriteria() { 46 | return ticketCriteria; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/PluginIssueFieldConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | public class PluginIssueFieldConfigModel { 27 | private final String fieldMappingJson; 28 | 29 | public PluginIssueFieldConfigModel(final String fieldMappingJson) { 30 | this.fieldMappingJson = fieldMappingJson; 31 | } 32 | 33 | public String getFieldMappingJson() { 34 | return fieldMappingJson; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/ProjectMappingConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | public class ProjectMappingConfigModel { 27 | private final String mappingsJson; 28 | 29 | public ProjectMappingConfigModel(final String mappingsJson) { 30 | this.mappingsJson = mappingsJson; 31 | } 32 | 33 | public String getMappingsJson() { 34 | return mappingsJson; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/model/TicketCriteriaConfigModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.model; 25 | 26 | public class TicketCriteriaConfigModel { 27 | private final String policyRulesJson; 28 | private final Boolean commentOnIssueUpdates; 29 | private final Boolean addComponentReviewerToTickets; 30 | 31 | public TicketCriteriaConfigModel(final String policyRulesJson, final Boolean commentOnIssueUpdates, final Boolean addComponentReviewerToTickets) { 32 | this.policyRulesJson = policyRulesJson; 33 | this.commentOnIssueUpdates = commentOnIssueUpdates; 34 | this.addComponentReviewerToTickets = addComponentReviewerToTickets; 35 | } 36 | 37 | public String getPolicyRulesJson() { 38 | return policyRulesJson; 39 | } 40 | 41 | public Boolean getCommentOnIssueUpdates() { 42 | return commentOnIssueUpdates; 43 | } 44 | 45 | public Boolean getAddComponentReviewerToTickets() { 46 | return addComponentReviewerToTickets; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/tracker/IssueTrackerProperties.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.tracker; 25 | 26 | import com.google.gson.annotations.SerializedName; 27 | 28 | public class IssueTrackerProperties { 29 | // TODO this might break backwards compatibility with the issue tracker 30 | @SerializedName("hubIssueUrl") 31 | private final String blackDuckIssueUrl; 32 | private final Long jiraIssueId; 33 | 34 | public IssueTrackerProperties(final String blackDuckIssueUrl, final Long jiraIssueId) { 35 | this.blackDuckIssueUrl = blackDuckIssueUrl; 36 | this.jiraIssueId = jiraIssueId; 37 | } 38 | 39 | public Long getJiraIssueId() { 40 | return jiraIssueId; 41 | } 42 | 43 | public String getBlackDuckIssueUrl() { 44 | return blackDuckIssueUrl; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/issue/ui/BlackDuckIssuePanelCondition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.issue.ui; 25 | 26 | import com.atlassian.jira.issue.Issue; 27 | import com.atlassian.jira.plugin.webfragment.conditions.AbstractWebCondition; 28 | import com.atlassian.jira.plugin.webfragment.model.JiraHelper; 29 | import com.atlassian.jira.user.ApplicationUser; 30 | import com.blackducksoftware.integration.jira.common.BlackDuckJiraConstants; 31 | 32 | public class BlackDuckIssuePanelCondition extends AbstractWebCondition { 33 | 34 | @Override 35 | public boolean shouldDisplay(final ApplicationUser applicationUser, final JiraHelper jiraHelper) { 36 | final Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue"); 37 | final String issueType = currentIssue.getIssueType().getName(); 38 | if (BlackDuckJiraConstants.BLACKDUCK_VULNERABILITY_ISSUE.equals(issueType) || 39 | BlackDuckJiraConstants.BLACKDUCK_SECURITY_POLICY_VIOLATION_ISSUE.equals(issueType) || 40 | BlackDuckJiraConstants.BLACKDUCK_POLICY_VIOLATION_ISSUE.equals(issueType)) { 41 | return true; 42 | } 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/task/BlackDuckJobRunner.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.task; 25 | 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import com.atlassian.sal.api.pluginsettings.PluginSettings; 30 | import com.atlassian.scheduler.JobRunner; 31 | import com.atlassian.scheduler.JobRunnerRequest; 32 | import com.atlassian.scheduler.JobRunnerResponse; 33 | import com.blackducksoftware.integration.jira.data.accessor.JiraSettingsAccessor; 34 | import com.blackducksoftware.integration.jira.task.thread.PluginExecutorService; 35 | import com.blackducksoftware.integration.jira.web.BlackDuckPluginVersion; 36 | import com.blackducksoftware.integration.jira.web.JiraServices; 37 | 38 | public class BlackDuckJobRunner implements JobRunner { 39 | public static final String HUMAN_READABLE_TASK_NAME = "Black Duck notification check task"; 40 | 41 | private final Logger logger = LoggerFactory.getLogger(getClass()); 42 | private final JiraSettingsAccessor jiraSettingsAccessor; 43 | private final PluginExecutorService executorService; 44 | 45 | public BlackDuckJobRunner(final PluginSettings pluginSettings, final PluginExecutorService executorService) { 46 | this.jiraSettingsAccessor = new JiraSettingsAccessor(pluginSettings); 47 | this.executorService = executorService; 48 | } 49 | 50 | @Override 51 | public JobRunnerResponse runJob(final JobRunnerRequest request) { 52 | final JiraTaskTimed jiraTaskTimed = new JiraTaskTimed(jiraSettingsAccessor, new JiraServices()); 53 | 54 | logger.info("blackduck-jira plugin version: " + BlackDuckPluginVersion.getVersion()); 55 | final BlackDuckJobRunnerUtil blackDuckJobRunnerUtil = new BlackDuckJobRunnerUtil(executorService, "periodic"); 56 | return blackDuckJobRunnerUtil.runJob(request, jiraTaskTimed); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/task/JiraDeploymentType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.task; 25 | 26 | public enum JiraDeploymentType { 27 | CLOUD, 28 | DATA_CENTER, 29 | SERVER; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/task/NotificationMonitor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.task; 25 | 26 | public interface NotificationMonitor { 27 | void reschedule(long interval); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/task/maintenance/BlackDuckMaintenanceJobRunner.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.task.maintenance; 25 | 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import com.atlassian.sal.api.pluginsettings.PluginSettings; 30 | import com.atlassian.scheduler.JobRunner; 31 | import com.atlassian.scheduler.JobRunnerRequest; 32 | import com.atlassian.scheduler.JobRunnerResponse; 33 | import com.blackducksoftware.integration.jira.data.accessor.JiraSettingsAccessor; 34 | import com.blackducksoftware.integration.jira.task.BlackDuckJobRunnerUtil; 35 | import com.blackducksoftware.integration.jira.task.thread.PluginExecutorService; 36 | 37 | public class BlackDuckMaintenanceJobRunner implements JobRunner { 38 | public static final String HUMAN_READABLE_TASK_NAME = "Black Duck maintenance task"; 39 | public static final String DEFAULT_ATLASSIAN_CRON_EXPRESSION = "0 0 0 * * ? *"; 40 | 41 | private final Logger logger = LoggerFactory.getLogger(getClass()); 42 | private final JiraSettingsAccessor jiraSettingsAccessor; 43 | 44 | public BlackDuckMaintenanceJobRunner(final PluginSettings pluginSettings) { 45 | this.jiraSettingsAccessor = new JiraSettingsAccessor(pluginSettings); 46 | } 47 | 48 | @Override 49 | public JobRunnerResponse runJob(final JobRunnerRequest request) { 50 | PluginExecutorService pluginExecutorService = null; 51 | try { 52 | final CleanUpOrphanedTicketsTask cleanUpTask = new CleanUpOrphanedTicketsTask(jiraSettingsAccessor); 53 | 54 | pluginExecutorService = PluginExecutorService.restricted(1); 55 | final BlackDuckJobRunnerUtil blackDuckJobRunnerUtil = new BlackDuckJobRunnerUtil(pluginExecutorService, "maintenance"); 56 | return blackDuckJobRunnerUtil.runJob(request, cleanUpTask); 57 | } finally { 58 | if (null != pluginExecutorService) { 59 | pluginExecutorService.shutdownNow(); 60 | } 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/BlackDuckPluginVersion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web; 25 | 26 | import java.io.IOException; 27 | import java.io.InputStream; 28 | import java.util.Properties; 29 | 30 | import org.slf4j.Logger; 31 | import org.slf4j.LoggerFactory; 32 | 33 | public class BlackDuckPluginVersion { 34 | private static final String VERSION_UNKNOWN = "(unknown)"; 35 | 36 | private static final Logger logger = LoggerFactory.getLogger(BlackDuckPluginVersion.class); 37 | 38 | public static String getVersion() { 39 | final Properties prop = new Properties(); 40 | final InputStream is = BlackDuckPluginVersion.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"); 41 | try { 42 | prop.load(is); 43 | } catch (final IOException e) { 44 | return VERSION_UNKNOWN; 45 | } 46 | String bundleName = null; 47 | String bundleVersion = null; 48 | for (final Object key : prop.keySet()) { 49 | if (key instanceof String) { 50 | final String keyString = (String) key; 51 | if (("Bundle-Name".equals(keyString)) || ("Bundle-Version".equals(keyString))) { 52 | logger.debug(keyString + "=" + prop.getProperty(keyString) + "\n"); 53 | } 54 | if ("Bundle-Name".equals(keyString)) { 55 | bundleName = prop.getProperty(keyString); 56 | } 57 | if ("Bundle-Version".equals(keyString)) { 58 | bundleVersion = prop.getProperty(keyString); 59 | } 60 | } else { 61 | logger.debug("nonString manifest key: " + key.toString() + "=" + prop.getProperty(key.toString()) + "\n"); 62 | } 63 | } 64 | if ((bundleName != null) && (bundleVersion != null)) { 65 | return bundleVersion; 66 | } 67 | return VERSION_UNKNOWN; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/ErrorTracking.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web; 25 | 26 | public interface ErrorTracking { 27 | boolean hasErrors(); 28 | 29 | String getErrorMessage(); 30 | 31 | void setErrorMessage(String errorMessage); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/JiraConfigDeserializer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web; 25 | 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import com.blackducksoftware.integration.jira.issue.model.PluginIssueCreationConfigModel; 30 | import com.blackducksoftware.integration.jira.issue.model.ProjectMappingConfigModel; 31 | import com.blackducksoftware.integration.jira.issue.model.TicketCriteriaConfigModel; 32 | import com.blackducksoftware.integration.jira.web.model.BlackDuckJiraConfigSerializable; 33 | import com.blackducksoftware.integration.jira.web.model.BlackDuckJiraFieldCopyConfigSerializable; 34 | 35 | public class JiraConfigDeserializer { 36 | private final Logger logger = LoggerFactory.getLogger(getClass()); 37 | 38 | public BlackDuckJiraConfigSerializable deserializeConfig(final PluginIssueCreationConfigModel issueCreationConfig) { 39 | final ProjectMappingConfigModel projectMapping = issueCreationConfig.getProjectMapping(); 40 | final TicketCriteriaConfigModel ticketCriteria = issueCreationConfig.getTicketCriteria(); 41 | 42 | final BlackDuckJiraConfigSerializable config = new BlackDuckJiraConfigSerializable(); 43 | config.setHubProjectMappingsJson(projectMapping.getMappingsJson()); 44 | config.setPolicyRulesJson(ticketCriteria.getPolicyRulesJson()); 45 | 46 | logger.debug("Mappings: " + config.getHubProjectMappings()); 47 | logger.debug("Policy Rules: " + config.getPolicyRules()); 48 | 49 | return config; 50 | } 51 | 52 | public BlackDuckJiraFieldCopyConfigSerializable deserializeFieldCopyConfig(final String fieldCopyMappingJson) { 53 | final BlackDuckJiraFieldCopyConfigSerializable fieldCopyConfig = new BlackDuckJiraFieldCopyConfigSerializable(); 54 | fieldCopyConfig.setJson(fieldCopyMappingJson); 55 | return fieldCopyConfig; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/JiraConfigErrorStrings.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web; 25 | 26 | public class JiraConfigErrorStrings { 27 | public static final String BLACKDUCK_SERVER_MISCONFIGURATION = "There was a problem with the Black Duck server configuration. "; 28 | public static final String CHECK_BLACKDUCK_SERVER_CONFIGURATION = "Please verify the Black Duck server information is configured correctly. "; 29 | public static final String BLACKDUCK_CONFIG_PLUGIN_MISSING = "The Black Duck server connection details have not been configured."; 30 | 31 | public static final String MAPPING_HAS_EMPTY_ERROR = "There are invalid mapping(s)."; 32 | public static final String NO_JIRA_PROJECTS_FOUND = "Could not find any JIRA Projects."; 33 | public static final String NO_BLACKDUCK_PROJECTS_FOUND = "Could not find any Black Duck Projects for this User. This Black Duck user may not be assigned to any projects."; 34 | public static final String BLACKDUCK_PROJECT_PATTERN_INVALID = "There are invalid project name patterns."; 35 | 36 | public static final String NO_POLICY_RULES_FOUND_ERROR = "No Policy rules were found in the configured Black Duck server."; 37 | public static final String NO_POLICY_LICENSE_FOUND = "Valid Policy License was not found"; 38 | public static final String POLICY_RULE_URL_ERROR = "Error getting policy rule URL"; 39 | 40 | public static final String NO_INTERVAL_FOUND_ERROR = "No interval between checks was found."; 41 | public static final String NO_CREATOR_SPECIFIED_ERROR = "The 'JIRA Issue Creator' field is required."; 42 | public static final String NO_CREATOR_CANDIDATES_FOUND = "Could not find any JIRA users eligible to be issue creators. Make sure Configuration Access has been set up, and that there are users in those groups."; 43 | public static final String UNAUTHORIZED_CREATOR_ERROR = "The user specified as the issue creator is not a valid JIRA user or has not been granted access to the Black Duck JIRA plugin."; 44 | public static final String INVALID_INTERVAL_FOUND_ERROR = "The interval must be greater than 0."; 45 | public static final String NON_SYSTEM_ADMINS_CANT_CHANGE_GROUPS = "Only JIRA system admins can update the list of JIRA groups that can access the Black Duck JIRA configuration."; 46 | 47 | public static final String NO_VALID_FIELD_CONFIGURATIONS = "At least one valid field configuration is required in order to save."; 48 | public static final String FIELD_CONFIGURATION_INVALID_SOURCE_FIELD = "The Black Duck Field in one of the field mappings is invalid."; 49 | public static final String FIELD_CONFIGURATION_INVALID_TARGET_FIELD = "The JIRA Field in one of the field mappings is invalid."; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/controller/ConfigController.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.controller; 25 | 26 | import java.util.function.Supplier; 27 | 28 | import javax.servlet.http.HttpServletRequest; 29 | 30 | import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; 31 | import com.atlassian.sal.api.transaction.TransactionTemplate; 32 | import com.atlassian.sal.api.user.UserManager; 33 | import com.blackducksoftware.integration.jira.common.model.PluginGroupsConfigModel; 34 | import com.blackducksoftware.integration.jira.data.accessor.GlobalConfigurationAccessor; 35 | import com.blackducksoftware.integration.jira.data.accessor.JiraSettingsAccessor; 36 | 37 | public class ConfigController { 38 | private final PluginSettingsFactory pluginSettingsFactory; 39 | private final TransactionTemplate transactionTemplate; 40 | private final AuthorizationChecker authorizationChecker; 41 | private final JiraSettingsAccessor jiraSettingsAccessor; 42 | 43 | public ConfigController(final PluginSettingsFactory pluginSettingsFactory, final TransactionTemplate transactionTemplate, final UserManager userManager) { 44 | this.pluginSettingsFactory = pluginSettingsFactory; 45 | this.transactionTemplate = transactionTemplate; 46 | authorizationChecker = new AuthorizationChecker(userManager); 47 | jiraSettingsAccessor = new JiraSettingsAccessor(pluginSettingsFactory.createGlobalSettings()); 48 | } 49 | 50 | public PluginSettingsFactory getPluginSettingsFactory() { 51 | return pluginSettingsFactory; 52 | } 53 | 54 | public TransactionTemplate getTransactionTemplate() { 55 | return transactionTemplate; 56 | } 57 | 58 | public AuthorizationChecker getAuthorizationChecker() { 59 | return authorizationChecker; 60 | } 61 | 62 | public JiraSettingsAccessor getJiraSettingsAccessor() { 63 | return jiraSettingsAccessor; 64 | } 65 | 66 | protected T executeAsTransaction(final Supplier supplier) { 67 | return getTransactionTemplate().execute(() -> supplier.get()); 68 | } 69 | 70 | protected boolean isAuthorized(final HttpServletRequest request) { 71 | final GlobalConfigurationAccessor globalConfigurationAccessor = jiraSettingsAccessor.createGlobalConfigurationAccessor(); 72 | final PluginGroupsConfigModel groupsConfig = globalConfigurationAccessor.getGroupsConfig(); 73 | return getAuthorizationChecker().isValidAuthorization(request, groupsConfig.getGroups()); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/BlackDuckAdminConfigSerializable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | import java.util.List; 28 | 29 | import javax.xml.bind.annotation.XmlAccessType; 30 | import javax.xml.bind.annotation.XmlAccessorType; 31 | import javax.xml.bind.annotation.XmlElement; 32 | 33 | import com.synopsys.integration.util.Stringable; 34 | 35 | @XmlAccessorType(XmlAccessType.FIELD) 36 | public class BlackDuckAdminConfigSerializable extends Stringable implements Serializable { 37 | private static final long serialVersionUID = -5925523949026662425L; 38 | 39 | @XmlElement 40 | private String hubJiraGroups; 41 | 42 | @XmlElement 43 | private List jiraGroups; 44 | 45 | @XmlElement 46 | private String hubJiraGroupsError; 47 | 48 | public BlackDuckAdminConfigSerializable() { 49 | } 50 | 51 | public String getHubJiraGroups() { 52 | return hubJiraGroups; 53 | } 54 | 55 | public void setHubJiraGroups(final String hubJiraGroups) { 56 | this.hubJiraGroups = hubJiraGroups; 57 | } 58 | 59 | public List getJiraGroups() { 60 | return jiraGroups; 61 | } 62 | 63 | public void setJiraGroups(final List jiraGroups) { 64 | this.jiraGroups = jiraGroups; 65 | } 66 | 67 | public String getHubJiraGroupsError() { 68 | return hubJiraGroupsError; 69 | } 70 | 71 | public void setHubJiraGroupsError(final String hubJiraGroupsError) { 72 | this.hubJiraGroupsError = hubJiraGroupsError; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | final StringBuilder builder = new StringBuilder(); 78 | builder.append("BlackDuckAdminConfigSerializable [hubJiraGroups="); 79 | builder.append(hubJiraGroups); 80 | builder.append(", jiraGroups="); 81 | builder.append(jiraGroups); 82 | builder.append(", hubJiraGroupsError="); 83 | builder.append(hubJiraGroupsError); 84 | builder.append("]"); 85 | return builder.toString(); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/BlackDuckProject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | 28 | import javax.xml.bind.annotation.XmlAccessType; 29 | import javax.xml.bind.annotation.XmlAccessorType; 30 | import javax.xml.bind.annotation.XmlElement; 31 | import javax.xml.bind.annotation.XmlRootElement; 32 | 33 | import com.synopsys.integration.util.Stringable; 34 | 35 | // Keeping this around in order to read old data from the JIRA SAL 36 | // Deprecated in 4.2.0, delete when customers all upgrade to 4.2.0+ 37 | @Deprecated 38 | @XmlRootElement 39 | @XmlAccessorType(XmlAccessType.FIELD) 40 | public class BlackDuckProject extends Stringable implements Serializable { 41 | private static final long serialVersionUID = -3423054294095627163L; 42 | 43 | @XmlElement 44 | private String projectName; 45 | 46 | @XmlElement 47 | private String projectUrl; 48 | 49 | public BlackDuckProject() { 50 | } 51 | 52 | public String getProjectName() { 53 | return projectName; 54 | } 55 | 56 | public void setProjectName(final String projectName) { 57 | this.projectName = projectName; 58 | } 59 | 60 | public String getProjectUrl() { 61 | return projectUrl; 62 | } 63 | 64 | public void setProjectUrl(final String projectUrl) { 65 | this.projectUrl = projectUrl; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "BlackDuckProject [projectName=" + projectName + ", projectUrl=" + projectUrl + "]"; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/Fields.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import javax.xml.bind.annotation.XmlAccessType; 31 | import javax.xml.bind.annotation.XmlAccessorType; 32 | import javax.xml.bind.annotation.XmlElement; 33 | 34 | import org.apache.commons.lang3.StringUtils; 35 | 36 | import com.blackducksoftware.integration.jira.web.ErrorTracking; 37 | 38 | @XmlAccessorType(XmlAccessType.FIELD) 39 | public class Fields implements Serializable, ErrorTracking { 40 | private static final long serialVersionUID = -9069924658532720147L; 41 | 42 | @XmlElement 43 | private List idToNameMappings = new ArrayList<>(); 44 | 45 | @XmlElement 46 | private String errorMessage; 47 | 48 | @Override 49 | public boolean hasErrors() { 50 | return StringUtils.isNotBlank(errorMessage); 51 | } 52 | 53 | @Override 54 | public String getErrorMessage() { 55 | return errorMessage; 56 | } 57 | 58 | @Override 59 | public void setErrorMessage(final String errorMessage) { 60 | this.errorMessage = errorMessage; 61 | } 62 | 63 | public List getIdToNameMappings() { 64 | return idToNameMappings; 65 | } 66 | 67 | public void setIdToNameMappings(final List idToNameMappings) { 68 | this.idToNameMappings = idToNameMappings; 69 | } 70 | 71 | public void add(final IdToNameMapping idToNameMapping) { 72 | this.idToNameMappings.add(idToNameMapping); 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "Fields [idToNameMappings=" + idToNameMappings + ", errorMessage=" + errorMessage + "]"; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/IdToNameMapping.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | 28 | import javax.xml.bind.annotation.XmlAccessType; 29 | import javax.xml.bind.annotation.XmlAccessorType; 30 | import javax.xml.bind.annotation.XmlElement; 31 | 32 | @XmlAccessorType(XmlAccessType.FIELD) 33 | public class IdToNameMapping implements Serializable, Comparable { 34 | private static final long serialVersionUID = -6879420109287472484L; 35 | 36 | @XmlElement 37 | private String id; 38 | 39 | @XmlElement 40 | private String name; 41 | 42 | public IdToNameMapping() { 43 | } 44 | 45 | public IdToNameMapping(final String id, final String name) { 46 | super(); 47 | this.id = id; 48 | this.name = name; 49 | } 50 | 51 | public String getId() { 52 | return id; 53 | } 54 | 55 | public String getName() { 56 | return name; 57 | } 58 | 59 | @Override 60 | public int compareTo(final IdToNameMapping idToNameMapping) { 61 | if ((idToNameMapping == null) || (idToNameMapping.getName() == null)) { 62 | return 1; 63 | } 64 | 65 | if (getName() == null) { 66 | return -1; 67 | } 68 | 69 | return getName().compareTo(idToNameMapping.getName()); 70 | } 71 | 72 | @Override 73 | public String toString() { 74 | return "IdToNameMapping [id=" + id + ", name=" + name + "]"; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/MigrationDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | import java.util.List; 28 | 29 | import javax.xml.bind.annotation.XmlAccessType; 30 | import javax.xml.bind.annotation.XmlAccessorType; 31 | import javax.xml.bind.annotation.XmlElement; 32 | 33 | import com.synopsys.integration.util.Stringable; 34 | 35 | @XmlAccessorType(XmlAccessType.FIELD) 36 | public class MigrationDetails extends Stringable implements Serializable { 37 | private static final long serialVersionUID = -6869352381133058302L; 38 | 39 | @XmlElement 40 | private List migratedProjects; 41 | 42 | @XmlElement 43 | private List projectsToMigrate; 44 | 45 | @XmlElement 46 | private String migrationStartTime; 47 | 48 | @XmlElement 49 | private String migrationEndTime; 50 | 51 | @XmlElement 52 | private String migrationStatus; 53 | 54 | public MigrationDetails() { 55 | } 56 | 57 | public List getMigratedProjects() { 58 | return migratedProjects; 59 | } 60 | 61 | public void setMigratedProjects(List migratedProjects) { 62 | this.migratedProjects = migratedProjects; 63 | } 64 | 65 | public List getProjectsToMigrate() { 66 | return projectsToMigrate; 67 | } 68 | 69 | public void setProjectsToMigrate(List projectsToMigrate) { 70 | this.projectsToMigrate = projectsToMigrate; 71 | } 72 | 73 | public String getMigrationStartTime() { 74 | return migrationStartTime; 75 | } 76 | 77 | public void setMigrationStartTime(String migrationStartTime) { 78 | this.migrationStartTime = migrationStartTime; 79 | } 80 | 81 | public String getMigrationEndTime() { 82 | return migrationEndTime; 83 | } 84 | 85 | public void setMigrationEndTime(String migrationEndTime) { 86 | this.migrationEndTime = migrationEndTime; 87 | } 88 | 89 | public String getMigrationStatus() { 90 | return migrationStatus; 91 | } 92 | 93 | public void setMigrationStatus(String migrationStatus) { 94 | this.migrationStatus = migrationStatus; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/ProjectPatternRestModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | import java.util.Collection; 28 | 29 | import javax.xml.bind.annotation.XmlAccessType; 30 | import javax.xml.bind.annotation.XmlAccessorType; 31 | import javax.xml.bind.annotation.XmlRootElement; 32 | 33 | import com.synopsys.integration.util.Stringable; 34 | 35 | @XmlRootElement 36 | @XmlAccessorType(XmlAccessType.FIELD) 37 | public class ProjectPatternRestModel extends Stringable implements Serializable { 38 | private static final long serialVersionUID = -8758361473598586323L; 39 | 40 | private Collection projects; 41 | private String regexString; 42 | private String errorMessage; 43 | 44 | public ProjectPatternRestModel() { 45 | } 46 | 47 | public Collection getProjects() { 48 | return projects; 49 | } 50 | 51 | public void setProjects(final Collection projects) { 52 | this.projects = projects; 53 | } 54 | 55 | public String getRegexString() { 56 | return regexString; 57 | } 58 | 59 | public void setRegexString(final String regexString) { 60 | this.regexString = regexString; 61 | } 62 | 63 | public String getErrorMessage() { 64 | return errorMessage; 65 | } 66 | 67 | public void setErrorMessage(final String errorMessage) { 68 | this.errorMessage = errorMessage; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/model/TicketCreationErrorSerializable.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.model; 25 | 26 | import java.io.Serializable; 27 | import java.util.List; 28 | 29 | import javax.xml.bind.annotation.XmlAccessType; 30 | import javax.xml.bind.annotation.XmlAccessorType; 31 | import javax.xml.bind.annotation.XmlElement; 32 | 33 | import com.blackducksoftware.integration.jira.web.TicketCreationError; 34 | import com.synopsys.integration.util.Stringable; 35 | 36 | @XmlAccessorType(XmlAccessType.FIELD) 37 | public class TicketCreationErrorSerializable extends Stringable implements Serializable { 38 | private static final long serialVersionUID = 3871965442453250995L; 39 | 40 | @XmlElement 41 | private List hubJiraTicketErrors; 42 | 43 | @XmlElement 44 | private String configError; 45 | 46 | public TicketCreationErrorSerializable() { 47 | } 48 | 49 | public List getHubJiraTicketErrors() { 50 | return hubJiraTicketErrors; 51 | } 52 | 53 | public void setHubJiraTicketErrors(final List hubJiraTicketErrors) { 54 | this.hubJiraTicketErrors = hubJiraTicketErrors; 55 | } 56 | 57 | public String getConfigError() { 58 | return configError; 59 | } 60 | 61 | public void setConfigError(final String configError) { 62 | this.configError = configError; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | final StringBuilder builder = new StringBuilder(); 68 | builder.append("TicketCreationErrorSerializable [hubJiraTicketErrors="); 69 | builder.append(hubJiraTicketErrors); 70 | builder.append(", configError="); 71 | builder.append(configError); 72 | builder.append("]"); 73 | return builder.toString(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/web/servlet/BlackDuckJiraServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.web.servlet; 25 | 26 | import java.io.IOException; 27 | 28 | import javax.servlet.http.HttpServlet; 29 | import javax.servlet.http.HttpServletRequest; 30 | import javax.servlet.http.HttpServletResponse; 31 | 32 | import com.atlassian.sal.api.auth.LoginUriProvider; 33 | import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; 34 | import com.atlassian.sal.api.user.UserManager; 35 | import com.atlassian.templaterenderer.TemplateRenderer; 36 | 37 | public class BlackDuckJiraServlet extends HttpServlet { 38 | private static final long serialVersionUID = 8293922701957754642L; 39 | 40 | private final TemplateRenderer renderer; 41 | private final LoginRedirect loginRedirect; 42 | 43 | public BlackDuckJiraServlet(final UserManager userManager, final LoginUriProvider loginUriProvider, final TemplateRenderer renderer, final PluginSettingsFactory pluginSettingsFactory) { 44 | this.renderer = renderer; 45 | this.loginRedirect = new LoginRedirect(loginUriProvider, userManager, pluginSettingsFactory); 46 | } 47 | 48 | @Override 49 | public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException { 50 | if (loginRedirect.redirectIfUnauthorized(request, response)) { 51 | return; 52 | } 53 | response.setContentType("text/html;charset=utf-8"); 54 | renderer.render("templates/blackduck-jira.vm", response.getWriter()); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/workflow/notification/CommonNotificationView.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.workflow.notification; 25 | 26 | import java.util.Date; 27 | 28 | import com.synopsys.integration.blackduck.api.core.BlackDuckView; 29 | import com.synopsys.integration.blackduck.api.generated.enumeration.NotificationStateRequestStateType; 30 | import com.synopsys.integration.blackduck.api.generated.enumeration.NotificationType; 31 | import com.synopsys.integration.blackduck.api.manual.view.NotificationUserView; 32 | import com.synopsys.integration.blackduck.api.manual.view.NotificationView; 33 | 34 | /** 35 | * This is a flattened view of both NotificationView and NotificationUserView and must be manually maintained to support both views and their api. The only common class between both views is HubView which is why sourceView is of that type, 36 | * but it should only ever be either NotificationView or NotificationUserView. 37 | */ 38 | public class CommonNotificationView extends BlackDuckView { 39 | private final BlackDuckView sourceView; 40 | private final String contentType; 41 | private final Date createdAt; 42 | private final NotificationType type; 43 | private final NotificationStateRequestStateType notificationState; 44 | 45 | public CommonNotificationView(final NotificationView notificationView) { 46 | sourceView = notificationView; 47 | contentType = notificationView.getContentType(); 48 | createdAt = notificationView.getCreatedAt(); 49 | type = notificationView.getType(); 50 | notificationState = null; 51 | setMeta(notificationView.getMeta()); 52 | setJson(notificationView.getJson()); 53 | } 54 | 55 | public CommonNotificationView(final NotificationUserView notificationUserView) { 56 | sourceView = notificationUserView; 57 | contentType = notificationUserView.getContentType(); 58 | createdAt = notificationUserView.getCreatedAt(); 59 | type = notificationUserView.getType(); 60 | notificationState = notificationUserView.getNotificationState(); 61 | setMeta(notificationUserView.getMeta()); 62 | setJson(notificationUserView.getJson()); 63 | } 64 | 65 | public BlackDuckView getSourceView() { 66 | return sourceView; 67 | } 68 | 69 | public String getContentType() { 70 | return contentType; 71 | } 72 | 73 | public Date getCreatedAt() { 74 | return createdAt; 75 | } 76 | 77 | public NotificationType getType() { 78 | return type; 79 | } 80 | 81 | public NotificationStateRequestStateType getNotificationState() { 82 | return notificationState; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/workflow/notification/CommonNotificationViewResults.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.workflow.notification; 25 | 26 | import java.util.Date; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public class CommonNotificationViewResults extends NotificationResults { 31 | private final List commonNotificationViews; 32 | 33 | public CommonNotificationViewResults(final List commonNotificationViews, final Optional latestNotificationCreatedAtDate, final Optional latestNotificationCreatedAtString) { 34 | super(latestNotificationCreatedAtDate, latestNotificationCreatedAtString); 35 | this.commonNotificationViews = commonNotificationViews; 36 | } 37 | 38 | @Override 39 | public List getResults() { 40 | return commonNotificationViews; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/workflow/notification/NotificationDetailResult.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.workflow.notification; 25 | 26 | import java.util.Date; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | import com.synopsys.integration.blackduck.api.generated.enumeration.NotificationStateRequestStateType; 31 | import com.synopsys.integration.blackduck.api.generated.enumeration.NotificationType; 32 | import com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent; 33 | 34 | public class NotificationDetailResult { 35 | private final NotificationContentComponent notificationContent; 36 | private final String contentType; 37 | private final Date createdAt; 38 | private final NotificationType type; 39 | private final String notificationGroup; 40 | private final Optional notificationState; 41 | 42 | private final List notificationContentDetails; 43 | 44 | public NotificationDetailResult(final NotificationContentComponent notificationContent, final String contentType, final Date createdAt, final NotificationType type, final String notificationGroup, 45 | final Optional notificationState, final List notificationContentDetails) { 46 | this.notificationContent = notificationContent; 47 | this.contentType = contentType; 48 | this.createdAt = createdAt; 49 | this.type = type; 50 | this.notificationGroup = notificationGroup; 51 | this.notificationState = notificationState; 52 | this.notificationContentDetails = notificationContentDetails; 53 | } 54 | 55 | public NotificationContentComponent getNotificationContent() { 56 | return notificationContent; 57 | } 58 | 59 | public String getContentType() { 60 | return contentType; 61 | } 62 | 63 | public Date getCreatedAt() { 64 | return createdAt; 65 | } 66 | 67 | public NotificationType getType() { 68 | return type; 69 | } 70 | 71 | public String getNotificationGroup() { 72 | return notificationGroup; 73 | } 74 | 75 | public Optional getNotificationState() { 76 | return notificationState; 77 | } 78 | 79 | public List getNotificationContentDetails() { 80 | return notificationContentDetails; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/workflow/notification/NotificationDetailResults.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.workflow.notification; 25 | 26 | import java.util.ArrayList; 27 | import java.util.Date; 28 | import java.util.List; 29 | import java.util.Optional; 30 | 31 | import com.synopsys.integration.blackduck.api.UriSingleResponse; 32 | import com.synopsys.integration.blackduck.api.core.BlackDuckResponse; 33 | 34 | public class NotificationDetailResults extends NotificationResults { 35 | private final List resultList; 36 | 37 | public NotificationDetailResults(final List resultList, final Optional latestNotificationCreatedAtDate, final Optional latestNotificationCreatedAtString) { 38 | super(latestNotificationCreatedAtDate, latestNotificationCreatedAtString); 39 | this.resultList = resultList; 40 | } 41 | 42 | public List> getAllLinks() { 43 | final List> uriResponses = new ArrayList<>(); 44 | resultList.forEach(result -> { 45 | result.getNotificationContentDetails().forEach(contentDetail -> { 46 | uriResponses.addAll(contentDetail.getPresentLinks()); 47 | }); 48 | }); 49 | 50 | return uriResponses; 51 | } 52 | 53 | @Override 54 | public List getResults() { 55 | return resultList; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/blackducksoftware/integration/jira/workflow/notification/NotificationResults.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | package com.blackducksoftware.integration.jira.workflow.notification; 25 | 26 | import java.util.Date; 27 | import java.util.List; 28 | import java.util.Optional; 29 | 30 | public abstract class NotificationResults { 31 | private final Optional latestNotificationCreatedAtDate; 32 | private final Optional latestNotificationCreatedAtString; 33 | 34 | public NotificationResults(final Optional latestNotificationCreatedAtDate, final Optional latestNotificationCreatedAtString) { 35 | this.latestNotificationCreatedAtDate = latestNotificationCreatedAtDate; 36 | this.latestNotificationCreatedAtString = latestNotificationCreatedAtString; 37 | } 38 | 39 | public abstract List getResults(); 40 | 41 | public final Optional getLatestNotificationCreatedAtDate() { 42 | return latestNotificationCreatedAtDate; 43 | } 44 | 45 | public final Optional getLatestNotificationCreatedAtString() { 46 | return latestNotificationCreatedAtString; 47 | } 48 | 49 | public boolean isEmpty() { 50 | return getResults() == null || getResults().isEmpty(); 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/Design_v01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/Design_v01.png -------------------------------------------------------------------------------- /src/main/resources/css/blackduck-jira-issue-panel.css: -------------------------------------------------------------------------------- 1 | .bds-name, .bds-value { 2 | text-align: left; 3 | display: inline-block; 4 | } 5 | 6 | .bds-name { 7 | float: left; 8 | color: #707070; 9 | font-weight: normal; 10 | padding: 2px 5px 2px 0; 11 | padding-right: 5px; 12 | width: 150px; 13 | text-align: left; 14 | display: inline-block; 15 | } 16 | 17 | .bds-value { 18 | word-wrap: break-word; 19 | word-break: break-word; 20 | display: inline-block; 21 | max-width: 100%; 22 | padding-bottom: 2px; 23 | padding-left: 5px; 24 | padding-top: 2px; 25 | position: relative; 26 | vertical-align: top; 27 | text-align: left; 28 | } 29 | 30 | .bds-wrap { 31 | padding: 0 10px 0 0px; 32 | } 33 | 34 | .bds-fiftyPercent { 35 | width: 50%; 36 | box-sizing: border-box; 37 | } 38 | 39 | div.bds-fieldSectionSeparator { 40 | clear: both; 41 | } -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/font-awesome-4.5.0/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/font-awesome-4.5.0/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/animated.less: -------------------------------------------------------------------------------- 1 | // Animated Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .@{fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .@{fa-css-prefix}-pull-left { float: left; } 11 | .@{fa-css-prefix}-pull-right { float: right; } 12 | 13 | .@{fa-css-prefix} { 14 | &.@{fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.@{fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .@{fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.5.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables.less"; 7 | @import "mixins.less"; 8 | @import "path.less"; 9 | @import "core.less"; 10 | @import "larger.less"; 11 | @import "fixed-width.less"; 12 | @import "list.less"; 13 | @import "bordered-pulled.less"; 14 | @import "animated.less"; 15 | @import "rotated-flipped.less"; 16 | @import "stacked.less"; 17 | @import "icons.less"; 18 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/larger.less: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .@{fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .@{fa-css-prefix}-2x { font-size: 2em; } 11 | .@{fa-css-prefix}-3x { font-size: 3em; } 12 | .@{fa-css-prefix}-4x { font-size: 4em; } 13 | .@{fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | .fa-icon-rotate(@degrees, @rotation) { 15 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 16 | -webkit-transform: rotate(@degrees); 17 | -ms-transform: rotate(@degrees); 18 | transform: rotate(@degrees); 19 | } 20 | 21 | .fa-icon-flip(@horiz, @vert, @rotation) { 22 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 23 | -webkit-transform: scale(@horiz, @vert); 24 | -ms-transform: scale(@horiz, @vert); 25 | transform: scale(@horiz, @vert); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .@{fa-css-prefix}-rotate-90, 15 | :root .@{fa-css-prefix}-rotate-180, 16 | :root .@{fa-css-prefix}-rotate-270, 17 | :root .@{fa-css-prefix}-flip-horizontal, 18 | :root .@{fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .#{$fa-css-prefix}-pull-left { float: left; } 11 | .#{$fa-css-prefix}-pull-right { float: right; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.#{$fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.#{$fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .#{$fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | @mixin fa-icon-rotate($degrees, $rotation) { 15 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 16 | -webkit-transform: rotate($degrees); 17 | -ms-transform: rotate($degrees); 18 | transform: rotate($degrees); 19 | } 20 | 21 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 22 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 23 | -webkit-transform: scale($horiz, $vert); 24 | -ms-transform: scale($horiz, $vert); 25 | transform: scale($horiz, $vert); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/font-awesome-4.5.0/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.5.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | -------------------------------------------------------------------------------- /src/main/resources/images/180 - duck_policy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/images/180 - duck_policy.png -------------------------------------------------------------------------------- /src/main/resources/images/180 - duck_vulnerability.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/images/180 - duck_vulnerability.png -------------------------------------------------------------------------------- /src/main/resources/images/Ducky-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackducksoftware/blackduck-jira/a17c3d34b6a0bee6e083ffd2b5c77c08a62ad71c/src/main/resources/images/Ducky-200.png -------------------------------------------------------------------------------- /src/main/resources/js/access/access-request.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | function readAdminData() { 25 | AJS.$.ajax({ 26 | url: createRequestPath('config/access/'), 27 | dataType: "json", 28 | success: function (admin) { 29 | fillInJiraGroups(admin.hubJiraGroups, admin.jiraGroups); 30 | handleError('hubJiraGroupsError', admin.hubJiraGroupsError, true, false); 31 | }, 32 | error: function (response) { 33 | handleDataRetrievalError(response, "hubJiraGroupsError", "There was a problem retrieving the Admin configuration.", "Admin Error"); 34 | }, 35 | complete: function (jqXHR, textStatus) { 36 | console.log("Completed get of groups: " + textStatus); 37 | } 38 | }); 39 | } 40 | 41 | function updateAccessConfig() { 42 | putAccessConfig(createRequestPath('config/access'), 'Save successful.', 'The configuration is not valid.'); 43 | } 44 | 45 | function putAccessConfig(restUrl, successMessage, failureMessage) { 46 | const hubJiraGroups = encodeURI(AJS.$("#" + hubJiraGroupsId).val()); 47 | 48 | AJS.$.ajax({ 49 | url: restUrl, 50 | type: "PUT", 51 | dataType: "json", 52 | contentType: "application/json", 53 | data: '{ "hubJiraGroups": "' + hubJiraGroups 54 | + '"}', 55 | processData: false, 56 | success: function () { 57 | hideError('hubJiraGroupsError'); 58 | showStatusMessage(successStatus, 'Success!', successMessage); 59 | initCreatorCandidates(); 60 | }, 61 | error: function (response) { 62 | try { 63 | if (!redirectIfUnauthenticated(response)) { 64 | let admin = JSON.parse(response.responseText); 65 | handleError('hubJiraGroupsError', admin.hubJiraGroupsError, true, true); 66 | 67 | showStatusMessage(errorStatus, 'ERROR!', failureMessage); 68 | } 69 | } catch (err) { 70 | // in case the response is not our error object 71 | alert(response.responseText); 72 | } 73 | }, 74 | complete: function (jqXHR, textStatus) { 75 | stopProgressSpinner('adminSaveSpinner'); 76 | } 77 | }); 78 | } 79 | -------------------------------------------------------------------------------- /src/main/resources/js/access/access-utilities.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Black Duck JIRA Plugin 3 | * 4 | * Copyright (C) 2020 Synopsys, Inc. 5 | * https://www.synopsys.com/ 6 | * 7 | * Licensed to the Apache Software Foundation (ASF) under one 8 | * or more contributor license agreements. See the NOTICE file 9 | * distributed with this work for additional information 10 | * regarding copyright ownership. The ASF licenses this file 11 | * to you under the Apache License, Version 2.0 (the 12 | * "License"); you may not use this file except in compliance 13 | * with the License. You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, 18 | * software distributed under the License is distributed on an 19 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | * KIND, either express or implied. See the License for the 21 | * specific language governing permissions and limitations 22 | * under the License. 23 | */ 24 | function fillInJiraGroups(hubJiraGroups, jiraGroups) { 25 | let splitHubJiraGroups = null; 26 | if (hubJiraGroups != null) { 27 | splitHubJiraGroups = hubJiraGroups.split(","); 28 | } 29 | const jiraGroupList = AJS.$("#" + hubJiraGroupsId); 30 | if (jiraGroups != null && jiraGroups.length > 0) { 31 | for (let j = 0; j < jiraGroups.length; j++) { 32 | let optionSelected = false; 33 | if (splitHubJiraGroups != null) { 34 | for (let g = 0; g < splitHubJiraGroups.length; g++) { 35 | if (splitHubJiraGroups[g] === jiraGroups[j]) { 36 | optionSelected = true; 37 | } 38 | } 39 | } 40 | 41 | let newOption = AJS.$('