コード例 #1
0
 public CryptoContext(GetPasswordCallback passwordCallback, string publicKeyRing, string secretKeyRing,
                      string cipher, string digest)
     : this(passwordCallback, cipher, digest)
 {
     PublicKeyRingFile  = publicKeyRing;
     PrivateKeyRingFile = secretKeyRing;
 }
コード例 #2
0
 public CryptoContext(GetPasswordCallback passwordCallback, string cipher, string digest, bool loadKeys = true)
     : this(loadKeys)
 {
     PasswordCallback = passwordCallback;
     Digest           = digest;
     Cipher           = cipher;
 }
コード例 #3
0
 public CryptoContext(GetPasswordCallback passwordCallback, string cipher, string digest)
     : this()
 {
     PasswordCallback = passwordCallback;
     Digest           = digest;
     Cipher           = cipher;
 }
コード例 #4
0
ファイル: TicketService.cs プロジェクト: mind0n/hive
 public TicketService(GetPasswordCallback getpwd)
 {
     if (getpwd == null)
     {
         throw new ArgumentNullException();
     }
     GetPassword = getpwd;
 }
コード例 #5
0
        public CryptoContext()
        {
            IsEncrypted          = false;
            IsSigned             = false;
            SignatureValidated   = false;
            IsCompressed         = false;
            FailedIntegrityCheck = true;
            Cipher = "AES-128";
            Digest = "SHA-1";

            GetPasswordCallback PasswordCallback = null;

            OnePassSignature = null;
            Signature        = null;

            List <string> gpgLocations = new List <string>();

            // If GNUPGHOME is set, add to list
            var gpgHome = System.Environment.GetEnvironmentVariable("GNUPGHOME");

            if (gpgHome != null)
            {
                gpgLocations.Add(gpgHome);
            }

            // If registry key is set, add to list
            using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\GNU\GnuPG"))
            {
                if (key != null)
                {
                    gpgHome = key.GetValue("HomeDir", null) as string;

                    if (gpgHome != null)
                    {
                        gpgLocations.Add(gpgHome);
                    }
                }
            }

            // Add default location to list
            gpgHome = System.Environment.GetEnvironmentVariable("APPDATA");
            gpgHome = Path.Combine(gpgHome, "gnupg");
            gpgLocations.Add(gpgHome);

            // many systems also use C:\Users\[name]\.gnupg as well.
            gpgHome = System.Environment.GetEnvironmentVariable("USERPROFILE");
            gpgHome = Path.Combine(gpgHome, ".gnupg");
            gpgLocations.Add(gpgHome);


            // Try all possible locations
            foreach (var home in gpgLocations)
            {
                if (File.Exists(Path.Combine(home, _privateFilename)))
                {
                    PublicKeyRingFile  = Path.Combine(home, _publicFilename);
                    PrivateKeyRingFile = Path.Combine(home, _privateFilename);
                    return;
                }

                // Portable gnupg will use a subfolder named 'home'
                if (File.Exists(Path.Combine(home, "home", _privateFilename)))
                {
                    PublicKeyRingFile  = Path.Combine(home, "home", _publicFilename);
                    PrivateKeyRingFile = Path.Combine(home, "home", _privateFilename);
                    return;
                }
            }

            // failed to find keyrings!
            throw new ApplicationException("Error, failed to locate keyrings! Please specify location using GNUPGHOME environmental variable.");
        }
コード例 #6
0
		public CryptoContext(GetPasswordCallback passwordCallback, string cipher, string digest)
			: this()
		{
			PasswordCallback = passwordCallback;
			Digest = digest;
			Cipher = cipher;
		}
コード例 #7
0
		public CryptoContext(GetPasswordCallback passwordCallback, string publicKeyRing, string secretKeyRing,
			string cipher, string digest)
			: this(passwordCallback, cipher, digest)
		{
			PublicKeyRingFile = publicKeyRing;
			PrivateKeyRingFile = secretKeyRing;
		}
コード例 #8
0
		public CryptoContext(GetPasswordCallback passwordCallback, string cipher, string digest, bool loadKeys = true)
			: this(loadKeys)
		{
			PasswordCallback = passwordCallback;
			Digest = digest;
			Cipher = cipher;
		}
コード例 #9
0
ファイル: App.cs プロジェクト: nuxleus/flexwiki
		public static int Main(string[] args)
		{
      try
      {
        PrintCopyright(); 

        string envOptions = Environment.GetEnvironmentVariable("FWSOPTIONS");
        
        if (envOptions != null)
        {
          envOptions = envOptions.Trim(); 

          if (envOptions.Length > 0)
          {
            string[] additionalArgs = envOptions.Split(' '); 

            ArrayList al = new ArrayList();
            al.AddRange(additionalArgs);
            al.AddRange(args); 

            args = (string[]) al.ToArray(typeof(string)); 

            Console.WriteLine("Running with modified command line:");
            Console.WriteLine("fwsync {0}", string.Join(" ", args)); 
          }
        }

        Options options = null; 
        GetPasswordCallback gpc = new GetPasswordCallback(GetPassword); 
        try	
        {
          options = Utilities.ParseCommandLine(args, gpc); 
        }
        catch (ParseCommandLineException pcle)
        {
          Console.WriteLine(pcle.Message); 
          Utilities.PrintUsage(); 
          return ERROR_USAGE; 
        }

        if (options.Debug)
        {
          System.Diagnostics.Debugger.Break(); 
        }

        FwEditServiceProxy proxy = CreateEditServiceProxy(options); 
        string basedir = Synchronizer.CalculateBaseDir(options.Files); 
        Synchronizer sync = new Synchronizer(basedir, proxy); 
        sync.Progress += new ProgressCallback(PrintProgress);
        
        if (options.Command == Commands.Initialize)
        {
          sync.Initialize(options.LocalOnly); 
        }
        else if (options.Command == Commands.Update)
        {
          sync.Update(options.Files); 
        }
        else if (options.Command == Commands.Status)
        {
          sync.SyncToLocal(); 

          if (!options.LocalOnly)
          {
            sync.SyncToRemote(); 
          }

          PrintStatus(sync, options.Files, options.Show); 
        }
        else if (options.Command == Commands.Commit)
        {
          try
          {
            sync.Commit(options.Attribution, options.Files, options.IgnoreConflict); 
          }
          catch (ConflictException c)
          {
            Console.WriteLine(c.Message); 
            return ERROR_CONFLICT; 
          }
        }
        else if (options.Command == Commands.Help)
        {
          switch (options.HelpTopic)
          {
            case HelpTopics.Commands: 
              Utilities.PrintCommandsHelp();
              break;
            case HelpTopics.Commit:
              Utilities.PrintCommitHelp(); 
              break; 
            case HelpTopics.Environment:
              Utilities.PrintEnvironmentHelp();
              break;
            case HelpTopics.General:
              Utilities.PrintGeneralHelp(); 
              break;
            case HelpTopics.Help:
              Utilities.PrintHelpHelp(); 
              break; 
            case HelpTopics.Init: 
              Utilities.PrintInitHelp(); 
              break; 
            case HelpTopics.Options:
              Utilities.PrintOptionsHelp();
              break;
            case HelpTopics.Status:
              Utilities.PrintStatusHelp();
              break;
            case HelpTopics.Resolve:
              Utilities.PrintResolveHelp(); 
              break; 
            case HelpTopics.Update:
              Utilities.PrintUpdateHelp();
              break; 
            default:
              Utilities.PrintGeneralHelp();
              break;
          }
        }
        else if (options.Command == Commands.Resolve)
        {
          ConflictResolver cr = new ConflictResolver(options); 
          ResolveConflictCallback rccb = new ResolveConflictCallback(cr.ResolveConflict); 
          sync.Resolve(rccb, options.Files); 
        }
        else
        {
          Console.WriteLine("Command {0} not currently implemented", options.Command); 
          return ERROR_NOT_IMPLEMENTED; 
        }
      }
      catch (Exception e)
      {
        Console.WriteLine("An unhandled exception was thrown.\n\n{0}", e); 
        return ERROR_EXCEPTION; 
      }

			return SUCCESS; 
			
		}