LDAPSecurityRealm.java 1.4 KB
Newer Older
1 2 3
package hudson.security;

import org.acegisecurity.AuthenticationManager;
K
kohsuke 已提交
4 5 6
import org.acegisecurity.MockAuthenticationManager;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.DataBoundConstructor;
7
import hudson.model.Descriptor;
K
kohsuke 已提交
8
import net.sf.json.JSONObject;
9 10 11 12 13 14 15

/**
 * {@link SecurityRealm} implementation that uses LDAP for authentication.
 * 
 * @author Kohsuke Kawaguchi
 */
public class LDAPSecurityRealm extends SecurityRealm {
K
kohsuke 已提交
16 17 18 19 20 21 22
    public final String providerUrl;

    @DataBoundConstructor
    public LDAPSecurityRealm(String providerUrl) {
        this.providerUrl = providerUrl;
    }

23
    public AuthenticationManager createAuthenticationManager() {
K
kohsuke 已提交
24 25
        // TODO
        return new MockAuthenticationManager(true);
26 27 28 29 30 31 32 33 34 35 36 37 38
    }

    public DescriptorImpl getDescriptor() {
        return DESCRIPTOR;
    }

    public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

    private static final class DescriptorImpl extends Descriptor<SecurityRealm> {
        private DescriptorImpl() {
            super(LDAPSecurityRealm.class);
        }

K
kohsuke 已提交
39 40 41 42
        public LDAPSecurityRealm newInstance(StaplerRequest req, JSONObject formData) throws FormException {
            return req.bindJSON(LDAPSecurityRealm.class,formData);
        }

43 44 45 46
        public String getDisplayName() {
            return "LDAP";
        }
    }
47 48

    static {
K
kohsuke 已提交
49
//        LIST.add(DESCRIPTOR);
50
    }
51
}