| | |
| | | import java.io.InputStreamReader; |
| | | import java.net.HttpURLConnection; |
| | | |
| | | import org.apache.wicket.util.io.IOUtils; |
| | | import org.apache.commons.io.IOUtils; |
| | | |
| | | import com.gitblit.Constants; |
| | | import com.gitblit.Constants.AccountType; |
| | | import com.gitblit.Constants.Role; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.auth.AuthenticationProvider.UsernamePasswordAuthenticationProvider; |
| | | import com.gitblit.models.TeamModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.utils.ConnectionUtils; |
| | | import com.gitblit.utils.StringUtils; |
| | |
| | | public boolean supportsTeamMembershipChanges() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean supportsRoleChanges(UserModel user, Role role) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean supportsRoleChanges(TeamModel team, Role role) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public AccountType getAccountType() { |
| | |
| | | if (!url.endsWith("/")) { |
| | | url = url.concat("/"); |
| | | } |
| | | String apiUrl = url + "users/current.json"; |
| | | |
| | | HttpURLConnection http; |
| | | if (username == null) { |
| | | // apikey authentication |
| | | String apiKey = String.valueOf(password); |
| | | String apiUrl = url + "users/current.json?key=" + apiKey; |
| | | http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, null, null); |
| | | http.addRequestProperty("X-Redmine-API-Key", apiKey); |
| | | } else { |
| | | // username/password BASIC authentication |
| | | String apiUrl = url + "users/current.json"; |
| | | http = (HttpURLConnection) ConnectionUtils.openConnection(apiUrl, username, password); |
| | | } |
| | | http.setRequestMethod("GET"); |