Skip to content

Commit

Permalink
Merge pull request #387 from rtyler/native-types-fixup
Browse files Browse the repository at this point in the history
Avoid referring to class objects directly in the Groovy helper
  • Loading branch information
Joshua Hoblitt committed Oct 9, 2015
2 parents e13a7b4 + 4b63762 commit 4b0cd6e
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions files/puppet_helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,14 @@ class Actions {
def j = Jenkins.getInstance()
def realm = j.getSecurityRealm()

def className = realm.getClass().getName()
def config
switch (realm) {
switch (className) {
// "Jenkins’ own user database"
case hudson.security.HudsonPrivateSecurityRealm:
case 'hudson.security.HudsonPrivateSecurityRealm':
config = [
setSecurityRealm: [
(realm.getClass().getName()): [
(className): [
realm.allowsSignup(),
realm.isEnableCaptcha(),
null,
Expand All @@ -649,10 +650,10 @@ class Actions {
break

// "Unix user/group database"
case hudson.security.PAMSecurityRealm:
case 'hudson.security.PAMSecurityRealm':
config = [
setSecurityRealm: [
(realm.getClass().getName()): [
(className): [
// there is no accessor for the serviceName field
realm.@serviceName
],
Expand All @@ -665,10 +666,10 @@ class Actions {
// public LDAPSecurityRealm(String server, String rootDN, String userSearchBase, String userSearch, String groupSearchBase, String groupSearchFilter, LDAPGroupMembershipStrategy groupMembershipStrategy, String managerDN, Secret managerPasswordSecret, boolean inhibitInferRootDN, boolean disableMailAddressResolver, CacheConfiguration cache, EnvironmentProperty[] environmentProperties, String displayNameAttributeName, String mailAddressAttributeName, IdStrategy userIdStrategy, IdStrategy groupIdStrategy)

// github-oauth
case org.jenkinsci.plugins.GithubSecurityRealm:
case 'org.jenkinsci.plugins.GithubSecurityRealm':
config = [
setSecurityRealm: [
(realm.getClass().getName()): [
(className): [
realm.getGithubWebUri(),
realm.getGithubApiUri(),
realm.getClientID(),
Expand All @@ -681,7 +682,7 @@ class Actions {

// constructor with no arguments
// "Delegate to servlet container"
case hudson.security.LegacySecurityRealm:
case 'hudson.security.LegacySecurityRealm':
default:
config = [
setSecurityRealm: [
Expand All @@ -702,13 +703,14 @@ class Actions {
def j = Jenkins.getInstance()
def strategy = j.getAuthorizationStrategy()

def className = strategy.getClass().getName()
def config
switch (strategy) {
// github-oauth
case org.jenkinsci.plugins.GithubAuthorizationStrategy:
case 'org.jenkinsci.plugins.GithubAuthorizationStrategy':
config = [
setAuthorizationStrategy: [
(strategy.getClass().getName()): [
(className): [
strategy.adminUserNames,
strategy.authenticatedUserReadPermission,
strategy.useRepositoryPermissions,
Expand All @@ -724,23 +726,23 @@ class Actions {

// constructor with no arguments
// "Anyone can do anything"
case hudson.security.AuthorizationStrategy$Unsecured:
case 'hudson.security.AuthorizationStrategy$Unsecured':
// "Legacy mode"
case hudson.security.LegacyAuthorizationStrategy:
case 'hudson.security.LegacyAuthorizationStrategy':
// "Logged-in users can do anything"
case hudson.security.FullControlOnceLoggedInAuthorizationStrategy:
case 'hudson.security.FullControlOnceLoggedInAuthorizationStrategy':
// "Matrix-based security"
case hudson.security.GlobalMatrixAuthorizationStrategy:
case 'hudson.security.GlobalMatrixAuthorizationStrategy':
// technically, you can select this class but it will "brick" the
// authorization strategy without additional method calls to configure
// the matrix which are not presently supported
// "Project-based Matrix Authorization Strategy"
case hudson.security.ProjectMatrixAuthorizationStrategy:
case 'hudson.security.ProjectMatrixAuthorizationStrategy':
// same issue as hudson.security.GlobalMatrixAuthorizationStrategy
default:
config = [
setAuthorizationStrategy: [
(strategy.getClass().getName()): [],
(className): [],
],
]
}
Expand Down

0 comments on commit 4b0cd6e

Please sign in to comment.