use of com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties in project hub-alert by blackducksoftware.
the class AzureBoardsProcessorFactory method createProcessor.
@Override
public IssueTrackerProcessor<Integer> createProcessor(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
String organizationName = azureBoardsProperties.getOrganizationName();
azureBoardsProperties.validateProperties();
// Initialize Http Service
ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
AzureHttpRequestCreator azureHttpRequestCreator = azureBoardsProperties.createAzureHttpRequestCreator(proxy, gson);
AzureHttpService azureHttpService = new AzureHttpService(gson, azureHttpRequestCreator);
// Common Azure Boards Services
AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
AzureProjectService projectService = new AzureProjectService(azureHttpService, apiVersionAppender);
AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
AzureWorkItemQueryService workItemQueryService = new AzureWorkItemQueryService(azureHttpService, apiVersionAppender);
String projectNameOrId = distributionDetails.getProjectNameOrId();
String teamProjectName = retrieveProjectNameIfNecessary(projectService, organizationName, projectNameOrId);
installCustomFieldsIfNecessary(organizationName, teamProjectName, distributionDetails.getWorkItemType(), projectService, new AzureProcessService(azureHttpService, apiVersionAppender));
// Searcher Requirements
AzureBoardsIssueStatusResolver azureBoardsIssueStatusResolver = new AzureBoardsIssueStatusResolver(distributionDetails.getWorkItemCompletedState(), distributionDetails.getWorkItemReopenState());
AzureBoardsIssueTrackerQueryManager queryManager = new AzureBoardsIssueTrackerQueryManager(organizationName, distributionDetails, workItemService, workItemQueryService);
// Extractor Requirements
AzureBoardsExistingIssueDetailsCreator issueDetailsCreator = new AzureBoardsExistingIssueDetailsCreator(organizationName, issueCategoryRetriever, azureBoardsIssueStatusResolver);
AzureBoardsWorkItemFinder workItemFinder = new AzureBoardsWorkItemFinder(queryManager, teamProjectName);
AzureBoardsProjectAndVersionIssueFinder projectAndVersionIssueFinder = new AzureBoardsProjectAndVersionIssueFinder(gson, issueDetailsCreator, workItemFinder);
AzureBoardsComponentIssueFinder componentIssueFinder = new AzureBoardsComponentIssueFinder(gson, workItemFinder, issueDetailsCreator);
IssueTrackerSearcher<Integer> azureBoardsSearcher = new IssueTrackerSearcher<>(projectAndVersionIssueFinder, projectAndVersionIssueFinder, componentIssueFinder, componentIssueFinder, modelTransformer);
IssueTrackerModelExtractor<Integer> extractor = new IssueTrackerModelExtractor<>(formatter, azureBoardsSearcher);
// Message Sender Requirements
AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
IssueTrackerMessageSender<Integer> messageSender = azureBoardsMessageSenderFactory.createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, organizationName, distributionDetails);
return new IssueTrackerProcessor<>(extractor, messageSender);
}
use of com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties in project hub-alert by blackducksoftware.
the class AzureBoardsGlobalFieldModelTestAction method testConfig.
@Override
public MessageResult testConfig(String configId, FieldModel fieldModel, FieldUtility registeredFieldValues) throws IntegrationException {
try {
Optional<ConfigurationFieldModel> configurationFieldModel = registeredFieldValues.getField(AzureBoardsDescriptor.KEY_ORGANIZATION_NAME);
String organizationName = configurationFieldModel.flatMap(ConfigurationFieldModel::getFieldValue).orElse(null);
AzureBoardsProperties azureBoardsProperties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, azureRedirectUrlCreator.createOAuthRedirectUri(), registeredFieldValues);
AzureHttpService azureHttpService = createAzureHttpService(azureBoardsProperties);
AzureProjectService azureProjectService = new AzureProjectService(azureHttpService, new AzureApiVersionAppender());
azureProjectService.getProjects(organizationName);
return new MessageResult("Successfully connected to Azure instance.");
} catch (HttpServiceException ex) {
logger.error("Global Test Action failed testing Azure Boards connection.", ex);
throw (ex);
}
}
use of com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties in project hub-alert by blackducksoftware.
the class AzureOAuthCallbackController method oauthCallback.
@GetMapping
public ResponseEntity<String> oauthCallback(HttpServletRequest request) {
logger.debug("Azure OAuth callback method called");
if (!authorizationManager.hasExecutePermission(ConfigContextEnum.GLOBAL.name(), ChannelKeys.AZURE_BOARDS.getUniversalKey())) {
logger.debug("Azure OAuth callback user does not have permission to call the controller.");
return responseFactory.createForbiddenResponse();
}
String state = request.getParameter("state");
String oAuthRequestId = oAuthRequestValidator.parseRequestIdString(state);
try {
String requestURI = request.getRequestURI();
String requestQueryString = request.getQueryString();
logger.debug("Request URI {}?{}", requestURI, requestQueryString);
String authorizationCode = request.getParameter("code");
if (!oAuthRequestValidator.hasRequestKey(state)) {
logger.info("OAuth request with id {}: not found.", oAuthRequestId);
} else {
logger.info("OAuth request with id {}: Processing...", oAuthRequestId);
oAuthRequestValidator.removeAuthorizationRequest(state);
FieldUtility fieldUtility = createFieldAccessor();
if (fieldUtility.getFields().isEmpty()) {
logger.error("OAuth request with id {}: Azure oauth callback: Channel global configuration missing", oAuthRequestId);
} else {
if (StringUtils.isBlank(authorizationCode)) {
logger.error("OAuth request with id {}: Azure oauth callback: Authorization code isn't valid. Stop processing", oAuthRequestId);
} else {
String oAuthRedirectUri = azureRedirectUrlCreator.createOAuthRedirectUri();
AzureBoardsProperties properties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, oAuthRedirectUri, fieldUtility);
testOAuthConnection(properties, authorizationCode, oAuthRequestId);
}
}
}
} catch (Exception ex) {
// catch any exceptions so the redirect back to the UI happens and doesn't display the URL with the authorization code to the user.
logger.error("OAuth request with id {}: Azure OAuth callback error occurred", oAuthRequestId, ex);
}
// redirect back to the global channel configuration URL in the Alert UI.
return responseFactory.createFoundRedirectResponse(azureRedirectUrlCreator.createUIRedirectLocation());
}
use of com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties in project hub-alert by blackducksoftware.
the class AzureBoardsMessageSenderFactory method createMessageSender.
@Override
public IssueTrackerMessageSender<Integer> createMessageSender(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
azureBoardsProperties.validateProperties();
// Initialize Http Service
ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
AzureHttpRequestCreator azureHttpRequestCreator = azureBoardsProperties.createAzureHttpRequestCreator(proxy, gson);
AzureHttpService azureHttpService = new AzureHttpService(gson, azureHttpRequestCreator);
// Azure Boards Services
AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
return createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, azureBoardsProperties.getOrganizationName(), distributionDetails);
}
use of com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties in project hub-alert by blackducksoftware.
the class AzureBoardsCustomFunctionAction method isAuthenticated.
private boolean isAuthenticated(FieldUtility fieldUtility) {
AzureBoardsProperties properties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, azureRedirectUrlCreator.createOAuthRedirectUri(), fieldUtility);
ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
return properties.hasOAuthCredentials(proxy);
}
Aggregations