-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add nested authentication input data #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||||||
package io.camunda.connector; | ||||||||||
|
||||||||||
import io.camunda.connector.api.ConnectorInput; | ||||||||||
import io.camunda.connector.api.SecretStore; | ||||||||||
import io.camunda.connector.api.Validator; | ||||||||||
import java.util.Objects; | ||||||||||
|
||||||||||
public class Authentication implements ConnectorInput { | ||||||||||
|
||||||||||
private String user; | ||||||||||
private String token; | ||||||||||
|
||||||||||
@Override | ||||||||||
public void validateWith(final Validator validator) { | ||||||||||
validator.require(user, "user"); | ||||||||||
validator.require(token, "token"); | ||||||||||
if (token != null && !token.startsWith("xobx")) { | ||||||||||
validator.addErrorMessage("Token must start with \"xobx\""); | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public void replaceSecrets(final SecretStore secretStore) { | ||||||||||
token = secretStore.replaceSecret(token); | ||||||||||
} | ||||||||||
|
||||||||||
public String getUser() { | ||||||||||
return user; | ||||||||||
} | ||||||||||
|
||||||||||
public void setUser(String user) { | ||||||||||
this.user = user; | ||||||||||
} | ||||||||||
|
||||||||||
public String getToken() { | ||||||||||
return token; | ||||||||||
} | ||||||||||
|
||||||||||
public void setToken(String token) { | ||||||||||
this.token = token; | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public int hashCode() { | ||||||||||
return Objects.hash(token, user); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public boolean equals(Object obj) { | ||||||||||
if (this == obj) return true; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's strange that auto-formatter doesn't catch such things. According to the Google Style Guide braces are always used
Suggested change
|
||||||||||
if (obj == null) return false; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if (getClass() != obj.getClass()) return false; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
Authentication other = (Authentication) obj; | ||||||||||
return Objects.equals(token, other.token) && Objects.equals(user, other.user); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public String toString() { | ||||||||||
return "Authentication [user=" + user + ", token=" + token + "]"; | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,20 +8,18 @@ | |||||||||
public class MyConnectorRequest implements ConnectorInput { | ||||||||||
|
||||||||||
private String message; | ||||||||||
private String token; | ||||||||||
private Authentication authentication; | ||||||||||
|
||||||||||
@Override | ||||||||||
public void validateWith(final Validator validator) { | ||||||||||
validator.require(message, "message"); | ||||||||||
validator.require(token, "token"); | ||||||||||
if (token != null && !token.startsWith("xobx")) { | ||||||||||
validator.addErrorMessage("Token must start with \"xobx\""); | ||||||||||
} | ||||||||||
validator.require(authentication, "authentication"); | ||||||||||
validateIfNotNull(authentication, validator); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public void replaceSecrets(final SecretStore secretStore) { | ||||||||||
token = secretStore.replaceSecret(token); | ||||||||||
replaceSecretsIfNotNull(authentication, secretStore); | ||||||||||
} | ||||||||||
|
||||||||||
public String getMessage() { | ||||||||||
|
@@ -32,17 +30,17 @@ public void setMessage(String message) { | |||||||||
this.message = message; | ||||||||||
} | ||||||||||
|
||||||||||
public String getToken() { | ||||||||||
return token; | ||||||||||
public Authentication getAuthentication() { | ||||||||||
return authentication; | ||||||||||
} | ||||||||||
|
||||||||||
public void setToken(String token) { | ||||||||||
this.token = token; | ||||||||||
public void setAuthentication(Authentication authentication) { | ||||||||||
this.authentication = authentication; | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public int hashCode() { | ||||||||||
return Objects.hash(message, token); | ||||||||||
return Objects.hash(authentication, message); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
|
@@ -51,12 +49,12 @@ public boolean equals(Object obj) { | |||||||||
if (obj == null) return false; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
if (getClass() != obj.getClass()) return false; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
MyConnectorRequest other = (MyConnectorRequest) obj; | ||||||||||
return Objects.equals(message, other.message) && Objects.equals(token, other.token); | ||||||||||
return Objects.equals(authentication, other.authentication) | ||||||||||
&& Objects.equals(message, other.message); | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public String toString() { | ||||||||||
return "MyConnectorRequest [message=" + message + ", token=" + token + "]"; | ||||||||||
return "MyConnectorRequest [message=" + message + ", authentication=" + authentication + "]"; | ||||||||||
} | ||||||||||
|
||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: I am wondering, whether template should also contain one dynamic variable example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a separate template with optional authentication to showcase this.