Package org.ejbca.core.model.ca.publisher

Examples of org.ejbca.core.model.ca.publisher.CustomPublisherContainer


                break;
            case PublisherConst.TYPE_ADPUBLISHER:
                publisher = new ActiveDirectoryPublisher();
                break;
            case PublisherConst.TYPE_CUSTOMPUBLISHERCONTAINER:
                publisher = new CustomPublisherContainer();
                break;
            case PublisherConst.TYPE_VAPUBLISHER:
                publisher = new ValidationAuthorityPublisher();
                break;
            }
View Full Code Here


     *
     */
    public void test01PublishQueueProcessSuccess() throws Exception {
        // Add a Dummy publisher with Id 12345
        try {
            CustomPublisherContainer publisher = new CustomPublisherContainer();
            publisher.setKeepPublishedInQueue(true);
            publisher.setClassPath("org.ejbca.core.model.ca.publisher.DummyCustomPublisher");
            publisher.setDescription("Used in Junit Test, Remove this one");
            publisherSession.addPublisher(admin, "TestPublishQueueProcessService", publisher);
        } catch (PublisherExistsException pee) {
        }
        int publisherId = publisherSession.getPublisherId(admin, "TestPublishQueueProcessService");

View Full Code Here

        final String PUBLISHER_NAME = "myPublisher";
        final Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        try {
            assertEquals(-4, ejbcaraws.getPublisherQueueLength(PUBLISHER_NAME));
            final CustomPublisherContainer publisher = new CustomPublisherContainer();
            publisher.setClassPath(DummyCustomPublisher.class.getName());
            publisher.setDescription("Used in Junit Test, Remove this one");
            publisherSession.addPublisher(admin, PUBLISHER_NAME, publisher);
            assertEquals(0, ejbcaraws.getPublisherQueueLength(PUBLISHER_NAME));
            final int publisherID = publisherSession.getPublisherId(admin, PUBLISHER_NAME);
            publisherQueueSession.addQueueData(publisherID, PublisherConst.PUBLISH_TYPE_CERT, "XX", null, PublisherConst.STATUS_PENDING);
            assertEquals(1, ejbcaraws.getPublisherQueueLength(PUBLISHER_NAME));
View Full Code Here

                                request.getParameter(BUTTON_TESTCONNECTION) != null){

                            if(publisherdata == null){
                                int tokentype = Integer.valueOf(request.getParameter(HIDDEN_PUBLISHERTYPE)).intValue();
                                if(tokentype == PublisherConst.TYPE_CUSTOMPUBLISHERCONTAINER) {
                                    publisherdata = new CustomPublisherContainer();
                                }
                                if(tokentype == PublisherConst.TYPE_LDAPPUBLISHER) {
                                    publisherdata = new LdapPublisher();
                                }
                                if (tokentype == PublisherConst.TYPE_LDAPSEARCHPUBLISHER) {
                                    publisherdata = new LdapSearchPublisher();
                                }
                                if(tokentype == PublisherConst.TYPE_ADPUBLISHER) {
                                    publisherdata = new ActiveDirectoryPublisher();
                                }
                                if(tokentype == PublisherConst.TYPE_VAPUBLISHER) {
                                    publisherdata = new ValidationAuthorityPublisher();
                                }
                            }
                            // Save changes.

                            // General settings
                            String value = request.getParameter(TEXTAREA_DESCRIPTION);
                            if(value != null){
                                value = value.trim();
                                publisherdata.setDescription(value);
                            }
                          value = request.getParameter(CHECKBOX_ONLYUSEQUEUE);
                          publisherdata.setOnlyUseQueue(value != null && value.equals(CHECKBOX_VALUE));
                          value = request.getParameter(CHECKBOX_KEEPPUBLISHEDINQUEUE);
                          publisherdata.setKeepPublishedInQueue(value != null && value.equals(CHECKBOX_VALUE));
                          value = request.getParameter(CHECKBOX_USEQUEUEFORCRLS);
                          publisherdata.setUseQueueForCRLs(value != null && value.equals(CHECKBOX_VALUE));
                          value = request.getParameter(CHECKBOX_USEQUEUEFORCERTIFICATES);
                          publisherdata.setUseQueueForCertificates(value != null && value.equals(CHECKBOX_VALUE));

                            if(publisherdata instanceof CustomPublisherContainer){
                                value = request.getParameter(TEXTFIELD_CUSTOMCLASSPATH);
                                if(value != null){
                                    value = value.trim();
                                    ((CustomPublisherContainer) publisherdata).setClassPath(value);
                                }
                                value = request.getParameter(TEXTAREA_CUSTOMPROPERTIES);
                                if(value != null){
                                    value = value.trim();
                                    ((CustomPublisherContainer) publisherdata).setPropertyData(value);
                                }
                            }

                            if(publisherdata instanceof LdapPublisher){
                                LdapPublisher ldappublisher = (LdapPublisher) publisherdata;

                                value = request.getParameter(TEXTFIELD_LDAPHOSTNAME);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setHostnames(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPPORT);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setPort(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPBASEDN);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setBaseDN(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPLOGINDN);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setLoginDN(value);
                                }
                                value = request.getParameter(PASSWORD_LDAPLOGINPASSWORD);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setLoginPassword(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPTIMEOUT);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setConnectionTimeOut(Integer.parseInt(value));
                                }
                                value = request.getParameter(TEXTFIELD_LDAPREADTIMEOUT);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setReadTimeOut(Integer.parseInt(value));
                                }
                                value = request.getParameter(TEXTFIELD_LDAPSTORETIMEOUT);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setStoreTimeOut(Integer.parseInt(value));
                                }
                                value = request.getParameter(TEXTFIELD_LDAPUSEROBJECTCLASS);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setUserObjectClass(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPCAOBJECTCLASS);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setCAObjectClass(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPUSERCERTATTRIBUTE);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setUserCertAttribute(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPCACERTATTRIBUTE);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setCACertAttribute(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPCRLATTRIBUTE);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setCRLAttribute(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPDELTACRLATTRIBUTE);
                                if(value != null){
                                  value = value.trim();
                                  ldappublisher.setDeltaCRLAttribute(value);
                                }
                                value = request.getParameter(TEXTFIELD_LDAPARLATTRIBUTE);
                                if(value != null){
                                    value = value.trim();
                                    ldappublisher.setARLAttribute(value);
                                }
                                value = request.getParameter(CHECKBOX_LDAPUSESSL);
                                if(value != null) {
                                    ldappublisher.setUseSSL(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setUseSSL(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAPCREATENONEXISTING);
                                if(value != null) {
                                    ldappublisher.setCreateNonExistingUsers(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setCreateNonExistingUsers(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAPMODIFYEXISTING);
                                if(value != null) {
                                    ldappublisher.setModifyExistingUsers(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setModifyExistingUsers(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAPMODIFYEXISTINGATTRIBUTES);
                                if(value != null) {
                                    ldappublisher.setModifyExistingAttributes(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setModifyExistingAttributes(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAPADDNONEXISTING);
                                if(value != null) {
                                    ldappublisher.setAddNonExistingAttributes(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setAddNonExistingAttributes(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAP_CREATEINTERMEDIATENODES);
                                if(value != null) {
                                    ldappublisher.setCreateIntermediateNodes(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setCreateIntermediateNodes(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAPADDMULTIPLECERTIFICATES);
                                if(value != null) {
                                    ldappublisher.setAddMultipleCertificates(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setAddMultipleCertificates(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAP_REVOKE_REMOVECERTIFICATE);
                                if(value != null) {
                                    ldappublisher.setRemoveRevokedCertificates(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setRemoveRevokedCertificates(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAP_REVOKE_REMOVEUSERONCERTREVOKE);
                                if(value != null) {
                                    ldappublisher.setRemoveUsersWhenCertRevoked(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    ldappublisher.setRemoveUsersWhenCertRevoked(false);
                                }
                                value = request.getParameter(CHECKBOX_LDAP_SET_USERPASSWORD);
                                if(value != null) {
                                    ldappublisher.setUserPassword(value.equals(CHECKBOX_VALUE));
                                } else {
                                    ldappublisher.setUserPassword(false);
                                }
                               
                                String[] values = request.getParameterValues(SELECT_LDAPUSEFIELDINLDAPDN);
                                if(values != null){
                                    ArrayList<Integer> usefields = new ArrayList<Integer>();
                                    for(int i=0;i< values.length;i++){
                                        usefields.add(Integer.valueOf(values[i]));
                                    }

                                    ldappublisher.setUseFieldInLdapDN(usefields);
                                }
                            }


                            if (publisherdata instanceof LdapSearchPublisher) {
                              LdapSearchPublisher ldapsearchpublisher = (LdapSearchPublisher) publisherdata;

                              value = request.getParameter(TEXTFIELD_LDAPSEARCHBASEDN);
                              if (value != null) {
                                value = value.trim();
                                ldapsearchpublisher.setSearchBaseDN(value);
                              }
                              value = request.getParameter(TEXTFIELD_LDAPSEARCHFILTER);
                              if (value != null) {
                                value = value.trim();
                                ldapsearchpublisher.setSearchFilter(value);
                              }
                            }


                            if(publisherdata instanceof ActiveDirectoryPublisher){
                                ActiveDirectoryPublisher adpublisher = (ActiveDirectoryPublisher) publisherdata;

                                value = request.getParameter(SELECT_ADSAMACCOUNTNAME);
                                if(value != null){
                                    value = value.trim();
                                    adpublisher.setSAMAccountName(Integer.parseInt(value));
                                }

                                value = request.getParameter(TEXTFIELD_ADUSERDESCRIPTION);
                                if(value != null){
                                    value = value.trim();
                                    adpublisher.setUserDescription(value);
                                }

                                value = request.getParameter(CHECKBOX_ADUSEPASSWORD);
                                if(value != null) {
                                    adpublisher.setUseUserPassword(value.equals(CHECKBOX_VALUE));
                                }
                                else {
                                    adpublisher.setUseUserPassword(false);
                                }
                                value = request.getParameter(SELECT_ADUSERACCOUNTCONTROL);
                                if(value != null) {
                                    value = value.trim();
                                    adpublisher.setUserAccountControl(Integer.parseInt(value));
                                }
                            }
                           
                            // Get parameters for ValidationAuthorityPublisher
                            if(publisherdata instanceof ValidationAuthorityPublisher){
                              final ValidationAuthorityPublisher vaPub = (ValidationAuthorityPublisher) publisherdata;
                             
                              value = request.getParameter(TEXTFIELD_VA_DATASOURCE);
                              if(value != null){
                                value = value.trim();
                                vaPub.setDataSource(value);
                              }
                              final String vCert = request.getParameter(CHECKBOX_VA_STORECERT);
                              final boolean isCert = vCert!=null && vCert.equals(CHECKBOX_VALUE);
                              vaPub.setStoreCert( isCert );
                              final String vCRL = request.getParameter(CHECKBOX_VA_STORECRL);
                              vaPub.setStoreCRL( isCert && vCRL!=null && vCRL.equals(CHECKBOX_VALUE) );
                            }


                            if(request.getParameter(BUTTON_SAVE) != null){
                                handler.changePublisher(publisher,publisherdata);
                                includefile=PAGE_PUBLISHERS;
                            }
                            if(request.getParameter(BUTTON_TESTCONNECTION)!= null){
                                connectionmessage = true;
                                handler.changePublisher(publisher,publisherdata);
                                try{
                                    handler.testConnection(publisher);
                                    connectionsuccessful = true;
                                }catch(PublisherConnectionException pce){
                                    connectionerrormessage = pce.getMessage();
                                }
                                includefile=PAGE_PUBLISHER;
                            }

                        }
                        if(request.getParameter(BUTTON_CANCEL) != null){
                            // Don't save changes.
                            includefile=PAGE_PUBLISHERS;
                        }

                    }
                }
            }

            if( action.equals(ACTION_CHANGE_PUBLISHERTYPE)){
                this.publishername = request.getParameter(HIDDEN_PUBLISHERNAME);
                String value = request.getParameter(SELECT_PUBLISHERTYPE);
                if(value!=null){
                    int profiletype = Integer.parseInt(value);
                    switch(profiletype){
                    case PublisherConst.TYPE_CUSTOMPUBLISHERCONTAINER :
                        publisherdata = new CustomPublisherContainer();
                        break;
                    case PublisherConst.TYPE_LDAPPUBLISHER :
                        publisherdata =  new LdapPublisher();
                        break;
                    case PublisherConst.TYPE_LDAPSEARCHPUBLISHER:
View Full Code Here

      log.trace(">test02ExternalOCSPPublisherFail");
        boolean ret = false;

        ret = false;
    try {
            CustomPublisherContainer publisher = new CustomPublisherContainer();
            publisher.setClassPath(ValidationAuthorityPublisher.class.getName());
        // We use a datasource that we know don't exist, so we know publishing will fail
            String jndiNamePrefix = configurationSession.getProperty(InternalConfiguration.CONFIG_DATASOURCENAMEPREFIX, "");
            log.debug("jndiNamePrefix=" + jndiNamePrefix);
            publisher.setPropertyData("dataSource " + jndiNamePrefix + "NoExist234DS");
            publisher.setDescription("Used in Junit Test, Remove this one");
            publisherSession.addPublisher(admin, "TESTEXTOCSPQUEUE", publisher);
            ret = true;
        } catch (PublisherExistsException pee) {
          // Do nothing
        }       
View Full Code Here

        publisherSession.removePublisher(admin, "TESTEXTOCSPQUEUE");           
      } catch (Exception pee) {}

        ret = false;
    try {
            CustomPublisherContainer publisher = new CustomPublisherContainer();
            publisher.setClassPath(ValidationAuthorityPublisher.class.getName());
        // We use a datasource that we know don't exist, so we know publishing will be successful
            String jndiName = configurationSession.getProperty(InternalConfiguration.CONFIG_DATASOURCENAMEPREFIX, "")
              + configurationSession.getProperty(DatabaseConfiguration.CONFIG_DATASOURCENAME, "EjbcaDS");
            log.debug("jndiName=" + jndiName);
            publisher.setPropertyData("dataSource " + jndiName);
            publisher.setDescription("Used in Junit Test, Remove this one");
            publisherSession.addPublisher(admin, "TESTEXTOCSPQUEUE", publisher);
            ret = true;
        } catch (PublisherExistsException pee) {
          // Do nothing
        }       
View Full Code Here

        publisherSession.removePublisher(admin, "TESTEXTOCSPQUEUE");           
      } catch (Exception pee) {}
       
        ret = false;
    try {
      CustomPublisherContainer publisher = new CustomPublisherContainer();
            publisher.setClassPath(ValidationAuthorityPublisher.class.getName());
        // We use the default EjbcaDS datasource here, because it probably exists during our junit test run
            String jndiName = configurationSession.getProperty(InternalConfiguration.CONFIG_DATASOURCENAMEPREFIX, "")
            + configurationSession.getProperty(DatabaseConfiguration.CONFIG_DATASOURCENAME, "EjbcaDS");
            log.debug("jndiName=" + jndiName);
            publisher.setPropertyData("dataSource " + jndiName);
            publisher.setDescription("Used in Junit Test, Remove this one");
           
            // Set to only use the publisher queue instead of publish directly
            publisher.setOnlyUseQueue(true);
           
            publisherSession.addPublisher(admin, "TESTEXTOCSPQUEUE", publisher);
            ret = true;
        } catch (PublisherExistsException pee) {
          // Do nothing
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.publisher.CustomPublisherContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.