mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 11:35:57 +01:00
Remove deprecated api calls
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sonia.scm.web;
|
package sonia.scm.web;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -40,23 +40,21 @@ import sonia.scm.plugin.Extension;
|
|||||||
*/
|
*/
|
||||||
@Extension
|
@Extension
|
||||||
public class GitUserAgentProvider implements UserAgentProvider {
|
public class GitUserAgentProvider implements UserAgentProvider {
|
||||||
|
|
||||||
private static final String PREFIX_JGIT = "jgit/";
|
private static final String PREFIX_JGIT = "jgit/";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final UserAgent JGIT = UserAgent.scmClient("JGit")
|
static final UserAgent JGIT = UserAgent.scmClient("JGit")
|
||||||
.browser(false)
|
|
||||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final String PREFIX_REGULAR = "git/";
|
private static final String PREFIX_REGULAR = "git/";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final UserAgent GIT = UserAgent.scmClient("Git")
|
static final UserAgent GIT = UserAgent.scmClient("Git")
|
||||||
.browser(false)
|
|
||||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final String PREFIX_LFS = "git-lfs/";
|
private static final String PREFIX_LFS = "git-lfs/";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -65,7 +63,7 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final String SUFFIX_MSYSGIT = "msysgit";
|
private static final String SUFFIX_MSYSGIT = "msysgit";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final UserAgent MSYSGIT = UserAgent.scmClient("msysGit")
|
static final UserAgent MSYSGIT = UserAgent.scmClient("msysGit")
|
||||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||||
@@ -78,7 +76,7 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
|||||||
@Override
|
@Override
|
||||||
public UserAgent parseUserAgent(String userAgentString) {
|
public UserAgent parseUserAgent(String userAgentString) {
|
||||||
String lowerUserAgent = toLower(userAgentString);
|
String lowerUserAgent = toLower(userAgentString);
|
||||||
|
|
||||||
if (isJGit(lowerUserAgent)) {
|
if (isJGit(lowerUserAgent)) {
|
||||||
return JGIT;
|
return JGIT;
|
||||||
} else if (isMsysGit(lowerUserAgent)) {
|
} else if (isMsysGit(lowerUserAgent)) {
|
||||||
@@ -91,23 +89,23 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toLower(String value) {
|
private String toLower(String value) {
|
||||||
return Strings.nullToEmpty(value).toLowerCase(Locale.ENGLISH);
|
return Strings.nullToEmpty(value).toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isJGit(String userAgent) {
|
private boolean isJGit(String userAgent) {
|
||||||
return userAgent.startsWith(PREFIX_JGIT);
|
return userAgent.startsWith(PREFIX_JGIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMsysGit(String userAgent) {
|
private boolean isMsysGit(String userAgent) {
|
||||||
return userAgent.startsWith(PREFIX_REGULAR) && userAgent.contains(SUFFIX_MSYSGIT);
|
return userAgent.startsWith(PREFIX_REGULAR) && userAgent.contains(SUFFIX_MSYSGIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGitLFS(String userAgent) {
|
private boolean isGitLFS(String userAgent) {
|
||||||
return userAgent.startsWith(PREFIX_LFS);
|
return userAgent.startsWith(PREFIX_LFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGit(String userAgent) {
|
private boolean isGit(String userAgent) {
|
||||||
return userAgent.startsWith(PREFIX_REGULAR);
|
return userAgent.startsWith(PREFIX_REGULAR);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user