Project

General

Profile

« Previous | Next » 

Revision 1004

Added by Jing Tao over 22 years ago

Some changes for pisco.

View differences:

src/edu/ucsb/nceas/metacat/AuthLdap.java
72 72
  private String userName;
73 73
  private String userPassword;
74 74
  ReferralException refExc;
75
  String uid=null;
75 76

  
76 77
  /** 
77 78
   * Construct an AuthLdap
......
100 101
    String ldapBase = this.ldapBase;
101 102
    boolean authenticated = false;
102 103
    String identifier = user;
103

  
104
    //get uid here.
105
    uid=user.substring(0, user.indexOf(","));
106
  
104 107
    try {
105 108
        // Check the usename as passed in
106 109
        authenticated = ldapAuthenticate(identifier, password);
110
        // if not found, try looking up a valid DN then auth again
111
        if (!authenticated) {
112
            identifier = getIdentifyingName(identifier,ldapUrl,ldapBase);
113
            System.out.println("identifier: "+identifier);
114
            authenticated = ldapAuthenticate(identifier+","+ldapBase, password);
115
        }
116
     
107 117
    } catch (NullPointerException e) {
108 118
      util.debugMessage("NullPointerException b' password is null");
109 119
      util.debugMessage("NullPointerException while authenticating in " + 
......
929 939
    referralContext = null;
930 940
    DirContext refDirContext=null;
931 941
    boolean moreReferrals=true;
942
    String referralInfo=null;
932 943
    //set a while loop is because we don't know if a referral excption contains
933 944
    //another referral exception
934 945
    while (moreReferrals)
935 946
    {
936 947
      try
937
      {
948
      {  
938 949
        //revise environment variable
939
        env.put(Context.PROVIDER_URL, refExc.getReferralInfo());
950
        referralInfo=(String)refExc.getReferralInfo();
951
        env.put(Context.PROVIDER_URL,refExc.getReferralInfo());
952
        System.out.println("referral info: "+referralInfo);
953
        if (referralInfo.indexOf("piscoweb")!=-1)
954
        {
955
          userName=uid+",o=PISCO,dc=piscoweb,dc=org";
956
        }
940 957
        env.put(Context.INITIAL_CONTEXT_FACTORY, 
941 958
                "com.sun.jndi.ldap.LdapCtxFactory");
959
        System.out.println("principal: "+userName);
942 960
        env.put(Context.SECURITY_PRINCIPAL, userName);
943 961
        env.put(Context.SECURITY_CREDENTIALS, userPassword);
944 962
        env.put(Context.REFERRAL, "throw");

Also available in: Unified diff