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

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


     */
    public void test04EditUserDataSource() throws Exception {
        log.trace(">test04EditUserDataSource()");
        boolean ret = false;

        BaseUserDataSource userdatasource = userDataSourceSession.getUserDataSource(admin, "TESTCLONEDUMMYCUSTOM");
        userdatasource.setDescription(userdatasource.getDescription().toUpperCase());
        userDataSourceSession.changeUserDataSource(admin, "TESTCLONEDUMMYCUSTOM", userdatasource);
        ret = true;

        assertTrue("Editing Custom UserDataSource failed", ret);
        log.trace("<test04EditUserDataSource()");
View Full Code Here


      ArrayList<UserDataSourceVO> result = new ArrayList<UserDataSourceVO>();
      while (iter.hasNext()) {
        Integer id = iter.next();
        UserDataSourceData pdl = UserDataSourceData.findById(entityManager, id);
        if (pdl != null) {
          BaseUserDataSource userdatasource = getUserDataSource(pdl);
          if(isAuthorizedToUserDataSource(admin,id.intValue(),userdatasource,false)){
            try {
              result.addAll(getUserDataSource(pdl).fetchUserDataSourceVOs(admin,searchstring));
              String msg = intres.getLocalizedMessage("userdatasource.fetcheduserdatasource", pdl.getName());             
              logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new java.util.Date(), null,
View Full Code Here

      Iterator<Integer> iter = userdatasourceids.iterator();
      while (iter.hasNext()) {
        Integer id = iter.next();
        UserDataSourceData pdl = UserDataSourceData.findById(entityManager, id);
        if (pdl != null) {
          BaseUserDataSource userdatasource = getUserDataSource(pdl);
          if(isAuthorizedToUserDataSource(admin,id.intValue(),userdatasource,true)){
            try {
              retval = retval || getUserDataSource(pdl).removeUserData(admin, searchstring, removeMultipleMatch);
              String msg = intres.getLocalizedMessage("userdatasource.removeduserdata", pdl.getName());             
              logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new java.util.Date(), null,
View Full Code Here

      if (log.isTraceEnabled()) {
            log.trace(">testConnection(id: " + userdatasourceid + ")");
      }
      UserDataSourceData pdl = UserDataSourceData.findById(entityManager, userdatasourceid);
      if (pdl != null) {
          BaseUserDataSource userdatasource = getUserDataSource(pdl);
          if(isAuthorizedToEditUserDataSource(admin,userdatasource)){
            try {
              userdatasource.testConnection(admin);
              String msg = intres.getLocalizedMessage("userdatasource.testedcon", pdl.getName());             
              logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new java.util.Date(), null,
                  null, LogConstants.EVENT_INFO_USERDATASOURCEDATA,msg);
            } catch (UserDataSourceConnectionException pe) {
              String msg = intres.getLocalizedMessage("userdatasource.errortestcon", pdl.getName());             
View Full Code Here

    @Override
    public void cloneUserDataSource(Admin admin, String oldname, String newname) throws UserDataSourceExistsException {
      if (log.isTraceEnabled()) {
            log.trace(">cloneUserDataSource(name: " + oldname + ")");
      }
        BaseUserDataSource userdatasourcedata = null;
        UserDataSourceData htp = UserDataSourceData.findByName(entityManager, oldname);
        if (htp == null) {
      String msg = intres.getLocalizedMessage("userdatasource.errorclonesource", newname, oldname);             
            log.error(msg);
            throw new EJBException(msg);
View Full Code Here

      UserDataSourceData htp = UserDataSourceData.findByName(entityManager, name);
      try {
        if (htp == null) {
          throw new Exception("No such UserDataSource.");
        }
        BaseUserDataSource userdatasource = getUserDataSource(htp);
        if(isAuthorizedToEditUserDataSource(admin,userdatasource)){
          entityManager.remove(htp);
          String msg = intres.getLocalizedMessage("userdatasource.removedsource", name);             
          logSession.log(admin, admin.getCaId(), LogConstants.MODULE_RA, new java.util.Date(), null, null, LogConstants.EVENT_INFO_USERDATASOURCEDATA, msg);
          retval = true;
View Full Code Here

        while (i.hasNext()) {
          UserDataSourceData next = i.next();
          if(superadmin){
            returnval.add(next.getId());
          }else{
            BaseUserDataSource userdatasource = getUserDataSource(next);
            if(userdatasource.getApplicableCAs().contains(Integer.valueOf(BaseUserDataSource.ANYCA))){
              if(includeAnyCA){
                returnval.add(next.getId());
              }
            }else{
              if(authorizedcas.containsAll(userdatasource.getApplicableCAs())){
                returnval.add(next.getId());
              }
            }
          }
        }
View Full Code Here

    }

    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    @Override
    public BaseUserDataSource getUserDataSource(Admin admin, String name) {
        BaseUserDataSource returnval = null;
        UserDataSourceData udsd = UserDataSourceData.findByName(entityManager, name);
        if (udsd != null) {
          BaseUserDataSource result = getUserDataSource(udsd);
            if(isAuthorizedToEditUserDataSource(admin,result)){
              returnval = result;
            }else{
          String msg = intres.getLocalizedMessage("userdatasource.errornotauth", name);             
            logSession.log(admin, admin.getCaId(),LogConstants.MODULE_RA,new Date(),null,null,LogConstants.EVENT_ERROR_NOTAUTHORIZEDTORESOURCE,msg);
View Full Code Here

    }

    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    @Override
    public BaseUserDataSource getUserDataSource(Admin admin, int id) {
        BaseUserDataSource returnval = null;
        UserDataSourceData udsd = UserDataSourceData.findById(entityManager, id);
        if (udsd != null) {
          BaseUserDataSource result = getUserDataSource(udsd);
            if(isAuthorizedToEditUserDataSource(admin,result)){
              returnval = result;
            }else{
          String msg = intres.getLocalizedMessage("userdatasource.errornotauth", Integer.valueOf(id));             
            logSession.log(admin, admin.getCaId(),LogConstants.MODULE_RA,new Date(),null,null,LogConstants.EVENT_ERROR_NOTAUTHORIZEDTORESOURCE,msg);
View Full Code Here

        return Integer.valueOf(id);
    }

    /** Method that returns the UserDataSource data and updates it if necessary. */
    private BaseUserDataSource getUserDataSource(UserDataSourceData udsData) {
      BaseUserDataSource userdatasource = udsData.getCachedUserDataSource();
        if (userdatasource == null) {
          java.beans.XMLDecoder decoder;
          try {
            decoder = new java.beans.XMLDecoder(new java.io.ByteArrayInputStream(udsData.getData().getBytes("UTF8")));
          } catch (UnsupportedEncodingException e) {
            throw new EJBException(e);
          }
          HashMap h = (HashMap) decoder.readObject();
          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.BaseUserDataSource

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.