|
1 | 1 | /* |
2 | | - * Copyright (c) 2012-2024 Red Hat, Inc. |
| 2 | + * Copyright (c) 2012-2025 Red Hat, Inc. |
3 | 3 | * This program and the accompanying materials are made |
4 | 4 | * available under the terms of the Eclipse Public License 2.0 |
5 | 5 | * which is available at https://www.eclipse.org/legal/epl-2.0/ |
|
30 | 30 | import org.eclipse.che.api.factory.server.scm.PersonalAccessTokenManager; |
31 | 31 | import org.eclipse.che.api.factory.server.scm.exception.ScmCommunicationException; |
32 | 32 | import org.eclipse.che.api.factory.server.scm.exception.ScmConfigurationPersistenceException; |
33 | | -import org.eclipse.che.api.factory.server.scm.exception.ScmItemNotFoundException; |
34 | | -import org.eclipse.che.api.factory.server.scm.exception.ScmUnauthorizedException; |
35 | 33 | import org.eclipse.che.api.factory.server.urlfactory.DevfileFilenamesProvider; |
36 | 34 | import org.eclipse.che.commons.annotation.Nullable; |
37 | 35 | import org.eclipse.che.commons.env.EnvironmentContext; |
38 | 36 | import org.eclipse.che.commons.lang.StringUtils; |
39 | 37 | import org.eclipse.che.security.oauth.OAuthAPI; |
40 | | -import org.eclipse.che.security.oauth1.BitbucketServerOAuthAuthenticator; |
41 | 38 |
|
42 | 39 | /** |
43 | 40 | * Parser of String Bitbucket Server URLs and provide {@link BitbucketServerUrl} objects. |
@@ -112,31 +109,10 @@ public boolean isValid(@NotNull String url) { |
112 | 109 | return |
113 | 110 | // If Bitbucket server URL is not configured try to find it in a manually added user namespace |
114 | 111 | // token. |
115 | | - isUserTokenPresent(url) |
116 | | - // Try to call an API request to see if the URL matches Bitbucket. |
117 | | - || isApiRequestRelevant(url); |
| 112 | + isUserTokenPresent(url); |
118 | 113 | } |
119 | 114 | } |
120 | 115 |
|
121 | | - private boolean isApiRequestRelevant(String repositoryUrl) { |
122 | | - try { |
123 | | - HttpBitbucketServerApiClient bitbucketServerApiClient = |
124 | | - new HttpBitbucketServerApiClient( |
125 | | - getServerUrl(repositoryUrl), |
126 | | - new BitbucketServerOAuthAuthenticator("", "", "", ""), |
127 | | - oAuthAPI, |
128 | | - ""); |
129 | | - // If the user request catches the unauthorised error, it means that the provided url |
130 | | - // belongs to Bitbucket. |
131 | | - bitbucketServerApiClient.getUser(); |
132 | | - } catch (ScmItemNotFoundException | ScmCommunicationException e) { |
133 | | - return false; |
134 | | - } catch (ScmUnauthorizedException e) { |
135 | | - return true; |
136 | | - } |
137 | | - return false; |
138 | | - } |
139 | | - |
140 | 116 | private String getServerUrl(String repositoryUrl) { |
141 | 117 | if (repositoryUrl.startsWith("ssh://git@")) { |
142 | 118 | String substring = repositoryUrl.substring(10); |
|
0 commit comments