-
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.
Add custom parameters to authorize and logout endpoint
- Loading branch information
1 parent
c62804f
commit 5c28d5f
Showing
17 changed files
with
525 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 paramName; | ||
private String paramValue; | ||
|
||
@DataBoundConstructor | ||
public OicQueryParameterConfiguration() {} | ||
|
||
public OicQueryParameterConfiguration(@NonNull String paramName, @NonNull String paramValue) { | ||
if (Util.fixEmptyAndTrim(paramName) == null) { | ||
throw new IllegalStateException("Parameter name '" + paramName + "' must not be null or empty."); | ||
} | ||
setQueryParamName(paramName.trim()); | ||
setQueryParamValue(paramValue.trim()); | ||
} | ||
|
||
@DataBoundSetter | ||
public void setQueryParamName(String paramName) { | ||
this.paramName = paramName; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setQueryParamValue(String paramValue) { | ||
this.paramValue = paramValue; | ||
} | ||
|
||
public String getQueryParamName() { | ||
return paramName; | ||
} | ||
|
||
public String getQueryParamValue() { | ||
return paramValue; | ||
} | ||
|
||
public String getQueryParamNameDecoded() { | ||
return paramName != null ? URLEncoder.encode(paramName, StandardCharsets.UTF_8).trim() : null; | ||
} | ||
|
||
public String getQueryParamValueDecoded() { | ||
return paramValue != null ? URLEncoder.encode(paramValue, StandardCharsets.UTF_8).trim() : null; | ||
} | ||
|
||
@Extension | ||
public static final class DescriptorImpl extends Descriptor<OicQueryParameterConfiguration> { | ||
@NonNull | ||
@Override | ||
public String getDisplayName() { | ||
return "Query Parameter Configuration"; | ||
} | ||
|
||
@POST | ||
public FormValidation doCheckQueryParamName(@QueryParameter String queryParamName) { | ||
Jenkins.get().checkPermission(Jenkins.ADMINISTER); | ||
if (Util.fixEmptyAndTrim(queryParamName) == null) { | ||
return FormValidation.error(Messages.OicQueryParameterConfiguration_QueryParameterNameRequired()); | ||
} | ||
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="${%QueryParameterName}" field="queryParamName"> | ||
<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 @@ | ||
QueryParameterName=Query Parameter Name | ||
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.