Hide token in exception message.
This commit is contained in:
parent
70387d3cfd
commit
af44628def
1 changed files with 27 additions and 11 deletions
|
@ -51,6 +51,8 @@ public class GiteaAPI
|
||||||
* Instantiates a new gitea API.
|
* Instantiates a new gitea API.
|
||||||
*/
|
*/
|
||||||
public GiteaAPI(final String url, final String token) throws IOException, ParseException
|
public GiteaAPI(final String url, final String token) throws IOException, ParseException
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
this.url = StringUtils.removeEnd(url, "/");
|
this.url = StringUtils.removeEnd(url, "/");
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
@ -67,6 +69,20 @@ public class GiteaAPI
|
||||||
json = IOUtils.toString(new URL(this.url + "/api/v1/repos/search?limit=100000&token=" + token), Charset.defaultCharset());
|
json = IOUtils.toString(new URL(this.url + "/api/v1/repos/search?limit=100000&token=" + token), Charset.defaultCharset());
|
||||||
this.repositories = (JSONArray) ((JSONObject) (new JSONParser().parse(json))).get("data");
|
this.repositories = (JSONArray) ((JSONObject) (new JSONParser().parse(json))).get("data");
|
||||||
}
|
}
|
||||||
|
catch (IOException exception)
|
||||||
|
{
|
||||||
|
String message = exception.getMessage();
|
||||||
|
if (message.matches(".*token=\\w+.*"))
|
||||||
|
{
|
||||||
|
message = message.replaceAll("token=\\w+", "token=*******");
|
||||||
|
throw new IOException(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the active user count.
|
* Gets the active user count.
|
||||||
|
|
Loading…
Reference in a new issue