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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

812 <strong>Improving</strong> <strong>Web</strong> <strong>Application</strong> <strong>Security</strong>: <strong>Threats</strong> <strong>and</strong> Countermeasures(continued)if (target == null){if ((canEncrypt == false && canDecrypt == false) && (canUseMachineStore ==false && canUseUserStore == false))return true;elsereturn false;}if (!(target.GetType().Equals(this.GetType())))throw new ArgumentException("Argument must be of type EncryptionPermission.");// Cast the target to an EncryptionPermission.EncryptionPermission targetPerm = (EncryptionPermission)target;canTargetEncrypt = (targetPerm._permFlag &EncryptionPermissionFlag.Encrypt).Equals(EncryptionPermissionFlag.Encrypt);canTargetDecrypt = (targetPerm._permFlag &EncryptionPermissionFlag.Decrypt).Equals(EncryptionPermissionFlag.Decrypt);canTargetUseMachineStore = (targetPerm._storePermFlag &StorePermissionFlag.Machine).Equals(StorePermissionFlag.Machine);canTargetUseUserStore = (targetPerm._storePermFlag &StorePermissionFlag.User).Equals(StorePermissionFlag.User);// Every value set (true) in this permission must be in the target.// The following code checks to see if the current permission is a subset// of the target. If the current permission has something that the target// does not have, it cannot be a subset.if(canEncrypt == true && canTargetEncrypt == false)return false;if(canDecrypt == true && canTargetDecrypt == false)return false;if(canUseMachineStore == true && canTargetUseMachineStore == false)return false;if(canUseUserStore == true && canTargetUseUserStore == false)return false;}return true;14. Implement I<strong>Security</strong>Encodable.ToXml <strong>and</strong> FromXml. These methods convertinstances of a permission object into an XML format <strong>and</strong> vice-versa. Thesemethods are used to support serialization. This is used, for example, when thesecurity attribute is stored in assembly metadata.

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

Saved successfully!

Ooh no, something went wrong!