@@ -62,9 +62,7 @@ public String getApiNamespace() {
62
62
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
63
63
*/
64
64
public static GitLabApi login (ApiVersion apiVersion , String url , String username , String password ) throws GitLabApiException {
65
- SessionApi sessionApi = new SessionApi (new GitLabApi (apiVersion , url , (String )null ));
66
- Session session = sessionApi .login (username , null , password );
67
- return (new GitLabApi (apiVersion , url , session ));
65
+ return (login (apiVersion , url , username , password , false ));
68
66
}
69
67
70
68
/**
@@ -78,7 +76,52 @@ public static GitLabApi login(ApiVersion apiVersion, String url, String username
78
76
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
79
77
*/
80
78
public static GitLabApi login (String url , String username , String password ) throws GitLabApiException {
81
- return (login (ApiVersion .V4 , url , username , password ));
79
+ return (login (ApiVersion .V4 , url , username , password , false ));
80
+ }
81
+
82
+ /**
83
+ * Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
84
+ * using returned private token and the specified GitLab API version.
85
+ *
86
+ * @param apiVersion the ApiVersion specifying which version of the API to use
87
+ * @param url GitLab URL
88
+ * @param username user name for which private token should be obtained
89
+ * @param password password for a given {@code username}
90
+ * @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
91
+ * @return new {@code GitLabApi} instance configured for a user-specific token
92
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
93
+ */
94
+ public static GitLabApi login (ApiVersion apiVersion , String url , String username , String password , boolean ignoreCertificateErrors ) throws GitLabApiException {
95
+
96
+ GitLabApi gitLabApi = new GitLabApi (apiVersion , url , (String )null );
97
+ if (ignoreCertificateErrors ) {
98
+ gitLabApi .setIgnoreCertificateErrors (true );
99
+ }
100
+
101
+ SessionApi sessionApi = gitLabApi .getSessionApi ();
102
+ Session session = sessionApi .login (username , null , password );
103
+ gitLabApi = new GitLabApi (apiVersion , url , session );
104
+
105
+ if (ignoreCertificateErrors ) {
106
+ gitLabApi .setIgnoreCertificateErrors (true );
107
+ }
108
+
109
+ return (gitLabApi );
110
+ }
111
+
112
+ /**
113
+ * Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
114
+ * using returned private token using GitLab API version 4.
115
+ *
116
+ * @param url GitLab URL
117
+ * @param username user name for which private token should be obtained
118
+ * @param password password for a given {@code username}
119
+ * @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
120
+ * @return new {@code GitLabApi} instance configured for a user-specific token
121
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
122
+ */
123
+ public static GitLabApi login (String url , String username , String password , boolean ignoreCertificateErrors ) throws GitLabApiException {
124
+ return (login (ApiVersion .V4 , url , username , password , ignoreCertificateErrors ));
82
125
}
83
126
84
127
/**
0 commit comments