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
65e0da83
Commit
65e0da83
authored
Nov 06, 2017
by
Greg Messner
Browse files
Added login() method with an ignoreCertificateErrors parameter (#94).
parent
88ad4250
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
65e0da83
...
@@ -62,9 +62,7 @@ public class GitLabApi {
...
@@ -62,9 +62,7 @@ public class GitLabApi {
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
*/
public
static
GitLabApi
login
(
ApiVersion
apiVersion
,
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
public
static
GitLabApi
login
(
ApiVersion
apiVersion
,
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
SessionApi
sessionApi
=
new
SessionApi
(
new
GitLabApi
(
apiVersion
,
url
,
(
String
)
null
));
return
(
login
(
apiVersion
,
url
,
username
,
password
,
false
));
Session
session
=
sessionApi
.
login
(
username
,
null
,
password
);
return
(
new
GitLabApi
(
apiVersion
,
url
,
session
));
}
}
/**
/**
...
@@ -78,7 +76,52 @@ public class GitLabApi {
...
@@ -78,7 +76,52 @@ public class GitLabApi {
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
*/
public
static
GitLabApi
login
(
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
public
static
GitLabApi
login
(
String
url
,
String
username
,
String
password
)
throws
GitLabApiException
{
return
(
login
(
ApiVersion
.
V4
,
url
,
username
,
password
));
return
(
login
(
ApiVersion
.
V4
,
url
,
username
,
password
,
false
));
}
/**
* Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token and the specified GitLab API version.
*
* @param apiVersion the ApiVersion specifying which version of the API to use
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
static
GitLabApi
login
(
ApiVersion
apiVersion
,
String
url
,
String
username
,
String
password
,
boolean
ignoreCertificateErrors
)
throws
GitLabApiException
{
GitLabApi
gitLabApi
=
new
GitLabApi
(
apiVersion
,
url
,
(
String
)
null
);
if
(
ignoreCertificateErrors
)
{
gitLabApi
.
setIgnoreCertificateErrors
(
true
);
}
SessionApi
sessionApi
=
gitLabApi
.
getSessionApi
();
Session
session
=
sessionApi
.
login
(
username
,
null
,
password
);
gitLabApi
=
new
GitLabApi
(
apiVersion
,
url
,
session
);
if
(
ignoreCertificateErrors
)
{
gitLabApi
.
setIgnoreCertificateErrors
(
true
);
}
return
(
gitLabApi
);
}
/**
* Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
* using returned private token using GitLab API version 4.
*
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
* @return new {@code GitLabApi} instance configured for a user-specific token
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
public
static
GitLabApi
login
(
String
url
,
String
username
,
String
password
,
boolean
ignoreCertificateErrors
)
throws
GitLabApiException
{
return
(
login
(
ApiVersion
.
V4
,
url
,
username
,
password
,
ignoreCertificateErrors
));
}
}
/**
/**
...
...
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