11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

814 <strong>Improving</strong> <strong>Web</strong> <strong>Application</strong> <strong>Security</strong>: <strong>Threats</strong> <strong>and</strong> Countermeasures(continued)}//Turn off the permission <strong>and</strong> store flags.this._permFlag &= ~(EncryptionPermissionFlag.Encrypt |EncryptionPermissionFlag.Decrypt);this._storePermFlag &= ~(StorePermissionFlag.Machine |StorePermissionFlag.User);attrVal = elem.Attribute("Flags");if (attrVal != null){if(!attrVal.Trim().Equals("")){this._permFlag =(EncryptionPermissionFlag)Enum.Parse(typeof(EncryptionPermissionFlag),attrVal);}}attrVal = elem.Attribute("Stores");if (attrVal != null){if(!attrVal.Trim().Equals("")){this._storePermFlag =(StorePermissionFlag)Enum.Parse(typeof(StorePermissionFlag),attrVal);}}15. Implement IUnrestrictedPermission.IsUnrestricted. This method returns true ifthe permission instance is in the unrestricted state. In this case, an unrestrictedEncryptionPermission instance allows code to encrypt <strong>and</strong> decrypt data usingboth the DPAPI machine <strong>and</strong> user stores.public bool IsUnrestricted(){bool canEncrypt, canDecrypt, canUseUserStore, canUseMachineStore;canEncrypt = (this._permFlag &EncryptionPermissionFlag.Encrypt).Equals(EncryptionPermissionFlag.Encrypt);canDecrypt = (this._permFlag &EncryptionPermissionFlag.Decrypt).Equals(EncryptionPermissionFlag.Decrypt);canUseUserStore = (this._storePermFlag &StorePermissionFlag.User).Equals(StorePermissionFlag.User);canUseMachineStore = (this._storePermFlag &StorePermissionFlag.Machine).Equals(StorePermissionFlag.Machine);return ((canEncrypt && canDecrypt) &&(canUseUserStore && canUseMachineStore));}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!