package hudson.security;

import hudson.model.Descriptor;
import org.acegisecurity.acls.sid.GrantedAuthoritySid;

/**
 * {@link AuthorizationStrategy} implementation that emulates the legacy behavior.
 * @author Kohsuke Kawaguchi
 */
public final class LegacyAuthorizationStrategy extends AuthorizationStrategy {
    private static final ACL LEGACY_ACL = new SparseACL(null) {{
        add(EVERYONE,Permission.READ,true);
        add(new GrantedAuthoritySid("admin"),Permission.FULL_CONTROL,true);
    }};

    public ACL getRootACL() {
        return LEGACY_ACL;
    }

    public Descriptor<AuthorizationStrategy> getDescriptor() {
        return DESCRIPTOR;
    }

    public static final Descriptor<AuthorizationStrategy> DESCRIPTOR = new DescriptorImpl();

    public static final class DescriptorImpl extends Descriptor<AuthorizationStrategy> {
        private DescriptorImpl() {
            super(LegacyAuthorizationStrategy.class);
        }

        public String getDisplayName() {
            return Messages.LegacyAuthorizationStrategy_DisplayName();
        }

        public String getHelpFile() {
            return "/help/security/legacy-auth-strategy.html";
        }
    }

    static {
        LIST.add(DESCRIPTOR);
    }

}

@@ -105,16 +105,90 @@
 ritySid;
+%0Aimport org.kohsuke.stapler.StaplerRequest;%0Aimport net.sf.json.JSONObject;
 %0A%0A/**%0A *
@@ -1251,16 +1251,200 @@
        %7D
+%0A%0A        public LegacyAuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException %7B%0A            return new LegacyAuthorizationStrategy();%0A        %7D
 %0A    %7D%0A%0A

missing a constructor.