⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldappublisher.java

📁 一个免费的CA,基于EJB平台的,老师叫我们测试,现把之共享出来让大家参考
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    public void setHostname (String hostname){    	data.put(HOSTNAME, hostname);	    }        /**     *  Returns true if SSL connetion should be used.     */        public boolean getUseSSL (){    	return ((Boolean) data.get(USESSL)).booleanValue();    }    /**     *  Sets if SSL connetion should be used.     */            public void setUseSSL (boolean usessl){    	data.put(USESSL, Boolean.valueOf(usessl));	    }        /**     *  Returns the port of ldap server.     */        public String getPort (){    	return (String) data.get(PORT);    }    /**     *  Sets the port of ldap server.     */            public void setPort(String port){    	data.put(PORT, port);	    }	    /**     *  Returns the basedn of ldap server.     */        public String getBaseDN(){    	return (String) data.get(BASEDN);    }    /**     *  Sets the basedn of ldap server.     */            public void setBaseDN(String basedn){    	data.put(BASEDN, basedn);	    }    /**     *  Returns the logindn to the ldap server.     */        public String getLoginDN(){    	return (String) data.get(LOGINDN);    }    /**     *  Sets the logindn to the ldap server.     */            public void setLoginDN(String logindn){    	data.put(LOGINDN, logindn);	    }    /**     *  Returns the loginpwd to the ldap server.     */        public String getLoginPassword(){    	return (String) data.get(LOGINPASSWORD);    }    /**     *  Sets the loginpwd to the ldap server.     */            public void setLoginPassword(String loginpwd){    	data.put(LOGINPASSWORD, loginpwd);	    }    /**     *  Returns true if nonexisting users should be created     */        public boolean getCreateNonExisingUsers (){    	return ((Boolean) data.get(CREATENONEXISTING)).booleanValue();    }    /**     *  Sets if nonexisting users should be created.     */            public void setCreateNonExisingUsers (boolean createnonexistingusers){    	data.put(CREATENONEXISTING, Boolean.valueOf(createnonexistingusers));	    }	    /**     *  Returns true if existing users should be modified.     */        public boolean getModifyExistingUsers (){    	return ((Boolean) data.get(MODIFYEXISTING)).booleanValue();    }    /**     *  Sets if existing users should be modified.     */            public void setModifyExistingUsers (boolean modifyexistingusers){    	data.put(MODIFYEXISTING, Boolean.valueOf(modifyexistingusers));	    }    /**     *  Returns the user object class in the ldap instance     */        public String getUserObjectClass(){    	return (String) data.get(USEROBJECTCLASS);    }    /**     *  Sets the user object class in the ldap instance     */            public void setUserObjectClass(String userobjectclass){    	data.put(USEROBJECTCLASS, userobjectclass);	    }    /**     *  Returns the CA object class in the ldap instance     */        public String getCAObjectClass(){    	return (String) data.get(CAOBJECTCLASS);    }    /**     *  Sets the CA object class in the ldap instance     */            public void setCAObjectClass(String caobjectclass){    	data.put(CAOBJECTCLASS, caobjectclass);	    }    /**     *  Returns the user cert attribute in the ldap instance     */        public String getUserCertAttribute(){    	return (String) data.get(USERCERTATTRIBUTE);    }    /**     *  Sets the user cert attribute in the ldap instance     */            public void setUserCertAttribute(String usercertattribute){    	data.put(USERCERTATTRIBUTE, usercertattribute);	    }    /**     *  Returns the ca cert attribute in the ldap instance     */        public String getCACertAttribute(){    	return (String) data.get(CACERTATTRIBUTE);    }    /**     *  Sets the ca cert attribute in the ldap instance     */            public void setCACertAttribute(String cacertattribute){    	data.put(CACERTATTRIBUTE, cacertattribute);	    }    /**     *  Returns the CRL attribute in the ldap instance     */        public String getCRLAttribute(){    	return (String) data.get(CRLATTRIBUTE);    }    /**     *  Sets the CRL attribute in the ldap instance     */            public void setCRLAttribute(String crlattribute){    	data.put(CRLATTRIBUTE, crlattribute);	    }    /**     *  Returns the ARL attribute in the ldap instance     */        public String getARLAttribute(){    	return (String) data.get(ARLATTRIBUTE);    }    /**     *  Sets the ARL attribute in the ldap instance     */            public void setARLAttribute(String arlattribute){    	data.put(ARLATTRIBUTE, arlattribute);	    }        /**     * Method getting a collection of DNFieldExtractor constants indicating which     * fields of the x509 certificate DN that should be used in the LDAP DN.     *      * Valid values are  DNFieldExtractor.E, .UID, .CN, .SN, .GIVENNAME, .SURNAME, .T, .OU, .L      * Other values should be defined in baseDN instead.     * If there exists multiple fields of the same type, then will all fields be mappen to LDAP dn.     *      * @return Collection of (Integer) containing DNFieldExtractor constants.     */    public Collection getUseFieldInLdapDN(){    	return (Collection) data.get(USEFIELDINLDAPDN);    }    /**     * Method setting a collection of DNFieldExtractor constants indicating which     * fields of the x509 certificate DN that should be used in the LDAP DN.     *      * Valid values are  DNFieldExtractor.E, .UID, .CN, .SN, .GIVENNAME, .SURNAME, .T, .OU, .L      * Other values should be defined in baseDN instead.     * If there exists multiple fields of the same type, then will all fields be mappen to LDAP dn.     *      * @return Collection of (Integer) containing DNFieldExtractor constants.     */        public void setUseFieldInLdapDN(Collection usefieldinldapdn){    	data.put(USEFIELDINLDAPDN, usefieldinldapdn);    }        /**     *  Returns true if multiple certificates should be appended to existing user entries, instead of replacing.     */        public boolean getAddMultipleCertificates (){        return ((Boolean) data.get(ADDMULTIPLECERTIFICATES)).booleanValue();    }    /**     *  Sets if multiple certificates should be appended to existing user entries, instead of replacing.     */            public void setAddMultipleCertificates (boolean appendcerts){        data.put(ADDMULTIPLECERTIFICATES, Boolean.valueOf(appendcerts));     }    public void setRemoveRevokedCertificates( boolean removerevoked ){        data.put(REMOVEREVOKED, Boolean.valueOf(removerevoked));      }        public boolean getRemoveRevokedCertificates(){        boolean removerevoked = true; //-- default value        if ( data.get(REMOVEREVOKED) != null ) {            removerevoked = ((Boolean)data.get(REMOVEREVOKED)).booleanValue();        }        return removerevoked;    }        public void setRemoveUsersWhenCertRevoked( boolean removeuser ){        data.put(REMOVEUSERONCERTREVOKE, Boolean.valueOf(removeuser));      }        public boolean getRemoveUsersWhenCertRevoked(){        boolean removeuser = false; //-- default value        if ( data.get(REMOVEUSERONCERTREVOKE) != null ) {        	removeuser = ((Boolean)data.get(REMOVEUSERONCERTREVOKE)).booleanValue();        }        return removeuser;    }	    // Private methods    /**     * Creates an LDAPAttributeSet.     *     * @param cert the certificate to use or null if no cert involved.     * @param objectclass the objectclass the attribute set should be of.     * @param dn dn of the LDAP entry.     * @param extra if we should add extra attributes except the objectclass to the attributeset.     * @param person true if this is a person-entry, false if it is a CA.     * @param password, currently only used for the AD publisher     * @param extendedinformation, for future use...     *     * @return LDAPAtributeSet created...     */    protected LDAPAttributeSet getAttributeSet(Certificate cert, String objectclass, String dn, boolean extra, boolean person,    		                                   String password, ExtendedInformation extendedinformation) {    	log.debug(">getAttributeSet()");        LDAPAttributeSet attributeSet = new LDAPAttributeSet();        LDAPAttribute attr = new LDAPAttribute("objectclass");        // The full LDAP object tree is divided with ; in the objectclass        StringTokenizer token = new StringTokenizer(objectclass,";");        while (token.hasMoreTokens()) {            String value = token.nextToken();            log.debug("Adding objectclass value: "+value);            attr.addValue(value);        }        attributeSet.add(attr);        /* To Add an entry to the directory,         *   -- Create the attributes of the entry and add them to an attribute set         *   -- Specify the DN of the entry to be created         *   -- Create an LDAPEntry object with the DN and the attribute set         *   -- Call the LDAPConnection add method to add it to the directory         */        if (extra) {        	String cn = CertTools.getPartFromDN(dn, "CN");        	if (cn != null) {        		attributeSet.add(new LDAPAttribute("cn", cn));        	}        	String l = CertTools.getPartFromDN(dn, "L");        	if (l != null) {        		attributeSet.add(new LDAPAttribute("l", l));        	}        	String ou = CertTools.getPartFromDN(dn, "OU");        	if (ou != null) {        		attributeSet.add(new LDAPAttribute("ou", ou));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -