Package com.baasbox.util

Examples of com.baasbox.util.ConfigurationFileContainer


            db = DbHelper.open("1234567890", "admin", "admin");
          } catch (InvalidAppCodeException e) {
            fail();
          }
          ODatabaseRecordThreadLocal.INSTANCE.set(db);
          ConfigurationFileContainer cfc = Push.PROFILE1_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
          assertNotNull(cfc);
          assertNotNull(cfc.getName());
          assertNotNull(cfc.getContent());
          assertEquals("TestFakeCertificate.p12",cfc.getName());
          String content = new String(cfc.getContent());
          assertTrue(content.indexOf("I am a fake certificate")>-1);
          certificate.delete();
          folder.delete();
          db.close();
        }
View Full Code Here


   
  }
 
  //this is needed due iOS certificates migrations
  private ConfigurationFileContainer getValueAsFileContainer(Object v) {
    ConfigurationFileContainer result = null;
    if(v!=null){
      ObjectMapper om = new ObjectMapper();
      try {
        result = om.readValue(v.toString(), ConfigurationFileContainer.class);
      } catch (Exception e) {
View Full Code Here

          FilePart file = body.getFile("file");
          if(file==null) return badRequest("missing file");
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          try{
            FileUtils.copyFile(file.getFile(),baos);
            Object fileValue = new ConfigurationFileContainer(file.getFilename(), baos.toByteArray());
            baos.close();
            conf.getMethod("setValue",Object.class).invoke(i,fileValue);
          }catch(Exception e){
            internalServerError(e.getMessage());
          }
View Full Code Here

  public void setConfiguration(ImmutableMap<ConfigurationKeys, String> configuration) {
    String json = configuration.get(ConfigurationKeys.IOS_CERTIFICATE);
    String name = null;
    ObjectMapper mp = new ObjectMapper();
    try{
      ConfigurationFileContainer cfc = mp.readValue(json, ConfigurationFileContainer.class);
      name = cfc.getName();
    }catch(Exception e){
      Logger.error(e.getMessage());
    }
    if(name!=null && !name.equals("null")){
      File f = IosCertificateHandler.getCertificate(name);
View Full Code Here

    String folder = BBConfiguration.getPushCertificateFolder();
    File f = new File(folder);
    if(!f.exists()){
      f.mkdirs();
    }
    ConfigurationFileContainer newValue=null;
    ConfigurationFileContainer currentValue=null;
    if(iNewValue!=null && iNewValue instanceof ConfigurationFileContainer){

      newValue =(ConfigurationFileContainer)iNewValue;
    }
    if(iCurrentValue!=null){
      if(iCurrentValue instanceof String){
        try {
          currentValue =new ObjectMapper().readValue(iCurrentValue.toString(), ConfigurationFileContainer.class);
        } catch (Exception e) {
          if (Logger.isDebugEnabled()) Logger.debug("unable to convert value to ConfigurationFileContainer");
        }
      }else if (iCurrentValue instanceof ConfigurationFileContainer){
        currentValue = (ConfigurationFileContainer)iCurrentValue;
        }
      }
      if(currentValue!=null){
        File oldFile =  new File(folder+sep+currentValue.getName());
        if(oldFile.exists()){
          try{
            FileUtils.forceDelete(oldFile);
          }catch(Exception e){
            Logger.error(e.getMessage());
View Full Code Here

      String folder = BBConfiguration.getPushCertificateFolder();
      File f = new File(folder);
      if(!f.exists()){
        f.mkdirs();
      }
      ConfigurationFileContainer prod = Push.PROFILE1_PRODUCTION_IOS_CERTIFICATE.getValueAsFileContainer();
      ConfigurationFileContainer sandbox = Push.PROFILE1_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
     
      ConfigurationFileContainer prod2 = Push.PROFILE2_PRODUCTION_IOS_CERTIFICATE.getValueAsFileContainer();
      ConfigurationFileContainer sandbox2 = Push.PROFILE2_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
     
      ConfigurationFileContainer prod3 = Push.PROFILE3_PRODUCTION_IOS_CERTIFICATE.getValueAsFileContainer();
      ConfigurationFileContainer sandbox3 = Push.PROFILE3_SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
     
      if(prod!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for default profile:"+prod.getName());
        File prodCertificate =  new File(folder+sep+prod.getName());
        if(!prodCertificate.exists()){
          try{
            prodCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(prod.getContent());
            FileUtils.copyInputStreamToFile(bais, prodCertificate);

          }catch(Exception e){
            prodCertificate.delete();
            throw new RuntimeException("Unable to create file for certificate:"+e.getMessage());
          }
        }
      }
      if(sandbox!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for default profile:"+sandbox.getName());
        File sandboxCertificate =  new File(folder+sep+sandbox.getName());
        if(!sandboxCertificate.exists()){
          try{
            sandboxCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(sandbox.getContent());
            FileUtils.copyInputStreamToFile(bais, sandboxCertificate);

          }catch(Exception e){
            sandboxCertificate.delete();
            throw new RuntimeException("Unable to create file for certificate:"+e.getMessage());
          }
        }
      }
     
      if(prod2!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for profile 2:"+prod2.getName());
        File prodCertificate =  new File(folder+sep+prod2.getName());
        if(!prodCertificate.exists()){
          try{
            prodCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(prod.getContent());
            FileUtils.copyInputStreamToFile(bais, prodCertificate);

          }catch(Exception e){
            prodCertificate.delete();
            throw new RuntimeException("Unable to create file for certificate:"+e.getMessage());
          }
        }
      }
      if(sandbox2!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for profile 2:"+sandbox2.getName());
        File sandboxCertificate =  new File(folder+sep+sandbox2.getName());
        if(!sandboxCertificate.exists()){
          try{
            sandboxCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(sandbox.getContent());
            FileUtils.copyInputStreamToFile(bais, sandboxCertificate);

          }catch(Exception e){
            sandboxCertificate.delete();
            throw new RuntimeException("Unable to create file for certificate:"+e.getMessage());
          }
        }
      }
     
      if(prod3!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate for profile 3:"+prod3.getName());
        File prodCertificate =  new File(folder+sep+prod3.getName());
        if(!prodCertificate.exists()){
          try{
            prodCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(prod3.getContent());
            FileUtils.copyInputStreamToFile(bais, prodCertificate);

          }catch(Exception e){
            prodCertificate.delete();
            throw new RuntimeException("Unable to create file for certificate:"+e.getMessage());
          }
        }
      }
      if(sandbox3!=null){
        if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate for profile 3:"+sandbox3.getName());
        File sandboxCertificate =  new File(folder+sep+sandbox3.getName());
        if(!sandboxCertificate.exists()){
          try{
            sandboxCertificate.createNewFile();
            ByteArrayInputStream bais = new ByteArrayInputStream(sandbox.getContent());
            FileUtils.copyInputStreamToFile(bais, sandboxCertificate);
View Full Code Here

TOP

Related Classes of com.baasbox.util.ConfigurationFileContainer

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.