-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/issue-435-add-the-possibility-to-use…
…-the-same-connector-with-different-connector-variables-values
- Loading branch information
Showing
29 changed files
with
1,598 additions
and
398 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...-engine/src/main/java/org/sentrysoftware/metricshub/engine/common/helpers/EscapeType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.sentrysoftware.metricshub.engine.common.helpers; | ||
|
||
/*- | ||
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ | ||
* MetricsHub Engine | ||
* ჻჻჻჻჻჻ | ||
* Copyright 2023 - 2024 Sentry Software | ||
* ჻჻჻჻჻჻ | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ | ||
*/ | ||
|
||
import java.util.function.UnaryOperator; | ||
import lombok.AllArgsConstructor; | ||
|
||
/** | ||
* Enum representing various escape types, each associated with | ||
* a specific method in the MacrosUpdater class that handles the escaping | ||
* of special characters for that type. Each constant references a method | ||
* that takes a String input and returns an escaped String output | ||
*/ | ||
@AllArgsConstructor | ||
public enum EscapeType { | ||
JSON(MacrosUpdater::escapeJsonSpecialCharacters), | ||
XML(MacrosUpdater::escapeXmlSpecialCharacters), | ||
URL(MacrosUpdater::escapeUrlSpecialCharacters), | ||
REGEX(MacrosUpdater::escapeRegexSpecialCharacters), | ||
WINDOWS(MacrosUpdater::escapeWindowsCmdSpecialCharacters), | ||
CMD(MacrosUpdater::escapeWindowsCmdSpecialCharacters), | ||
POWERSHELL(MacrosUpdater::escapePowershellSpecialCharacters), | ||
LINUX(MacrosUpdater::escapeBashSpecialCharacters), | ||
BASH(MacrosUpdater::escapeBashSpecialCharacters), | ||
SQL(MacrosUpdater::escapeSqlSpecialCharacters); | ||
|
||
private final UnaryOperator<String> escapeFunction; | ||
|
||
/** | ||
* Applies the associated escape method to the provided input string. | ||
* | ||
* @param input the string to be escaped | ||
* @return the escaped string | ||
*/ | ||
public String escape(String input) { | ||
return escapeFunction.apply(input); | ||
} | ||
|
||
/** | ||
* Retrieves the corresponding EscapeType from a string representation. | ||
* | ||
* @param escapeType the string representation of the escape type | ||
* @return the corresponding EscapeType | ||
* @throws IllegalStateException if the provided string does not match any escape type | ||
*/ | ||
public static EscapeType fromString(String escapeType) { | ||
for (EscapeType type : values()) { | ||
if (type.name().equalsIgnoreCase(escapeType)) { | ||
return type; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...b-engine/src/main/java/org/sentrysoftware/metricshub/engine/common/helpers/MacroType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.sentrysoftware.metricshub.engine.common.helpers; | ||
|
||
/*- | ||
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ | ||
* MetricsHub Engine | ||
* ჻჻჻჻჻჻ | ||
* Copyright 2023 - 2024 Sentry Software | ||
* ჻჻჻჻჻჻ | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ | ||
*/ | ||
|
||
/** | ||
* Enum representing various types of macros. | ||
* These constants are used to identify the different pieces of | ||
* information required for authentication processes. | ||
*/ | ||
public enum MacroType { | ||
USERNAME, | ||
PASSWORD, | ||
HOSTNAME, | ||
AUTHENTICATIONTOKEN, | ||
PASSWORD_BASE64, | ||
BASIC_AUTH_BASE64, | ||
SHA256_AUTH | ||
} |
Oops, something went wrong.