Examples of CryptographicProvider


Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

   * @param archive archive to read from
   * @return programmer's key
   */
  private Key readProgrammerKey(JarFile archive)
  {
    CryptographicProvider p =
      CryptographicManager.getInstance().getProvider("OpenPGP");
    try
    {

      byte[] data = this.readFile("programmer", "asc", archive, null);
      return p.importKey(data);

    } catch (IOException e)
    {
      e.printStackTrace();
      return null;
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

   * @param archive Archive to extract key from. 
   * @param agentInfo <code>AgentInfo</code> where to store the key.
   */
  private void readAgentKey(JarFile archive, AgentInfo agentInfo)
  {
    CryptographicProvider p =
      CryptographicManager.getInstance().getProvider("OpenPGP");
    try
    {

      byte[] data =
        this.readFile(
          "agent",
          "asc",
          archive,
          agentInfo.getOwnerPublicKey());
      agentInfo.setAgentPublicKey(p.importKey(data));

    } catch (IOException e)
    {
      e.printStackTrace();
    }
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

   * @param archive archive from which to extract the key
   * @param agentInfo <code>AgentInfo</code> to which to store the key.
   */
  private void readOwnerKey(JarFile archive, AgentInfo agentInfo)
  {
    CryptographicProvider p =
      CryptographicManager.getInstance().getProvider("OpenPGP");
    try
    {

      byte[] data = this.readFile("owner", "asc", archive, null);
      Key ownerKey = p.importKey(data);
      agentInfo.setOwnerPublicKey(ownerKey);

    } catch (IOException e)
    {
      e.printStackTrace();
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

      // yes, host-specific
      System.out.println("Hostspecific file");
      byte[] data =
        this.inputStreamToByteArray(archive.getInputStream(entry));
      CryptographicProvider p =
        CryptographicManager.getInstance().getProvider("OpenPGP");
      data = p.decrypt(data, ownerkey);

      return data;

    } else
    {
      // we have only the generic information
      entry = archive.getEntry(filename + "." + extension);

      if (entry == null)
      {
        System.out.println("File not found: " + filename);
        return null;
      }

      System.out.println("Generic file");

      byte[] data =
        this.inputStreamToByteArray(archive.getInputStream(entry));

      // check signature
      CryptographicProvider p =
        CryptographicManager.getInstance().getProvider("OpenPGP");

      if (ownerkey != null)
      {

        if (!p.isValidSignature(data, ownerkey))
          return null;

        data = p.stripSignature(data);
      }

      return data;
    }
  }
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

   * @return verified data or <code>null</code>, if signature is wrong
   */
  private byte[] verifySignature(byte[] data, Key ownerKey)
  {
    // obtain openpgp-compliant CryptographicProvider
    CryptographicProvider p = this.getCryptographicProvider();
   
    // check, if one is installed in the system
    if(p==null) return null;
   
    if (p.isValidSignature(data, ownerKey))
    {
      return p.stripSignature(data);
    } else
    {
      return null;
    }
  }
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

    File jarFile)
  {
    String[] certificate = new String(data).split("\n");

    // get matching CryptographicProvider
    CryptographicProvider p = null;

    System.out.println("0");
    // check header
    // ident-string+empty line+1 line info
    if (certificate.length != 3)
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

   *
   * @param args not used
   */
  public static void main(String[] args)
  {
    CryptographicProvider p = new GPGCryptographicProvider();
    GPGKey myKey = new GPGKey("BF384020FD7BAC6AE98F1111F2CF16F2324033FF");
    GPGKey dannyKey = new GPGKey("82D4BE5C00DC9AFBCFA8469110A452249A209C50");

    System.out.println("Trust my  key: " + p.isTrustedKey(myKey));
    System.out.println("Trust d's key: " + p.isTrustedKey(dannyKey));
   
   
    byte[] e_bytes = p.encryptAndSign("Hallo".getBytes(),myKey,null);
    String encrypted = new String(e_bytes);
    System.out.println("Encrypted:\n==========\n\n"+encrypted+"\n");
   
    byte[] d_bytes = p.decrypt(encrypted.getBytes(),null);
    String decrypted = new String(d_bytes);
   
    System.out.println("Decrypted:\n==========\n\n"+decrypted+"\n\n");
  }
View Full Code Here

Examples of de.tuclausthal.informatik.winf.mobileagents.security.CryptographicProvider

  public CryptographicProvider getProvider(Key key)
  {
    Iterator it = this.providers.values().iterator();
    while(it.hasNext())
    {
      CryptographicProvider p = (CryptographicProvider)it.next();
      if(p.canUseKey(key))
      {
        return p;
      }
    }
   
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.