mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-05 08:21:21 +00:00
Provide a way to determine if the connection is anonymous
This commit is contained in:
@@ -192,8 +192,16 @@ public class GitHub {
|
||||
return new GitHub(null,null,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an anonymous connection
|
||||
* @return {@code true} if operations that require authentication will fail.
|
||||
*/
|
||||
public boolean isAnonymous() {
|
||||
return login==null && encodedAuthorization==null;
|
||||
}
|
||||
|
||||
/*package*/ void requireCredential() {
|
||||
if (login==null && encodedAuthorization==null)
|
||||
if (isAnonymous())
|
||||
throw new IllegalStateException("This operation requires a credential but none is given to the GitHub constructor");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user