Skip to content

Commit

Permalink
feat(multiple-auth): add support for multiple auth (#51)
Browse files Browse the repository at this point in the history
This commit updates the authentication interface and incorporates the instance methods used for the validation of auth schemes. other than validation results, it also stores the error message for each auth scheme instance.
  • Loading branch information
sufyankhanrao committed Dec 4, 2023
1 parent dd04271 commit f16afbe
Showing 1 changed file with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,59 @@
/**
* To setup methods for authentication
*/
public interface Authentication {
public abstract class Authentication {

/**
* Apply the authentication on the httpRequest
* @param httpRequest the request on which authentication is being applied
* @return the authenticated request
* Stores the validity of the auth scheme.
*/
Request apply(Request httpRequest);
private boolean isValid;

/**
* Validates the auth params for the httpRequest
* Stores the error message for the auth scheme.
*/
void validate();
private String errorMessage;

/**
* Applies the authentication on the httpRequest.
* @param httpRequest the request on which authentication is being applied.
* @return the authenticated request.
*/
public abstract Request apply(Request httpRequest);

/**
* Validates the credentials for authentication.
*/
public abstract void validate();

/**
* Checks if the auth credentials are valid.
* @return true if the auth credentials are valid, false otherwise.
*/
public boolean isValid() {
return isValid;
}

/**
* Sets the validatity of the auth credentials.
* @param isValid the flag to set for validity.
*/
public void setValidity(boolean isValid) {
this.isValid = isValid;
}

/**
* Returns the error message if the auth credentials are not valid.
* @return the string message whenever the auth credentials are not valid.
*/
public String getErrorMessage() {
return errorMessage;
}

/**
* Sets the error message for invalid auth credentials.
* @param errorMessage the error message to set.
*/
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

0 comments on commit f16afbe

Please sign in to comment.