Package org.ejbca.core.model.ra.userdatasource

Examples of org.ejbca.core.model.ra.userdatasource.CustomUserDataSourceContainer


                if( request.getParameter(BUTTON_ADD_USERDATASOURCE) != null){
                    userdatasource = request.getParameter(TEXTFIELD_USERDATASOURCENAME);
                    if(userdatasource != null){
                        if(!userdatasource.trim().equals("")){
                            try{
                              userdatasourcesession.addUserDataSource(admin,userdatasource.trim(), new CustomUserDataSourceContainer());
                              ejbcawebbean.getInformationMemory().userDataSourceEdited();
                            }catch( UserDataSourceExistsException e){
                                userdatasourceexists=true;
                            }
                        }
                    }
                    includefile=PAGE_USERDATASOURCES;
                }
                if( request.getParameter(BUTTON_CLONE_USERDATASOURCE) != null){
                    String newuserdatasourcename = request.getParameter(TEXTFIELD_USERDATASOURCENAME);
                    String olduserdatasourcename = request.getParameter(SELECT_USERDATASOURCE);
                    if(olduserdatasourcename != null && newuserdatasourcename != null){
                      if(!newuserdatasourcename.trim().equals("") && !olduserdatasourcename.trim().equals("")){
                        try{
                          userdatasourcesession.cloneUserDataSource(admin,olduserdatasourcename.trim(),newuserdatasourcename.trim());
                          ejbcawebbean.getInformationMemory().userDataSourceEdited();
                        }catch( UserDataSourceExistsException e){
                          userdatasourceexists=true;
                        }
                      }
                    }
                    includefile=PAGE_USERDATASOURCES;
                }
            }
            if( action.equals(ACTION_EDIT_USERDATASOURCE)){
                // Display edit access rules page.
                userdatasource = request.getParameter(HIDDEN_USERDATASOURCENAME);
                this.userdatasourcename = userdatasource;
                if(userdatasource != null){
                    if(!userdatasource.trim().equals("")){
                        if(request.getParameter(BUTTON_SAVE) != null ||
                                request.getParameter(BUTTON_TESTCONNECTION) != null){

                            if(userdatasourcedata == null){
                                int tokentype = Integer.valueOf(request.getParameter(HIDDEN_USERDATASOURCETYPE)).intValue();
                                if(tokentype == CustomUserDataSourceContainer.TYPE_CUSTOMUSERDATASOURCECONTAINER) {
                                    userdatasourcedata = new CustomUserDataSourceContainer();
                                }
                            }
                            // Save changes.

                            // General settings
                            String value = request.getParameter(TEXTAREA_DESCRIPTION);
                            if(value != null){
                                value = value.trim();
                                userdatasourcedata.setDescription(value);
                            }
                           
                            String[] values = request.getParameterValues(SELECT_MODIFYABLEFIELDS);
                            if(values != null){
                                Set modifyablefields = new HashSet();
                                for(int i=0;i< values.length;i++){
                                  modifyablefields.add(Integer.valueOf(values[i]));
                                }

                                userdatasourcedata.setModifiableFields(modifyablefields);
                            }else{
                              userdatasourcedata.setModifiableFields(new HashSet());
                            }

                            values = request.getParameterValues(SELECT_APPLICABLECAS);
                            if(values != null){
                                ArrayList useCAs = new ArrayList();
                                for(int i=0;i< values.length;i++){
                                  Integer caid = Integer.valueOf(values[i]);
                                  if(caid.intValue() == BaseUserDataSource.ANYCA){
                                    useCAs = new ArrayList();
                                    useCAs.add(caid);
                                    break;
                                  }
                                  useCAs.add(Integer.valueOf(values[i]));
                                }

                                userdatasourcedata.setApplicableCAs(useCAs);
                            }else{
                              userdatasourcedata.setApplicableCAs(new ArrayList());
                            }
                           
                          


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

                            if(request.getParameter(BUTTON_SAVE) != null){
                                userdatasourcesession.changeUserDataSource(admin,userdatasource,userdatasourcedata);
                                ejbcawebbean.getInformationMemory().userDataSourceEdited();
                                includefile=PAGE_USERDATASOURCES;
                            }
                            if(request.getParameter(BUTTON_TESTCONNECTION)!= null){
                                connectionmessage = true;
                                userdatasourcesession.changeUserDataSource(admin, userdatasource,userdatasourcedata);
                                try{
                                  int userdatasourceid = userdatasourcesession.getUserDataSourceId(admin,userdatasource);
                                  userdatasourcesession.testConnection(admin,userdatasourceid);
                                    connectionsuccessful = true;
                                }catch(UserDataSourceConnectionException pce){
                                    connectionerrormessage = pce.getMessage();
                                }
                                includefile=PAGE_USERDATASOURCE;
                            }

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

                    }
                }
            }

            if( action.equals(ACTION_CHANGE_USERDATASOURCETYPE)){
                this.userdatasourcename = request.getParameter(HIDDEN_USERDATASOURCENAME);
                String value = request.getParameter(SELECT_USERDATASOURCETYPE);
                if(value!=null){
                    int profiletype = Integer.parseInt(value);
                    switch(profiletype){
                    case CustomUserDataSourceContainer.TYPE_CUSTOMUSERDATASOURCECONTAINER :
                        userdatasourcedata = new CustomUserDataSourceContainer();
                        break;                   
                    }
                }

                includefile=PAGE_USERDATASOURCE;
View Full Code Here


     */
    public void test01AddCustomUserDataSource() throws Exception {
        log.trace(">test01AddCustomUserDataSource()");
        boolean ret = false;
        try {
            CustomUserDataSourceContainer userdatasource = new CustomUserDataSourceContainer();
            userdatasource.setClassPath("org.ejbca.core.model.ra.userdatasource.DummyCustomUserDataSource");
            userdatasource.setDescription("Used in Junit Test, Remove this one");
            userDataSourceSession.addUserDataSource(admin, "TESTDUMMYCUSTOM", userdatasource);
            ret = true;
        } catch (UserDataSourceExistsException pee) {
        }

View Full Code Here

          decoder.close();
          // Handle Base64 encoded string values
          HashMap data = new Base64GetHashMap(h);
          switch (((Integer) (data.get(BaseUserDataSource.TYPE))).intValue()) {
          case CustomUserDataSourceContainer.TYPE_CUSTOMUSERDATASOURCECONTAINER:
            userdatasource = new CustomUserDataSourceContainer();
            break;
          }
          userdatasource.loadData(data);
      }
      return userdatasource;
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.userdatasource.CustomUserDataSourceContainer

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.