Package net.nathcat.authcat
Class AuthCat
java.lang.Object
net.nathcat.authcat.AuthCat
An integration for making requests to the AuthCat service.
This class contains methods which will allow you to easily make requests to the AuthCat service for better integration with your applications.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAuthCat()Create a new AuthCat instance using the default HTTP provider (SEHttpProvider).AuthCat(IHttpProvider httpProvider) Create a new AuthCat instance with a custom HTTP provider. -
Method Summary
Modifier and TypeMethodDescriptioncreateAuthToken(org.json.simple.JSONObject user) Generate a quick auth token for a userloginWithCookie(String cookie) Use a quick auth token for authentication.tryAuthenticate(org.json.simple.JSONObject user) Send an authentication request to AuthCat.tryLogin(org.json.simple.JSONObject authEntry) Call the authentication service from AuthCat.org.json.simple.JSONObjectuserSearch(String key, Object data) Call the user search service.org.json.simple.JSONObjectuserSearch(org.json.simple.JSONObject searchData) Call the user search service
-
Constructor Details
-
AuthCat
Create a new AuthCat instance with a custom HTTP provider.- Parameters:
httpProvider-
-
AuthCat
public AuthCat()Create a new AuthCat instance using the default HTTP provider (SEHttpProvider).
-
-
Method Details
-
tryLogin
- Throws:
InvalidResponse
-
tryLogin
Call the authentication service from AuthCat.- Parameters:
authEntry- The supplied authentication data, should contain a username and password field- Returns:
- The AuthResult
- Throws:
InvalidResponse- Thrown if the service responds with an unexpected or invalid response code
-
loginWithCookie
- Throws:
InvalidResponse
-
userSearch
Call the user search service. With more explicit arguments- Parameters:
key- The data key to search for (fullName / id / username).data- The data to search for- Returns:
- The JSON response from the server.
- Throws:
InvalidResponse
-
userSearch
public org.json.simple.JSONObject userSearch(org.json.simple.JSONObject searchData) throws InvalidResponse Call the user search service- Parameters:
searchData- The JSON search data, must contain either a username field, or a fullName field, or both- Returns:
- The JSON response from the server
- Throws:
InvalidResponse- Thrown if the service responds with an unexpected or invalid response
-
tryAuthenticate
Send an authentication request to AuthCat. Will attempt cookie authentication first if thecookieAuthfield is present. Otherwise will fall back to username / password.- Parameters:
user- The user data- Returns:
- The AuthResult returned from the authentication request
-
tokenAuth
Use a quick auth token for authentication.- Parameters:
token- The quick auth token to use- Returns:
- The AuthResult
- Throws:
org.json.simple.parser.ParseException
-
createAuthToken
public String createAuthToken(org.json.simple.JSONObject user) throws org.json.simple.parser.ParseException Generate a quick auth token for a user- Parameters:
user- The user to generate the quick auth token for- Returns:
- The quick auth token
- Throws:
org.json.simple.parser.ParseException
-