Example #1
0
        public DecoderForm(SecretType mode, GameRegion region)
        {
            this.Build();
            switch (mode)
            {
            case SecretType.Game:
                _secretLength = 20;
                break;

            case SecretType.Ring:
                _secretLength = 15;
                break;

            case SecretType.Memory:
                _secretLength = 5;
                break;
            }
            _region = region;
            data    = new byte[_secretLength];
            Mode    = mode;
            chkAppendRings.Visible = Mode == SecretType.Ring;

            if (region == GameRegion.US)
            {
                notebook1.RemovePage(1);
            }
            else if (region == GameRegion.JP)
            {
                notebook1.RemovePage(0);
                label7.Text = "Secrets can be entered in kana, romaji, or both";
                label8.Text = "んすなこゆ\nn su na ko yu\nN すな KoYu";
            }
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public SecretInformation(
     string name,
     SecretType type,
     string vaultName,
     ReadOnlyDictionary <string, object> metadata) : this(name, type, vaultName)
 {
     Metadata = metadata;
 }
Example #3
0
 private int?SecretTypeToInt(SecretType type)
 {
     if (type == SecretType.Auto)
     {
         return(null);
     }
     return((int)type);
 }
Example #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public SecretInformation(
     string name,
     SecretType type,
     string vaultName)
 {
     Name      = name;
     Type      = type;
     VaultName = vaultName;
 }
Example #5
0
        internal Secret(SecretName name, string value, DateTime createdUtc, DateTime?expiryUtc, SecretType type, IEnumerable <SecretAuditEntry> auditLog)
        {
            Name       = name;
            Value      = value;
            CreatedUtc = createdUtc;
            ExpiryUtc  = expiryUtc;
            Type       = type;

            _auditLog = auditLog.ToList();
            AuditLog  = _auditLog.AsReadOnly();
        }
Example #6
0
        private static byte[] ReadSecret(string keyDirectory, string id, SecretType st)
        {
            var keyfile = keyDirectory + $"{Path.DirectorySeparatorChar}";

            keyfile += st == SecretType.Key ? $"{id}.kv2" : $"{id}.iv";
            if (!File.Exists(keyfile))
            {
                throw new FileNotFoundException($"Key file '{keyfile}' not found.");
            }
            return(Read(keyfile));
        }
Example #7
0
        internal Secret(SecretName name, string value, DateTime createdUtc, DateTime? expiryUtc, SecretType type, IEnumerable<SecretAuditEntry> auditLog)
        {
            Name = name;
            Value = value;
            CreatedUtc = createdUtc;
            ExpiryUtc = expiryUtc;
            Type = type;

            _auditLog = auditLog.ToList();
            AuditLog = _auditLog.AsReadOnly();
        }
Example #8
0
        /// <summary>
        /// Creates a new <c>InputSecretDialogView</c> instance and
        /// specifies the type of secret that the user will be asked to input.
        /// </summary>
        /// <param name="secretType">Tht type of secret that the user should input (password, rescue code...).</param>
        public InputSecretDialogView(SecretType secretType)
        {
            this.InitializeComponent();
            this.DataContextChanged += InputSecretDialogView_DataContextChanged;

            _txtSecret  = this.FindControl <CopyPasteTextBox> ("txtSecret");
            _lblMessage = this.FindControl <TextBlock>("lblMessage");

            // This is only here because for some reason the XAML behaviour "FocusOnAttached"
            // isn't working for this window. No clue why, probably a dumb mistake on my part.
            // If anyone gets this working in XAML, this ugly hack can be removed!
            _txtSecret.AttachedToVisualTree += (sender, e) => (sender as CopyPasteTextBox).Focus();
        }
Example #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SecretInformation(
            string name,
            SecretType type,
            string vaultName,
            Hashtable metadata) : this(name, type, vaultName)
        {
            if (metadata == null)
            {
                return;
            }

            Dictionary <string, object> metaDictionary = new Dictionary <string, object>(metadata.Count);

            foreach (var key in metadata.Keys)
            {
                metaDictionary.Add((string)key, metadata[key]);
            }
            Metadata = new ReadOnlyDictionary <string, object>(metaDictionary);
        }
        public SecretDecoder(SecretType mode)
        {
            InitializeComponent();
            switch (mode)
            {
            case SecretType.Game:
                _secretLength = 20;
                break;

            case SecretType.Ring:
                _secretLength = 15;
                break;

            case SecretType.Memory:
                _secretLength = 5;
                break;
            }
            data = new byte[_secretLength];
            Mode = mode;
            chkAppendRings.Visibility = Mode == SecretType.Ring ? Visibility.Visible : Visibility.Collapsed;
        }
Example #11
0
        /// <summary>
        /// Creates a new <c>InputSecretDialogView</c> instance and
        /// specifies the type of secret that the user will be asked to input.
        /// </summary>
        /// <param name="secretType">Tht type of secret that the user should input (password, rescue code...).</param>
        public InputSecretDialogView(SecretType secretType)
        {
            this.InitializeComponent();

            //Prevent closing the dialog externally.
            this.Closing   += InputSecretDialogView_Closing;
            _txtSecret      = this.FindControl <CopyPasteTextBox> ("txtSecret");
            _btnOK          = this.FindControl <Button>("btnOK");
            _lblMessage     = this.FindControl <TextBlock>("lblMessage");
            _txtSecret.Text = "";
            _btnOK.Click   += (object sender, RoutedEventArgs e) =>
            {
                AllGood = true;
                this.Close(_txtSecret.Text);
            };

            this._secretType = secretType;
            switch (secretType)
            {
            case SecretType.Password:
                _lblMessage.Text        = _loc.GetLocalizationValue("EnterPasswordMessage");
                _txtSecret.PasswordChar = '*';
                break;

            case SecretType.RescueCode:
                _lblMessage.Text = _loc.GetLocalizationValue("EnterRescueCodeMessage");
                break;

            default:
                break;
            }

#if DEBUG
            this.AttachDevTools();
#endif
        }
 internal ValueSecretInfo(SecretType secretType, string value) : base(secretType)
 {
     Value      = value;
     SecretType = secretType;
 }
Example #13
0
 internal AzureFirstPartyManagedCertificateDefinition(SecretType secretType) : base(secretType)
 {
     SecretType = secretType;
 }
Example #14
0
 internal SecretParameters(SecretType type)
 {
     Type = type;
 }
Example #15
0
 internal AzureFirstPartyManagedCertificateParameters(SecretType secretType) : base(secretType)
 {
     SecretType = secretType;
 }
Example #16
0
 internal KeyVaultSecretReferenceSecretInfo(SecretType secretType, string name, string version) : base(secretType)
 {
     Name       = name;
     Version    = version;
     SecretType = secretType;
 }
Example #17
0
 internal ManagedCertificateDefinition(SecretType secretType, string subject, string expirationDate) : base(secretType)
 {
     Subject        = subject;
     ExpirationDate = expirationDate;
     SecretType     = secretType;
 }
Example #18
0
 internal KeyVaultSecretUriSecretInfo(SecretType secretType, string value) : base(secretType)
 {
     Value      = value;
     SecretType = secretType;
 }
Example #19
0
 private int? SecretTypeToInt(SecretType type)
 {
     if (type == SecretType.Auto)
     {
         return null;
     }
     return (int)type;
 }
Example #20
0
 public Secret(SecretName name, string value, DateTime createdUtc, DateTime? expiryUtc, SecretType type)
     : this(name, value, createdUtc, expiryUtc, type, Enumerable.Empty<SecretAuditEntry>())
 {
 }
Example #21
0
 internal SecretProperties(SecretType secretType)
 {
     SecretType = secretType;
 }
 public void SetSecret(string newVal, SecretType secretType)
 {
     this.m_comObject.GetType().InvokeMember("SetSecret", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, this.m_comObject, new object[] { newVal, secretType });
 }
Example #23
0
 public Secret(SecretName name, string value, DateTime createdUtc, DateTime?expiryUtc, SecretType type)
     : this(name, value, createdUtc, expiryUtc, type, Enumerable.Empty <SecretAuditEntry>())
 {
 }
 internal ManagedCertificateParameters(SecretType type) : base(type)
 {
     Type = type;
 }
Example #25
0
    private void SubInitialiseSessionStart()
    {
        //
        // - - - SecretTypes - - -
        //
        Dictionary <string, SecretType> dictOfSecretTypes = GameManager.i.dataScript.GetDictOfSecretTypes();

        if (dictOfSecretTypes != null)
        {
            foreach (var secretType in dictOfSecretTypes)
            {
                //pick out and assign the ones required for fast access.
                //Also dynamically assign SecretType.level values (0/1/2).
                switch (secretType.Key)
                {
                case "Player":
                    secretType.Value.level = 0;
                    secretTypePlayer       = secretType.Value;
                    break;

                case "Organisation":
                    secretType.Value.level = 1;
                    secretTypeOrganisation = secretType.Value;
                    break;

                case "Story":
                    secretType.Value.level = 2;
                    secretTypeStory        = secretType.Value;
                    break;

                default:
                    Debug.LogWarningFormat("Invalid secretType \"{0}\"", secretType.Key);
                    break;
                }
            }
            //error check
            Debug.Assert(secretTypePlayer != null, "Invalid secretTypePlayer (Null)");
            Debug.Assert(secretTypeOrganisation != null, "Invalid secretTypeOrganisation (Null)");
        }
        else
        {
            Debug.LogWarning("Invalid dictOfSecretTypes (Null)");
        }
        //
        // - - - - Secrets - - -
        //
        Dictionary <string, Secret> dictOfSecrets = GameManager.i.dataScript.GetDictOfSecrets();
        List <Secret> listOfPlayerSecrets         = GameManager.i.dataScript.GetListOfPlayerSecrets();
        List <Secret> listOfOrganisationSecrets   = GameManager.i.dataScript.GetListOfOrganisationSecrets();
        List <Secret> listOfStorySecrets          = GameManager.i.dataScript.GetListOfStorySecrets();

        int playerLevel = GameManager.i.sideScript.PlayerSide.level;

        if (dictOfSecrets != null)
        {
            if (listOfPlayerSecrets != null)
            {
                if (listOfOrganisationSecrets != null)
                {
                    if (listOfStorySecrets != null)
                    {
                        //add to appropriate lists
                        foreach (var secret in dictOfSecrets)
                        {
                            if (secret.Value != null)
                            {
                                //set all key secret SO data to default settings (otherwise will carry over data between sessions)
                                secret.Value.Initialise();
                                //Only add those of the same side as the player)
                                if (secret.Value.side.level == playerLevel)
                                {
                                    switch (secret.Value.type.level)
                                    {
                                    case 0:
                                        //Player secrets
                                        listOfPlayerSecrets.Add(secret.Value);
                                        break;

                                    case 1:
                                        //Organisation measures secrets (desperate)
                                        listOfOrganisationSecrets.Add(secret.Value);
                                        break;

                                    case 2:
                                        //Story secrets
                                        listOfStorySecrets.Add(secret.Value);
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                Debug.LogWarning("Invalid secret (Null) in dictOfSecrets");
                            }
                        }
                        Debug.LogFormat("[Loa] SecretManager.cs -> listOfPlayerSecrets has {0} entries{1}", listOfPlayerSecrets.Count, "\n");
                        Debug.Assert(listOfPlayerSecrets.Count > 0, "No records in listOfPlayerSecrets");
                    }
                    else
                    {
                        Debug.LogWarning("Invalid listOfStorySecrets (Null)");
                    }
                }
                else
                {
                    Debug.LogWarning("Invalid listOfOrganisationSecrets (Null)");
                }
            }
            else
            {
                Debug.LogWarning("Invalid listOfPlayerSecrets (Null)");
            }
        }
        else
        {
            Debug.LogWarning("Invalid dictOfSecrets (Null)");
        }
    }
Example #26
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="SecretType" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => SecretType.CreateFrom(sourceValue);
Example #27
0
 public JWTService(string secretKey, SecretType type)
 {
     SecretKey = secretKey;
     Type      = type;
 }
 public override int GetHashCode()
 {
     return(SecretType.GetHashCode());
 }
 internal SecretDefinition(SecretType secretType)
 {
     SecretType = secretType;
 }
 internal SecretInfoBase(SecretType secretType)
 {
     SecretType = secretType;
 }
 internal SecretParameters(SecretType secretType)
 {
     SecretType = secretType;
 }