Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
cb7987bd
Commit
cb7987bd
authored
Jul 02, 2019
by
Greg Messner
Browse files
Cleaned up OAUTH2 login logic.
parent
4c62a279
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/AbstractApi.java
View file @
cb7987bd
...
...
@@ -21,7 +21,7 @@ import org.gitlab4j.api.models.User;
*/
public
abstract
class
AbstractApi
implements
Constants
{
pr
ivate
final
GitLabApi
gitLabApi
;
pr
otected
final
GitLabApi
gitLabApi
;
public
AbstractApi
(
GitLabApi
gitLabApi
)
{
this
.
gitLabApi
=
gitLabApi
;
...
...
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
cb7987bd
...
...
@@ -33,7 +33,7 @@ public class GitLabApi {
/** Specifies the version of the GitLab API to communicate with. */
public
enum
ApiVersion
{
V3
,
V4
,
OAUTH2_CLIENT
;
V3
,
V4
;
public
String
getApiNamespace
()
{
return
(
"/api/"
+
name
().
toLowerCase
());
...
...
@@ -268,7 +268,10 @@ public class GitLabApi {
throw
new
IllegalArgumentException
(
"both username and email cannot be empty or null"
);
}
GitLabApi
gitLabApi
=
new
GitLabApi
(
ApiVersion
.
OAUTH2_CLIENT
,
url
,
(
String
)
null
);
// Create a GitLabApi instance set up to be used to do an OAUTH2 login.
GitLabApi
gitLabApi
=
new
GitLabApi
(
apiVersion
,
url
,
(
String
)
null
);
gitLabApi
.
apiClient
.
setHostUrlToBaseUrl
();
if
(
ignoreCertificateErrors
)
{
gitLabApi
.
setIgnoreCertificateErrors
(
true
);
}
...
...
src/main/java/org/gitlab4j/api/GitLabApiClient.java
View file @
cb7987bd
...
...
@@ -210,9 +210,7 @@ public class GitLabApiClient {
// Remove the trailing "/" from the hostUrl if present
this
.
hostUrl
=
(
hostUrl
.
endsWith
(
"/"
)
?
hostUrl
.
replaceAll
(
"/$"
,
""
)
:
hostUrl
);
this
.
baseUrl
=
this
.
hostUrl
;
if
(
ApiVersion
.
OAUTH2_CLIENT
!=
apiVersion
)
{
this
.
hostUrl
+=
apiVersion
.
getApiNamespace
();
}
this
.
hostUrl
+=
apiVersion
.
getApiNamespace
();
this
.
tokenType
=
tokenType
;
this
.
authToken
=
authToken
;
...
...
@@ -760,6 +758,13 @@ public class GitLabApiClient {
return
(
builder
);
}
/**
* Used to set the host URL to be used by OAUTH2 login in GitLabApi.
*/
void
setHostUrlToBaseUrl
()
{
this
.
hostUrl
=
this
.
baseUrl
;
}
/**
* Returns true if the API is setup to ignore SSL certificate errors, otherwise returns false.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment