Examples of MethodResult


Examples of de.netsysit.controller.MethodResult

    KeyStore keyStore = null;
    Key privateKey;
    CMSSignedDataGenerator generator;
    CMSProcessable processableData;
    CMSSignedData signedContainer;
    MethodResult loadingKeyStoreResult;

    MethodResult signingDataResult;
    byte[] signedData = null;
    int resultValue = UNKNOWN_ERROR;
    Throwable th = null;

    loadingKeyStoreResult = loadKeyStore(keyStorePath, keyStorePassword);
//    Log.d(TAG, "keystore: " + loadingKeyStoreResult.getResultObject());

    if (loadingKeyStoreResult.getResultValue() == OPERATION_SUCCESSFUL) {
      try {
        keyStore = (KeyStore) loadingKeyStoreResult.getResultObject();
        privateKey = keyStore.getKey(keyAlias, privateKeyPassword);
        generator = new CMSSignedDataGenerator();
        generator.addSigner((PrivateKey) privateKey,
                    (X509Certificate) keyStore.getCertificate(keyAlias),
                    digestOID);
        List<X509Certificate> certList = new ArrayList<X509Certificate>();
        certList.add((X509Certificate) keyStore.getCertificate(keyAlias));
        CertStoreParameters params = new CollectionCertStoreParameters(certList);
        CertStore cs = CertStore.getInstance("Collection", params, "BC");
        generator.addCertificatesAndCRLs(cs);
        processableData = new CMSProcessableByteArray(data2beSigned);
        signedContainer = generator.generate(processableData, true, "BC");
        signedData = signedContainer.getEncoded();
        resultValue = OPERATION_SUCCESSFUL;
      } catch (UnrecoverableKeyException uke) {
        uke.printStackTrace();
        resultValue = PRIVATE_KEY_CORRUPTED;
        th = uke;
      } catch (KeyStoreException kse) {
        kse.printStackTrace();
        resultValue = KEYSTORE_CORRUPTED;
        th = kse;
      } catch (NoSuchAlgorithmException nsae) {
        nsae.printStackTrace();
        resultValue = ALGORITHM_NOT_FOUND;
        th = nsae;
      } catch (InvalidAlgorithmParameterException iape) {
        iape.printStackTrace();
        resultValue = ALGORITHM_NOT_FOUND;
        th = iape;
      } catch (NoSuchProviderException nspe) {
        nspe.printStackTrace();
        resultValue = CRYPTO_PROVIDER_NOT_FOUND;
        th = nspe;
      } catch (CertStoreException cse) {
        cse.printStackTrace();
        resultValue = CERTIFICATE_CORRUPTED;
        th = cse;
      } catch (CMSException cmse) {
        cmse.printStackTrace();
        resultValue = MESSAGE_CORRUPTED;
        th = cmse;
      } catch (IOException ioe) {
        ioe.printStackTrace();
        resultValue = IO_ERROR;
        th = ioe;
      } catch (Throwable t) {
        t.printStackTrace();
        resultValue = UNKNOWN_ERROR;
        th = t;
      }
    }
    else { // loading of keystore was not successful...
      resultValue = loadingKeyStoreResult.getResultValue();
      th = loadingKeyStoreResult.getT();
    }

    signingDataResult = new MethodResult(resultValue, signedData, th);

    return signingDataResult;
  }
View Full Code Here

Examples of de.netsysit.controller.MethodResult

    return signingDataResult;
  }

  private static MethodResult loadKeyStore(String keyStorePath, char[] keyStorePassword) {
    MethodResult result;
    int resultValue = UNKNOWN_ERROR;
    Throwable th = null;

    MethodResult gettingKeyStoreContentResult;

    File keyStoreFile;
    InputStream signedKeyStoreInputStream;
    KeyStore keyStore = null;

    try {
      keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
      keyStoreFile = new File(keyStorePath);
      signedKeyStoreInputStream = new FileInputStream(keyStoreFile);
      gettingKeyStoreContentResult = getContentOfSignedData(signedKeyStoreInputStream, true);

      if (gettingKeyStoreContentResult.getResultValue() == OPERATION_SUCCESSFUL) {
        keyStore.load((InputStream) gettingKeyStoreContentResult.getResultObject(), keyStorePassword);
        // XXX close the inputstream possible after loading the keystore ?
//        Log.d(TAG, "keystore: " + keyStore);
        resultValue = OPERATION_SUCCESSFUL;
      }
      else {
        resultValue = gettingKeyStoreContentResult.getResultValue();
        th = gettingKeyStoreContentResult.getT();
      }

    } catch (KeyStoreException kse) {
      kse.printStackTrace();
      resultValue = KEYSTORE_CORRUPTED;
      th = kse;
    } catch (FileNotFoundException fne) {
      fne.printStackTrace();
      resultValue = KEYSTORE_NOT_FOUND;
      th = fne;
    } catch (NoSuchAlgorithmException nsae) {
      nsae.printStackTrace();
      resultValue = ALGORITHM_NOT_FOUND;
      th = nsae;
    } catch (CertificateException ce) {
      ce.printStackTrace();
      resultValue = CERTIFICATE_CORRUPTED;
      th = ce;
    } catch (IOException ioe) {
      ioe.printStackTrace();
      resultValue = IO_ERROR;
      th = ioe;
    } catch (Throwable t) {
      t.printStackTrace();
      resultValue = UNKNOWN_ERROR;
      th = t;
    }

    result = new MethodResult(resultValue, keyStore, th);

    return result;
  }
View Full Code Here

Examples of de.netsysit.controller.MethodResult

    return result;
  }

  public static MethodResult getContentOfSignedData (InputStream signedContentStream, boolean resultAsStream) {
    MethodResult result = null;
    int resultValue = 0;
    byte[] content = null;
    Throwable th = null;

    CMSSignedData signedData;
    ByteArrayInputStream contentStream = null;

    try {
      signedData = new CMSSignedData(signedContentStream);
      content = (byte[]) signedData.getSignedContent().getContent();

      if (resultAsStream)
        contentStream = new ByteArrayInputStream(content);

      resultValue = OPERATION_SUCCESSFUL;
    } catch (CMSException cmse) {
      cmse.printStackTrace();
      resultValue = MESSAGE_CORRUPTED;
      th = cmse;
    } catch (Throwable t) {
      t.printStackTrace();
      resultValue = UNKNOWN_ERROR;
      th = t;
    }

    if (resultAsStream)
      result = new MethodResult(resultValue, contentStream, th);
    else
      result = new MethodResult(resultValue, content, th);

    return result;
  }
View Full Code Here

Examples of gnu.classpath.jdwp.util.MethodResult

  }

  private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
      throws JdwpException, IOException
  {
    MethodResult mr = invokeMethod(bb);

    Object value = mr.getReturnedValue();
    Exception exception = mr.getThrownException();
    ObjectId eId = idMan.getObjectId(exception);

    Value.writeTaggedValue(os, value);
    eId.writeTagged(os);
  }
View Full Code Here

Examples of gnu.classpath.jdwp.util.MethodResult

  }

  private void executeNewInstance(ByteBuffer bb, DataOutputStream os)
      throws JdwpException, IOException
  {
    MethodResult mr = invokeMethod(bb);

    Object obj = mr.getReturnedValue();
    ObjectId oId = idMan.getObjectId(obj);
    Exception exception = mr.getThrownException();
    ObjectId eId = idMan.getObjectId(exception);

    oId.writeTagged(os);
    eId.writeTagged(os);
  }
View Full Code Here

Examples of gnu.classpath.jdwp.util.MethodResult

    try
      {
        if (suspend)
    VMVirtualMachine.suspendAllThreads ();

        MethodResult mr = VMVirtualMachine.executeMethod(null, thread,
               clazz, method,
               values, false);
        if (suspend)
    VMVirtualMachine.resumeAllThreads ();
View Full Code Here

Examples of gnu.classpath.jdwp.util.MethodResult

    boolean nonVirtual = ((invokeOptions
         & JdwpConstants.InvokeOptions.INVOKE_NONVIRTUAL)
        != 0);

    MethodResult mr = VMVirtualMachine.executeMethod(obj, thread,
                 clazz, method,
                 values, nonVirtual);
    Object value = mr.getReturnedValue();
    Exception exception = mr.getThrownException();

    ObjectId eId = idMan.getObjectId(exception);
    Value.writeTaggedValue(os, value);
    eId.writeTagged(os);
  }
View Full Code Here

Examples of org.apache.felix.scr.impl.helper.MethodResult

                    new Object[] {refPair.getRef(), getName()}, null );
            return false;

        }
        BindParameters bp = new BindParameters(componentContext, refPair);
        MethodResult result = m_bindMethods.getBind().invoke( componentContext.getImplementationObject( false ), bp, MethodResult.VOID, m_componentManager );
        if ( result == null )
        {
            return false;
        }
        m_componentManager.setServiceProperties( result );
View Full Code Here

Examples of org.apache.felix.scr.impl.helper.MethodResult

                        new Object[] {refPair.getRef(), getName()}, null );
                return;

            }
            BindParameters bp = new BindParameters(componentContext, refPair);
            MethodResult methodResult = m_bindMethods.getUpdated().invoke( componentContext.getImplementationObject( false ), bp, MethodResult.VOID, m_componentManager );
            if ( methodResult != null)
            {
                m_componentManager.setServiceProperties( methodResult );
            }
        }
View Full Code Here

Examples of org.apache.felix.scr.impl.helper.MethodResult

                        new Object[] {refPair.getRef(), getName()}, null );
                return;

            }
            BindParameters bp = new BindParameters(componentContext, refPair);
            MethodResult methodResult = m_bindMethods.getUnbind().invoke( componentContext.getImplementationObject( false ), bp, MethodResult.VOID, m_componentManager );
            if ( methodResult != null )
            {
                m_componentManager.setServiceProperties( methodResult );
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.