diff --git a/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java b/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..226246e07cfd5016dd874d32a673a8dd1a112065 --- /dev/null +++ b/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java @@ -0,0 +1,62 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.security; + +import hudson.Extension; +import hudson.markup.MarkupFormatter; +import jenkins.model.GlobalConfiguration; +import jenkins.model.Jenkins; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; + +/** + * Security configuration. + * + * @author Kohsuke Kawaguchi + */ +@Extension(ordinal=200) +public class GlobalSecurityConfiguration extends GlobalConfiguration { + @Override + public boolean configure(StaplerRequest req, JSONObject json) throws FormException { + // for compatibility reasons, the actual value is stored in Jenkins + Jenkins j = Jenkins.getInstance(); + + if (json.has("useSecurity")) { + JSONObject security = json.getJSONObject("useSecurity"); + j.setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); + j.setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization")); + + if (security.has("markupFormatter")) { + j.setMarkupFormatter(req.bindJSON(MarkupFormatter.class, security.getJSONObject("markupFormatter"))); + } else { + j.setMarkupFormatter(null); + } + } else { + j.disableSecurity(); + } + + return true; + } +} + diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 58af727c8c30a9c1df41c5dad19d934035668213..db13d48f17ba31ab2b374e1172a64eb904ed9932 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -58,7 +58,6 @@ import hudson.model.LoadBalancer; import hudson.model.ManagementLink; import hudson.model.ModifiableItemGroup; import hudson.model.NoFingerprintMatch; -import hudson.model.Node.Mode; import hudson.model.OverallLoadStatistics; import hudson.model.Project; import hudson.model.RestartListener; @@ -101,7 +100,6 @@ import hudson.Plugin; import hudson.PluginManager; import hudson.PluginWrapper; import hudson.ProxyConfiguration; -import hudson.StructuredForm; import hudson.TcpSlaveAgentListener; import hudson.UDPBroadcastThread; import hudson.Util; @@ -1849,6 +1847,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup0, onclick:"\$('sat.port').disabled=false") + label("for":"sat.fixed", _$("Fixed")) + text(" : ") + input(type:"text", "class":"number", name:"slaveAgentPort", id:"sat.port", + value: port>0 ? port : null, disabled: port>0 ? null : "true" ) + + raw(" ") //////////////////////////// + + f.radio(name:"slaveAgentPortType", value:"random", id:"sat.random", + checked:port==0, onclick:"\$('sat.port').disabled=true") + label("for":"sat.random", _$("Random")) + + raw(" ") //////////////////////////// + + f.radio(name:"slaveAgentPortType", value:"disable", id:"sat.disabled", + checked:port==-1, onclick:"\$('sat.port').disabled=true") + label("for":"sat.random", _$("Random")) + +// checked="${it.useSecurity}" help="/help/system-config/enableSecurity.html"> +// help="/help/system-config/master-slave/slave-agent-port.html"> +/* + + + + + + + + + + + + +*/ + } + + f.dropdownDescriptorSelector(title:_("Markup Formatter"),field:"markupFormatter") + + f.entry(title:_("Access Control")) { + table(style:"width:100%") { + f.descriptorRadioList(title:_("Security Realm"),varName:"realm", instance:app.securityRealm, descriptors:SecurityRealm.all()) + f.descriptorRadioList(title:_("Authorization"), varName:"authorization", instance:app.authorizationStrategy, descriptors:AuthorizationStrategy.all()) + } + } +} + +/* + + + + + + +
+
+ +*/ \ No newline at end of file diff --git a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly index 1bab785c5653dad17a0e00ee7170eb6f4bd7f813..e6501c92385abd73e4ad49fe8d576ba5118d9458 100644 --- a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly +++ b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly @@ -106,44 +106,6 @@ THE SOFTWARE. - - - - : - - - - - - - - - - - - - - - - - - - -
-
-
-