private Parser(Tokenizer t) { _t = t; _doc = null; ParseContents(); }
private void ParseContents() { TokenizerStream stream = new TokenizerStream(); this._t.GetTokens(stream, 2, false); stream.Reset(); int format = this.DetermineFormat(stream); stream.GoToPosition(format); this._t.GetTokens(stream, -1, false); stream.Reset(); int index = 0; this.GetRequiredSizes(stream, ref index); this._doc = new SecurityDocument(index); int position = 0; stream.Reset(); for (short nextFullToken = stream.GetNextFullToken(); (int)nextFullToken != -1; nextFullToken = stream.GetNextFullToken()) { if (((int)nextFullToken & 16384) == 16384) { switch ((short)((int)nextFullToken & 65280)) { case 17408: this._doc.AddToken((byte)4, ref position); continue; case 20480: stream.ThrowAwayNextString(); continue; case 25344: this._doc.AppendString(" ", ref position); this._doc.AppendString(stream.GetNextString(), ref position); continue; case 16640: this._doc.AddToken((byte)1, ref position); this._doc.AddString(stream.GetNextString(), ref position); continue; case 16896: this._doc.AddToken((byte)2, ref position); this._doc.AddString(stream.GetNextString(), ref position); this._doc.AddString(stream.GetNextString(), ref position); continue; case 17152: this._doc.AddToken((byte)3, ref position); this._doc.AddString(stream.GetNextString(), ref position); continue; default: throw new XmlSyntaxException(); } } } }
internal void FromXml(SecurityDocument doc, int position, PolicyLevel level, bool allowInternalOnly) { if (doc == null) { throw new ArgumentNullException("doc"); } if (!doc.GetTagForElement(position).Equals("PolicyStatement")) { throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), (object)"PolicyStatement", (object)this.GetType().FullName)); } this.m_attributes = PolicyStatementAttribute.Nothing; string attributeForElement = doc.GetAttributeForElement(position, "Attributes"); if (attributeForElement != null) { this.m_attributes = (PolicyStatementAttribute)Enum.Parse(typeof(PolicyStatementAttribute), attributeForElement); } lock (this) { this.m_permSet = (PermissionSet)null; if (level != null) { string local_3 = doc.GetAttributeForElement(position, "PermissionSetName"); if (local_3 != null) { this.m_permSet = (PermissionSet)level.GetNamedPermissionSetInternal(local_3); if (this.m_permSet == null) { this.m_permSet = new PermissionSet(PermissionState.None); } } } if (this.m_permSet == null) { ArrayList local_4 = doc.GetChildrenPositionForElement(position); int local_5 = -1; for (int local_6 = 0; local_6 < local_4.Count; ++local_6) { if (doc.GetTagForElement((int)local_4[local_6]).Equals("PermissionSet")) { local_5 = (int)local_4[local_6]; } } if (local_5 == -1) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } string local_7 = doc.GetAttributeForElement(local_5, "class"); this.m_permSet = local_7 == null || !local_7.Equals("NamedPermissionSet") && !local_7.Equals("System.Security.NamedPermissionSet") ? new PermissionSet(PermissionState.None) : (PermissionSet) new NamedPermissionSet("DefaultName", PermissionState.None); this.m_permSet.FromXml(doc, local_5, allowInternalOnly); } if (this.m_permSet != null) { return; } this.m_permSet = new PermissionSet(PermissionState.None); } }
private Parser(Tokenizer t) { this._t = t; this._doc = (SecurityDocument)null; try { this.ParseContents(); } finally { this._t.Recycle(); } }
private Parser(Tokenizer t) { this._t = t; this._doc = null; try { this.ParseContents(); } finally { this._t.Recycle(); } }
private Parser(Tokenizer t) { _t = t; _doc = null; try { ParseContents(); } finally { _t.Recycle(); } }
private void AddDocuments() { DocumentInfo documentInfo1 = new DocumentInfo { Id = "DINFO1", Creator = this.UserDatas.Find("U1"), Status = DocumentStatus.Executing, Date = DateTime.Now, Details = "Empty details...", Notes = "123 -> zyx", PhoneNumber = "11354897", Planned = true, }; DocumentInfo documentInfo2 = new DocumentInfo { Id = "DINFO2", Creator = this.UserDatas.Find("U1"), Status = DocumentStatus.Issued, Date = DateTime.Now.AddDays(1).AddHours(15), Details = "Detailed description", Notes = "blabla", PhoneNumber = "0021545", Planned = false, }; SecurityDocument sd1 = new SecurityDocument() { Id = "SD1", DocumentInfo = documentInfo1, }; SecurityDocument sd2 = new SecurityDocument() { Id = "SD2", DocumentInfo = documentInfo2, }; this.DocumentInfoes.Add(documentInfo2); this.DocumentInfoes.Add(documentInfo1); this.SecurityDocuments.Add(sd2); this.SecurityDocuments.Add(sd1); this.SaveChanges(); }
public async Task <IActionResult> AddDocument(bool planned, string datetime, string details, string notes, string phoneNumber, string createdBy, bool workOperationsCompleted, bool tagsRemoved, bool groundingRemoved, bool ready) { /* * int count = _context.PlanoviRadaTB.Count() + 1; * string plID = count.ToString(); * PlanRada pl = new PlanRada(plID, userid, createdby, DateTime.Parse(datecreated), company, tipnacemu, DateTime.Parse(startdate), DateTime.Parse(enddate), tiprada, phoneno, "", "", "", adresa, svrha, detalji, beleske); * pl.Status = status; * pl.UserID = userid; * _context.Add(pl); * await _context.SaveChangesAsync(); */ DocumentInfo info = new DocumentInfo(); SecurityDocument newDoc = new SecurityDocument(); try { string DId = "SD_" + datetime; info.Id = "Info_" + DId; info.Creator = _context.UserDatas.Find(createdBy); info.Date = DateTime.Parse(datetime); info.Status = DocumentStatus.Draft; info.Details = details; info.Notes = notes; info.PhoneNumber = phoneNumber; info.Planned = planned; newDoc.Id = DId; newDoc.DocumentInfo = info; _context.DocumentInfoes.Add(info); _context.SecurityDocuments.Add(newDoc); await _context.SaveChangesAsync(); } catch { } return(Ok()); }
internal void FromXml(SecurityDocument doc, int position, PolicyLevel level, bool allowInternalOnly) { if (doc == null) { throw new ArgumentNullException("doc"); } if (!doc.GetTagForElement(position).Equals("PolicyStatement")) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), "PolicyStatement", this.GetType().FullName)); } m_attributes = (PolicyStatementAttribute)0; String strAttributes = doc.GetAttributeForElement(position, "Attributes"); if (strAttributes != null) { m_attributes = (PolicyStatementAttribute)Enum.Parse(typeof(PolicyStatementAttribute), strAttributes); } lock (this) { m_permSet = null; if (level != null) { String permSetName = doc.GetAttributeForElement(position, "PermissionSetName"); if (permSetName != null) { m_permSet = level.GetNamedPermissionSetInternal(permSetName); if (m_permSet == null) { m_permSet = new PermissionSet(PermissionState.None); } } } if (m_permSet == null) { // There is no provided level, it is not a named permission set, or // the named permission set doesn't exist in the provided level, // so just create the class through reflection and decode normally. ArrayList childPositions = doc.GetChildrenPositionForElement(position); int positionPermissionSet = -1; for (int i = 0; i < childPositions.Count; ++i) { if (doc.GetTagForElement((int)childPositions[i]).Equals("PermissionSet")) { positionPermissionSet = (int)childPositions[i]; } } if (positionPermissionSet != -1) { String className = doc.GetAttributeForElement(positionPermissionSet, "class"); if (className != null && (className.Equals("NamedPermissionSet") || className.Equals("System.Security.NamedPermissionSet"))) { m_permSet = new NamedPermissionSet("DefaultName", PermissionState.None); } else { m_permSet = new PermissionSet(PermissionState.None); } m_permSet.FromXml(doc, positionPermissionSet, allowInternalOnly); } else { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } } if (m_permSet == null) { m_permSet = new PermissionSet(PermissionState.None); } } }
[System.Security.SecurityCritical] // auto-generated private void Cache (int count, byte[] serializedEvidence, PolicyStatement policy) { if (m_configId == ConfigId.None) return; if (serializedEvidence == null) return; byte[] policyArray = new SecurityDocument(policy.ToXml(null, true)).m_data; Config.AddCacheEntry(m_configId, count, serializedEvidence, policyArray); }
internal SecurityDocumentElement(SecurityDocument document, int position) { this.m_document = document; this.m_position = position; }
private void ParseContents() { short i; TokenizerStream stream = new TokenizerStream(); _t.GetTokens(stream, 2, false); stream.Reset(); int gotoPosition = DetermineFormat(stream); stream.GoToPosition(gotoPosition); _t.GetTokens(stream, -1, false); stream.Reset(); int neededIndex = 0; GetRequiredSizes(stream, ref neededIndex); _doc = new SecurityDocument(neededIndex); int position = 0; stream.Reset(); for (i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken()) { if ((i & c_flag) != c_flag) { continue; } else { switch ((short)(i & 0xFF00)) { case c_elementtag: _doc.AddToken(SecurityDocument.c_element, ref position); _doc.AddString(stream.GetNextString(), ref position); break; case c_attributetag: _doc.AddToken(SecurityDocument.c_attribute, ref position); _doc.AddString(stream.GetNextString(), ref position); _doc.AddString(stream.GetNextString(), ref position); break; case c_texttag: _doc.AddToken(SecurityDocument.c_text, ref position); _doc.AddString(stream.GetNextString(), ref position); break; case c_additionaltexttag: _doc.AppendString(" ", ref position); _doc.AppendString(stream.GetNextString(), ref position); break; case c_childrentag: _doc.AddToken(SecurityDocument.c_children, ref position); break; case c_wastedstringtag: stream.ThrowAwayNextString(); break; default: throw new XmlSyntaxException("error"); } } } }
private void GetRequiredSizes(TokenizerStream stream, ref int index) { bool needToBreak = false; bool needToPop = false; bool createdNode = false; bool intag = false; int stackDepth = 1; SecurityElementType type = SecurityElementType.Regular; String strValue = null; bool sawEquals = false; bool sawText = false; int status = 0; short i; do { for (i = stream.GetNextToken(); i != -1; i = stream.GetNextToken()) { switch (i & 0x00FF) { case Tokenizer.cstr: { if (intag) { if (type == SecurityElementType.Comment) { // Ignore data in comments but still get the data // to keep the stream in the right place. stream.ThrowAwayNextString(); stream.TagLastToken(c_wastedstringtag); } else { // We're in a regular tag, so we've found an attribute/value pair. if (strValue == null) { // Found attribute name, save it for later. strValue = stream.GetNextString(); } else { // Found attribute text, add the pair to the current element. if (!sawEquals) { throw new XmlSyntaxException(_t.LineNo); } stream.TagLastToken(c_attributetag); index += SecurityDocument.EncodedStringSize(strValue) + SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; strValue = null; sawEquals = false; } } } else { // We're not in a tag, so we've found text between tags. if (sawText) { stream.TagLastToken(c_additionaltexttag); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" "); } else { stream.TagLastToken(c_texttag); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; sawText = true; } } } break; case Tokenizer.bra: intag = true; sawText = false; i = stream.GetNextToken(); if (i == Tokenizer.slash) { stream.TagLastToken(c_childrentag); while (true) { // spin; don't care what's in here i = stream.GetNextToken(); if (i == Tokenizer.cstr) { stream.ThrowAwayNextString(); stream.TagLastToken(c_wastedstringtag); } else if (i == -1) { throw new XmlSyntaxException("XMLSyntax_UnexpectedEndOfFile"); } else { break; } } if (i != Tokenizer.ket) { throw new XmlSyntaxException("XMLSyntax_ExpectedCloseBracket"); } intag = false; // Found the end of this element index++; sawText = false; stackDepth--; needToBreak = true; } else if (i == Tokenizer.cstr) { // Found a child createdNode = true; stream.TagLastToken(c_elementtag); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; if (type != SecurityElementType.Regular) { throw new XmlSyntaxException(_t.LineNo); } needToBreak = true; stackDepth++; } else if (i == Tokenizer.bang) { // Found a child that is a comment node. Next up better be a cstr. status = 1; do { i = stream.GetNextToken(); switch (i) { case Tokenizer.bra: status++; break; case Tokenizer.ket: status--; break; case Tokenizer.cstr: stream.ThrowAwayNextString(); stream.TagLastToken(c_wastedstringtag); break; default: break; } } while (status > 0); intag = false; sawText = false; needToBreak = true; } else if (i == Tokenizer.quest) { // Found a child that is a format node. Next up better be a cstr. i = stream.GetNextToken(); if (i != Tokenizer.cstr) { throw new XmlSyntaxException(_t.LineNo); } createdNode = true; type = SecurityElementType.Format; stream.TagLastToken(c_elementtag); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; status = 1; stackDepth++; needToBreak = true; } else { throw new XmlSyntaxException("XMLSyntax_ExpectedSlashOrString"); } break; case Tokenizer.equals: sawEquals = true; break; case Tokenizer.ket: if (intag) { intag = false; continue; } else { throw new XmlSyntaxException("XMLSyntax_UnexpectedCloseBracket"); } // not reachable case Tokenizer.slash: i = stream.GetNextToken(); if (i == Tokenizer.ket) { // Found the end of this element stream.TagLastToken(c_childrentag); index++; stackDepth--; sawText = false; needToBreak = true; } else { throw new XmlSyntaxException("XMLSyntax_ExpectedCloseBracket"); } break; case Tokenizer.quest: if (intag && type == SecurityElementType.Format && status == 1) { i = stream.GetNextToken(); if (i == Tokenizer.ket) { stream.TagLastToken(c_childrentag); index++; stackDepth--; sawText = false; needToBreak = true; } else { throw new XmlSyntaxException("XMLSyntax_ExpectedCloseBracket"); } } else { throw new XmlSyntaxException(_t.LineNo); } break; case Tokenizer.dash: default: throw new XmlSyntaxException(_t.LineNo); } if (needToBreak) { needToBreak = false; needToPop = false; break; } else { needToPop = true; } } if (needToPop) { index++; stackDepth--; sawText = false; } else if (i == -1 && (stackDepth != 1 || !createdNode)) { // This means that we still have items on the stack, but the end of our // stream has been reached. throw new XmlSyntaxException("XMLSyntax_UnexpectedEndOfFile"); } }while (stackDepth > 1); }
private void GetRequiredSizes(TokenizerStream stream, ref int index) { bool flag1 = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; int num1 = 1; SecurityElementType securityElementType = SecurityElementType.Regular; string str = (string)null; bool flag5 = false; bool flag6 = false; int num2 = 0; do { short nextToken; for (nextToken = stream.GetNextToken(); (int)nextToken != -1; nextToken = stream.GetNextToken()) { switch ((int)nextToken & (int)byte.MaxValue) { case 0: flag4 = true; flag6 = false; nextToken = stream.GetNextToken(); switch (nextToken) { case 2: stream.TagLastToken((short)17408); while (true) { nextToken = stream.GetNextToken(); switch (nextToken) { case 3: stream.ThrowAwayNextString(); stream.TagLastToken((short)20480); continue; case -1: goto label_18; case 1: goto label_20; default: goto label_19; } } label_18: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); label_19: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); label_20: flag4 = false; ++index; flag6 = false; --num1; flag1 = true; break; case 3: flag3 = true; stream.TagLastToken((short)16640); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; if (securityElementType != SecurityElementType.Regular) { throw new XmlSyntaxException(this._t.LineNo); } flag1 = true; ++num1; break; case 6: num2 = 1; do { nextToken = stream.GetNextToken(); switch (nextToken) { case 0: ++num2; break; case 1: --num2; break; case 3: stream.ThrowAwayNextString(); stream.TagLastToken((short)20480); break; } }while (num2 > 0); flag4 = false; flag6 = false; flag1 = true; break; case 5: nextToken = stream.GetNextToken(); if ((int)nextToken != 3) { throw new XmlSyntaxException(this._t.LineNo); } flag3 = true; securityElementType = SecurityElementType.Format; stream.TagLastToken((short)16640); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; num2 = 1; ++num1; flag1 = true; break; default: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString")); } case 1: if (!flag4) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket")); } flag4 = false; continue; case 2: nextToken = stream.GetNextToken(); if ((int)nextToken != 1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); } stream.TagLastToken((short)17408); ++index; --num1; flag6 = false; flag1 = true; break; case 3: if (flag4) { if (securityElementType == SecurityElementType.Comment) { stream.ThrowAwayNextString(); stream.TagLastToken((short)20480); break; } if (str == null) { str = stream.GetNextString(); break; } if (!flag5) { throw new XmlSyntaxException(this._t.LineNo); } stream.TagLastToken((short)16896); index += SecurityDocument.EncodedStringSize(str) + SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; str = (string)null; flag5 = false; break; } if (flag6) { stream.TagLastToken((short)25344); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" "); break; } stream.TagLastToken((short)17152); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; flag6 = true; break; case 4: flag5 = true; break; case 5: if (!flag4 || securityElementType != SecurityElementType.Format || num2 != 1) { throw new XmlSyntaxException(this._t.LineNo); } nextToken = stream.GetNextToken(); if ((int)nextToken != 1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); } stream.TagLastToken((short)17408); ++index; --num1; flag6 = false; flag1 = true; break; default: throw new XmlSyntaxException(this._t.LineNo); } if (flag1) { flag1 = false; flag2 = false; break; } flag2 = true; } if (flag2) { ++index; --num1; flag6 = false; } else if ((int)nextToken == -1 && (num1 != 1 || !flag3)) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); } }while (num1 > 1); }
private void GetRequiredSizes(TokenizerStream stream, ref int index) { bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; int num = 1; SecurityElementType regular = SecurityElementType.Regular; string nextString = null; bool flag5 = false; bool flag6 = false; int num2 = 0; do { short nextToken = stream.GetNextToken(); while (nextToken != -1) { switch ((nextToken & 0xff)) { case 0: flag4 = true; flag6 = false; nextToken = stream.GetNextToken(); if (nextToken != 2) { goto Label_01BD; } stream.TagLastToken(0x4400); while (true) { nextToken = stream.GetNextToken(); if (nextToken != 3) { break; } stream.ThrowAwayNextString(); stream.TagLastToken(0x5000); } if (nextToken == -1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); } if (nextToken != 1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); } flag4 = false; index++; flag6 = false; num--; flag = true; goto Label_03BD; case 1: if (!flag4) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket")); } flag4 = false; goto Label_03C8; case 2: nextToken = stream.GetNextToken(); if (nextToken != 1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); } stream.TagLastToken(0x4400); index++; num--; flag6 = false; flag = true; goto Label_03BD; case 3: if (!flag4) { goto Label_00D1; } if (regular != SecurityElementType.Comment) { break; } stream.ThrowAwayNextString(); stream.TagLastToken(0x5000); goto Label_03BD; case 4: flag5 = true; goto Label_03BD; case 5: if ((!flag4 || (regular != SecurityElementType.Format)) || (num2 != 1)) { throw new XmlSyntaxException(this._t.LineNo); } nextToken = stream.GetNextToken(); if (nextToken != 1) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); } stream.TagLastToken(0x4400); index++; num--; flag6 = false; flag = true; goto Label_03BD; default: throw new XmlSyntaxException(this._t.LineNo); } if (nextString == null) { nextString = stream.GetNextString(); } else { if (!flag5) { throw new XmlSyntaxException(this._t.LineNo); } stream.TagLastToken(0x4200); index += (SecurityDocument.EncodedStringSize(nextString) + SecurityDocument.EncodedStringSize(stream.GetNextString())) + 1; nextString = null; flag5 = false; } goto Label_03BD; Label_00D1: if (flag6) { stream.TagLastToken(0x6300); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" "); } else { stream.TagLastToken(0x4300); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; flag6 = true; } goto Label_03BD; Label_01BD: if (nextToken == 3) { flag3 = true; stream.TagLastToken(0x4100); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; if (regular != SecurityElementType.Regular) { throw new XmlSyntaxException(this._t.LineNo); } flag = true; num++; } else if (nextToken == 6) { num2 = 1; do { nextToken = stream.GetNextToken(); switch (nextToken) { case 0: num2++; break; case 1: num2--; break; case 3: stream.ThrowAwayNextString(); stream.TagLastToken(0x5000); break; } }while (num2 > 0); flag4 = false; flag6 = false; flag = true; } else { if (nextToken != 5) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString")); } nextToken = stream.GetNextToken(); if (nextToken != 3) { throw new XmlSyntaxException(this._t.LineNo); } flag3 = true; regular = SecurityElementType.Format; stream.TagLastToken(0x4100); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; num2 = 1; num++; flag = true; } Label_03BD: if (flag) { flag = false; flag2 = false; break; } flag2 = true; Label_03C8: nextToken = stream.GetNextToken(); } if (flag2) { index++; num--; flag6 = false; } else if ((nextToken == -1) && ((num != 1) || !flag3)) { throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); } }while (num > 1); }
[System.Security.SecurityCritical] // auto-generated private PolicyStatement CheckCache (int count, byte[] serializedEvidence) { if (m_configId == ConfigId.None) return null; if (serializedEvidence == null) return null; byte[] cachedValue; if (!Config.GetCacheEntry(m_configId, count, serializedEvidence, out cachedValue)) return null; PolicyStatement cachedSet = new PolicyStatement(); SecurityDocument doc = new SecurityDocument(cachedValue); cachedSet.FromXml(doc, 0, null, true); return cachedSet; }
private void ParseContents() { short i; TokenizerStream stream = new TokenizerStream(); _t.GetTokens( stream, 2, false ); stream.Reset(); int gotoPosition = DetermineFormat( stream ); stream.GoToPosition( gotoPosition ); _t.GetTokens( stream, -1, false ); stream.Reset(); int neededIndex = 0; GetRequiredSizes( stream, ref neededIndex ); _doc = new SecurityDocument( neededIndex ); int position = 0; stream.Reset(); for (i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken()) { if ((i & c_flag) != c_flag) continue; else { switch((short)(i & 0xFF00)) { case c_elementtag: _doc.AddToken( SecurityDocument.c_element, ref position ); _doc.AddString( stream.GetNextString(), ref position ); break; case c_attributetag: _doc.AddToken( SecurityDocument.c_attribute, ref position ); _doc.AddString( stream.GetNextString(), ref position ); _doc.AddString( stream.GetNextString(), ref position ); break; case c_texttag: _doc.AddToken( SecurityDocument.c_text, ref position ); _doc.AddString( stream.GetNextString(), ref position ); break; case c_additionaltexttag: _doc.AppendString( " ", ref position ); _doc.AppendString( stream.GetNextString(), ref position ); break; case c_childrentag: _doc.AddToken( SecurityDocument.c_children, ref position ); break; case c_wastedstringtag: stream.ThrowAwayNextString(); break; default: throw new XmlSyntaxException(); } } } }
private void ParseContents() { TokenizerStream stream = new TokenizerStream(); this._t.GetTokens(stream, 2, false); stream.Reset(); int position = this.DetermineFormat(stream); stream.GoToPosition(position); this._t.GetTokens(stream, -1, false); stream.Reset(); int index = 0; this.GetRequiredSizes(stream, ref index); this._doc = new SecurityDocument(index); int num4 = 0; stream.Reset(); for (short i = stream.GetNextFullToken(); i != -1; i = stream.GetNextFullToken()) { if ((i & 0x4000) == 0x4000) { switch (((short)(i & 0xff00))) { case 0x4400: { this._doc.AddToken(4, ref num4); continue; } case 0x5000: { stream.ThrowAwayNextString(); continue; } case 0x6300: { this._doc.AppendString(" ", ref num4); this._doc.AppendString(stream.GetNextString(), ref num4); continue; } case 0x4100: { this._doc.AddToken(1, ref num4); this._doc.AddString(stream.GetNextString(), ref num4); continue; } case 0x4200: { this._doc.AddToken(2, ref num4); this._doc.AddString(stream.GetNextString(), ref num4); this._doc.AddString(stream.GetNextString(), ref num4); continue; } case 0x4300: { this._doc.AddToken(3, ref num4); this._doc.AddString(stream.GetNextString(), ref num4); continue; } } throw new XmlSyntaxException(); } } }
internal void FromXml(SecurityDocument doc, int position, PolicyLevel level, bool allowInternalOnly) { if (doc == null) { throw new ArgumentNullException("doc"); } if (!doc.GetTagForElement(position).Equals("PolicyStatement")) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), new object[] { "PolicyStatement", base.GetType().FullName })); } this.m_attributes = PolicyStatementAttribute.Nothing; string attributeForElement = doc.GetAttributeForElement(position, "Attributes"); if (attributeForElement != null) { this.m_attributes = (PolicyStatementAttribute)Enum.Parse(typeof(PolicyStatementAttribute), attributeForElement); } lock (this) { this.m_permSet = null; if (level != null) { string name = doc.GetAttributeForElement(position, "PermissionSetName"); if (name != null) { this.m_permSet = level.GetNamedPermissionSetInternal(name); if (this.m_permSet == null) { this.m_permSet = new System.Security.PermissionSet(PermissionState.None); } } } if (this.m_permSet == null) { ArrayList childrenPositionForElement = doc.GetChildrenPositionForElement(position); int num = -1; for (int i = 0; i < childrenPositionForElement.Count; i++) { if (doc.GetTagForElement((int)childrenPositionForElement[i]).Equals("PermissionSet")) { num = (int)childrenPositionForElement[i]; } } if (num == -1) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } string str3 = doc.GetAttributeForElement(num, "class"); if ((str3 != null) && (str3.Equals("NamedPermissionSet") || str3.Equals("System.Security.NamedPermissionSet"))) { this.m_permSet = new NamedPermissionSet("DefaultName", PermissionState.None); } else { this.m_permSet = new System.Security.PermissionSet(PermissionState.None); } this.m_permSet.FromXml(doc, num, allowInternalOnly); } if (this.m_permSet == null) { this.m_permSet = new System.Security.PermissionSet(PermissionState.None); } } }
// Token: 0x06002B97 RID: 11159 RVA: 0x000A3388 File Offset: 0x000A1588 private void GetRequiredSizes(TokenizerStream stream, ref int index) { bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; int num = 1; SecurityElementType securityElementType = SecurityElementType.Regular; string text = null; bool flag5 = false; bool flag6 = false; int num2 = 0; for (;;) { short nextToken = stream.GetNextToken(); while (nextToken != -1) { switch (nextToken & 255) { case 0: flag4 = true; flag6 = false; nextToken = stream.GetNextToken(); if (nextToken == 2) { stream.TagLastToken(17408); for (;;) { nextToken = stream.GetNextToken(); if (nextToken != 3) { break; } stream.ThrowAwayNextString(); stream.TagLastToken(20480); } if (nextToken == -1) { goto Block_9; } if (nextToken != 1) { goto Block_10; } flag4 = false; index++; flag6 = false; num--; flag = true; goto IL_3B9; } else if (nextToken == 3) { flag3 = true; stream.TagLastToken(16640); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; if (securityElementType != SecurityElementType.Regular) { goto Block_12; } flag = true; num++; goto IL_3B9; } else { if (nextToken == 6) { num2 = 1; do { nextToken = stream.GetNextToken(); switch (nextToken) { case 0: num2++; break; case 1: num2--; break; case 3: stream.ThrowAwayNextString(); stream.TagLastToken(20480); break; } }while (num2 > 0); flag4 = false; flag6 = false; flag = true; goto IL_3B9; } if (nextToken != 5) { goto IL_2B3; } nextToken = stream.GetNextToken(); if (nextToken != 3) { goto Block_17; } flag3 = true; securityElementType = SecurityElementType.Format; stream.TagLastToken(16640); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; num2 = 1; num++; flag = true; goto IL_3B9; } break; case 1: if (flag4) { flag4 = false; goto IL_3C4; } goto IL_2E0; case 2: nextToken = stream.GetNextToken(); if (nextToken == 1) { stream.TagLastToken(17408); index++; num--; flag6 = false; flag = true; goto IL_3B9; } goto IL_329; case 3: if (flag4) { if (securityElementType == SecurityElementType.Comment) { stream.ThrowAwayNextString(); stream.TagLastToken(20480); goto IL_3B9; } if (text == null) { text = stream.GetNextString(); goto IL_3B9; } if (!flag5) { goto Block_5; } stream.TagLastToken(16896); index += SecurityDocument.EncodedStringSize(text) + SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; text = null; flag5 = false; goto IL_3B9; } else { if (flag6) { stream.TagLastToken(25344); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + SecurityDocument.EncodedStringSize(" "); goto IL_3B9; } stream.TagLastToken(17152); index += SecurityDocument.EncodedStringSize(stream.GetNextString()) + 1; flag6 = true; goto IL_3B9; } break; case 4: flag5 = true; goto IL_3B9; case 5: if (!flag4 || securityElementType != SecurityElementType.Format || num2 != 1) { goto IL_397; } nextToken = stream.GetNextToken(); if (nextToken == 1) { stream.TagLastToken(17408); index++; num--; flag6 = false; flag = true; goto IL_3B9; } goto IL_37C; } goto Block_1; IL_3C4: nextToken = stream.GetNextToken(); continue; IL_3B9: if (flag) { flag = false; flag2 = false; break; } flag2 = true; goto IL_3C4; } if (flag2) { index++; num--; flag6 = false; } else if (nextToken == -1 && (num != 1 || !flag3)) { goto IL_3F5; } if (num <= 1) { return; } } Block_1: goto IL_3A8; Block_5: throw new XmlSyntaxException(this._t.LineNo); Block_9: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); Block_10: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); Block_12: throw new XmlSyntaxException(this._t.LineNo); Block_17: throw new XmlSyntaxException(this._t.LineNo); IL_2B3: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedSlashOrString")); IL_2E0: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedCloseBracket")); IL_329: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); IL_37C: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_ExpectedCloseBracket")); IL_397: throw new XmlSyntaxException(this._t.LineNo); IL_3A8: throw new XmlSyntaxException(this._t.LineNo); IL_3F5: throw new XmlSyntaxException(this._t.LineNo, Environment.GetResourceString("XMLSyntax_UnexpectedEndOfFile")); }