-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c62804f
commit 418804d
Showing
16 changed files
with
420 additions
and
22 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions
80
src/main/java/org/jenkinsci/plugins/oic/OicQueryParameterConfiguration.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,80 @@ | ||
package org.jenkinsci.plugins.oic; | ||
|
||
import hudson.Extension; | ||
import hudson.Util; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import hudson.util.FormValidation; | ||
import java.io.Serializable; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import jenkins.model.Jenkins; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import org.kohsuke.stapler.verb.POST; | ||
import org.springframework.lang.NonNull; | ||
|
||
public class OicQueryParameterConfiguration extends AbstractDescribableImpl<OicQueryParameterConfiguration> | ||
implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private String key; | ||
Check warning Code scanning / Jenkins Security Scan Jenkins: Plaintext password storage Warning
Field should be reviewed whether it stores a password and is serialized to disk: key
|
||
private String value; | ||
|
||
@DataBoundConstructor | ||
public OicQueryParameterConfiguration() {} | ||
|
||
public OicQueryParameterConfiguration(@NonNull String key, @NonNull String value) { | ||
if (Util.fixEmptyAndTrim(key) == null) { | ||
throw new IllegalStateException("Key '" + key + "' must not be null or empty."); | ||
} | ||
setQueryParamKey(key); | ||
setQueryParamValue(value.trim()); | ||
} | ||
|
||
@DataBoundSetter | ||
public void setQueryParamKey(String key) { | ||
this.key = key; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setQueryParamValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getQueryParamKey() { | ||
return key; | ||
} | ||
|
||
public String getQueryParamValue() { | ||
return value; | ||
} | ||
|
||
public String getQueryParamKeyDecoded() { | ||
return key != null ? URLEncoder.encode(key, StandardCharsets.UTF_8) : null; | ||
} | ||
|
||
public String getQueryParamValueDecoded() { | ||
return value != null ? URLEncoder.encode(value, StandardCharsets.UTF_8) : null; | ||
} | ||
|
||
@Extension | ||
public static final class DescriptorImpl extends Descriptor<OicQueryParameterConfiguration> { | ||
@NonNull | ||
@Override | ||
public String getDisplayName() { | ||
return "Query Parameter Configuration"; | ||
} | ||
|
||
@POST | ||
public FormValidation doCheckQueryParamKey(@QueryParameter String value) { | ||
Jenkins.get().checkPermission(Jenkins.ADMINISTER); | ||
if (Util.fixEmptyAndTrim(value) == null) { | ||
return FormValidation.error(Messages.OicQueryParameterConfiguration_QueryParameterKeyRequired()); | ||
} | ||
return FormValidation.ok(); | ||
} | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/resources/org/jenkinsci/plugins/oic/Messages.properties
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
9 changes: 9 additions & 0 deletions
9
src/main/resources/org/jenkinsci/plugins/oic/OicQueryParameterConfiguration/config.jelly
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,9 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form"> | ||
<f:entry title="${%QueryParameterKey}" field="queryParamKey"> | ||
<f:textbox /> | ||
</f:entry> | ||
<f:entry title="${%QueryParameterValue}" field="queryParamValue"> | ||
<f:textbox /> | ||
</f:entry> | ||
</j:jelly> |
2 changes: 2 additions & 0 deletions
2
...main/resources/org/jenkinsci/plugins/oic/OicQueryParameterConfiguration/config.properties
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,2 @@ | ||
QueryParameterKey=Query Parameter Key | ||
QueryParameterValue=Query Parameter Value |
3 changes: 3 additions & 0 deletions
3
src/main/resources/org/jenkinsci/plugins/oic/OicQueryParameterConfiguration/help.html
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,3 @@ | ||
<div> | ||
Additional custom query parameters added to a URL. | ||
</div> |
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
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
Oops, something went wrong.