상속: Asn1Object
예제 #1
0
        public DebugParameter(Asn1Tagged dseObject)
        {
            switch ((DebugParameterType)(dseObject.getIdentifier().Tag))
              {
              case DebugParameterType.ENTRYID:
              case DebugParameterType.INTEGER:
            objData = getTaggedIntValue(dseObject);
            break;

              case DebugParameterType.BINARY:
            objData = ((Asn1OctetString) dseObject.taggedValue()).byteValue();
            break;

              case DebugParameterType.STRING:
            objData = ((Asn1OctetString) dseObject.taggedValue()).stringValue();
            break;

              case DebugParameterType.TIMESTAMP:
            objData = new DSETimeStamp(getTaggedSequence(dseObject));
            break;

              case DebugParameterType.TIMEVECTOR:
            ArrayList timeVector = new ArrayList();
            Asn1Sequence seq = getTaggedSequence(dseObject);
            int count = ((Asn1Integer) seq.get_Renamed(0)).intValue();
            if (count > 0)
            {
              Asn1Sequence timeSeq = (Asn1Sequence) seq.get_Renamed(1);

              for (int i = 0; i < count; i++)
              {
            timeVector.Add(new DSETimeStamp((Asn1Sequence) timeSeq.get_Renamed(i)));
              }
            }

            objData = timeVector;
            break;

              case DebugParameterType.ADDRESS:
            objData = new ReferralAddress(getTaggedSequence(dseObject));
            break;

              default:
            throw new IOException("Unknown Tag in DebugParameter..");
              }

              debug_type = (DebugParameterType)(dseObject.getIdentifier().Tag);
        }
예제 #2
0
        /// <summary> Encode an Asn1Tagged directly into the specified outputstream.</summary>
        public void Encode(Asn1Tagged t, Stream outRenamed)
        {
            if (t.Explicit)
            {
                Encode(t.GetIdentifier(), outRenamed);

                /* determine the encoded length of the base type. */
                var encodedContent = new MemoryStream();
                t.TaggedValue.Encode(this, encodedContent);

                EncodeLength((int)encodedContent.Length, outRenamed);
                var array = encodedContent.ToArray();
                outRenamed.Write(array, 0, array.Length);
            }
            else
            {
                t.TaggedValue.Encode(this, outRenamed);
            }
        }
예제 #3
0
        /// <summary> Encode an Asn1Tagged directly into the specified outputstream.</summary>
        public void encode(Asn1Tagged t, Stream out_Renamed)
        {
            if (t.Explicit)
            {
                encode(t.getIdentifier(), out_Renamed);

                /* determine the encoded length of the base type. */
                MemoryStream encodedContent = new MemoryStream();
                t.taggedValue().encode(this, encodedContent);

                encodeLength((int)encodedContent.Length, out_Renamed);
                sbyte[] temp_sbyteArray;
                temp_sbyteArray = SupportClass.ToSByteArray(encodedContent.ToArray());
                out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);
            }
            else
            {
                t.taggedValue().encode(this, out_Renamed);
            }
        }
예제 #4
0
		//*************************************************************************
		// Constructors for AuthenticationChoice
		//*************************************************************************
		
		/// <summary> </summary>
		public RfcAuthenticationChoice(Asn1Tagged choice):base(choice)
		{
		}
예제 #5
0
		/// <summary> Encode an Asn1Tagged directly into the specified outputstream.</summary>
		public void  encode(Asn1Tagged t, System.IO.Stream out_Renamed)
		{
			if (t.Explicit)
			{
				encode(t.getIdentifier(), out_Renamed);
				
				/* determine the encoded length of the base type. */
				System.IO.MemoryStream encodedContent = new System.IO.MemoryStream();
				t.taggedValue().encode(this, encodedContent);
				
				encodeLength((int)encodedContent.Length, out_Renamed);
				sbyte[] temp_sbyteArray;
				temp_sbyteArray = SupportClass.ToSByteArray(encodedContent.ToArray());
				out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;;
			}
			else
			{
				t.taggedValue().encode(this, out_Renamed);
			}
			return ;
		}
예제 #6
0
        protected Asn1Sequence getTaggedSequence(Asn1Tagged tagVal)
        {
            Asn1Object obj = tagVal.taggedValue();
              byte[] dataBytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue());

              MemoryStream decodedData = new MemoryStream(dataBytes);
              LBERDecoder decoder = new LBERDecoder();

              return new Asn1Sequence(decoder, decodedData, dataBytes.Length);
        }
예제 #7
0
        protected int getTaggedIntValue(Asn1Tagged tagVal)
        {
            Asn1Object obj = tagVal.taggedValue();
              byte[] dataBytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue());

              MemoryStream decodedData = new MemoryStream(dataBytes);
              LBERDecoder decoder = new LBERDecoder();

              return ((int) decoder.decodeNumeric(
                decodedData,
                dataBytes.Length));
        }
예제 #8
0
        /// <summary> RFC 2254 filter helper method. Will Parse a filter component.</summary>
        private Asn1Tagged parseFilterComp()
        {
            Asn1Tagged tag = null;
            int filterComp = ft.OpOrAttr;

            switch (filterComp)
            {

                case AND:
                case OR:
                    tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterComp), parseFilterList(), false);
                    break;

                case NOT:
                    tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterComp), parseFilter(), true);
                    break;

                default:
                    int filterType = ft.FilterType;
                    System.String value_Renamed = ft.Value;

                    switch (filterType)
                    {

                        case GREATER_OR_EQUAL:
                        case LESS_OR_EQUAL:
                        case APPROX_MATCH:
                            tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, filterType), new RfcAttributeValueAssertion(new RfcAttributeDescription(ft.Attr), new RfcAssertionValue(unescapeString(value_Renamed))), false);
                            break;

                        case EQUALITY_MATCH:
                            if (value_Renamed.Equals("*"))
                            {
                                // present
                                tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, PRESENT), new RfcAttributeDescription(ft.Attr), false);
                            }
                            else if (value_Renamed.IndexOf((System.Char) '*') != - 1)
                            {
                                // substrings parse:
                                //    [initial], *any*, [final] into an Asn1SequenceOf
                                SupportClass.Tokenizer sub = new SupportClass.Tokenizer(value_Renamed, "*", true);
            //								SupportClass.Tokenizer sub = new SupportClass.Tokenizer(value_Renamed, "*");//, true);
                                Asn1SequenceOf seq = new Asn1SequenceOf(5);
                                int tokCnt = sub.Count;
                                int cnt = 0;

                                System.String lastTok = new System.Text.StringBuilder("").ToString();

                                while (sub.HasMoreTokens())
                                {
                                    System.String subTok = sub.NextToken();
                                    cnt++;
                                    if (subTok.Equals("*"))
                                    {
                                        // if previous token was '*', and since the current
                                        // token is a '*', we need to insert 'any'
                                        if (lastTok.Equals(subTok))
                                        {
                                            // '**'
                                            seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, ANY), new RfcLdapString(unescapeString("")), false));
                                        }
                                    }
                                    else
                                    {
                                        // value (RfcLdapString)
                                        if (cnt == 1)
                                        {
                                            // initial
                                            seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, INITIAL), new RfcLdapString(unescapeString(subTok)), false));
                                        }
                                        else if (cnt < tokCnt)
                                        {
                                            // any
                                            seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, ANY), new RfcLdapString(unescapeString(subTok)), false));
                                        }
                                        else
                                        {
                                            // final
                                            seq.add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, FINAL), new RfcLdapString(unescapeString(subTok)), false));
                                        }
                                    }
                                    lastTok = subTok;
                                }

                                tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, SUBSTRINGS), new RfcSubstringFilter(new RfcAttributeDescription(ft.Attr), seq), false);
                            }
                            else
                            {
                                // simple
                                tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EQUALITY_MATCH), new RfcAttributeValueAssertion(new RfcAttributeDescription(ft.Attr), new RfcAssertionValue(unescapeString(value_Renamed))), false);
                            }
                            break;

                        case EXTENSIBLE_MATCH:
                            System.String type = null, matchingRule = null;
                            bool dnAttributes = false;
            //							SupportClass.Tokenizer st = new StringTokenizer(ft.Attr, ":", true);
                            SupportClass.Tokenizer st = new SupportClass.Tokenizer(ft.Attr, ":");//, true);

                            bool first = true;
                            while (st.HasMoreTokens())
                            {
                                System.String s = st.NextToken().Trim();
                                if (first && !s.Equals(":"))
                                {
                                    type = s;
                                }
                                // dn must be lower case to be considered dn of the Entry.
                                else if (s.Equals("dn"))
                                {
                                    dnAttributes = true;
                                }
                                else if (!s.Equals(":"))
                                {
                                    matchingRule = s;
                                }
                                first = false;
                            }

                            tag = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EXTENSIBLE_MATCH), new RfcMatchingRuleAssertion(((System.Object) matchingRule == null)?null:new RfcMatchingRuleId(matchingRule), ((System.Object) type == null)?null:new RfcAttributeDescription(type), new RfcAssertionValue(unescapeString(value_Renamed)), (dnAttributes == false)?null:new Asn1Boolean(true)), false);
                            break;
                        }
                    break;

            }
            return tag;
        }
예제 #9
0
 /// <summary> Creates and addes a substrings filter component.
 /// 
 /// startSubstrings must be immediatly followed by at least one
 /// {@link #addSubstring} method and one {@link #endSubstrings} method
 /// @throws Novell.Directory.Ldap.LdapLocalException
 /// Occurs when this component is created out of sequence.
 /// </summary>
 public virtual void startSubstrings(System.String attrName)
 {
     finalFound = false;
     Asn1SequenceOf seq = new Asn1SequenceOf(5);
     Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, SUBSTRINGS), new RfcSubstringFilter(new RfcAttributeDescription(attrName), seq), false);
     addObject(current);
     SupportClass.StackPush(filterStack, seq);
     return ;
 }
예제 #10
0
 /// <summary> Creates and adds the Asn1Tagged value for a nestedFilter: AND, OR, or
 /// NOT.
 /// 
 /// Note that a Not nested filter can only have one filter, where AND
 /// and OR do not
 /// 
 /// </summary>
 /// <param name="rfcType">Filter type:
 /// [AND | OR | NOT]
 /// @throws Novell.Directory.Ldap.LdapLocalException
 /// </param>
 public virtual void startNestedFilter(int rfcType)
 {
     Asn1Object current;
     if (rfcType == AND || rfcType == OR)
     {
         current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), new Asn1SetOf(), false);
     }
     else if (rfcType == NOT)
     {
         current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), null, true);
     }
     else
     {
         throw new LdapLocalException("Attempt to create a nested filter other than AND, OR or NOT", LdapException.FILTER_ERROR);
     }
     addObject(current);
     return ;
 }
예제 #11
0
 /// <summary> Creates and adds a present matching to the filter.
 /// 
 /// </summary>
 /// <param name="attrName">Name of the attribute to check for presence.
 /// @throws LdapLocalException
 /// Occurs if addPresent is called out of sequence.
 /// </param>
 public virtual void addPresent(System.String attrName)
 {
     Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, false, PRESENT), new RfcAttributeDescription(attrName), false);
     addObject(current);
     return ;
 }
예제 #12
0
 public virtual void addExtensibleMatch(System.String matchingRule, System.String attrName, sbyte[] value_Renamed, bool useDNMatching)
 {
     Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, EXTENSIBLE_MATCH), new RfcMatchingRuleAssertion(((System.Object) matchingRule == null)?null:new RfcMatchingRuleId(matchingRule), ((System.Object) attrName == null)?null:new RfcAttributeDescription(attrName), new RfcAssertionValue(value_Renamed), (useDNMatching == false)?null:new Asn1Boolean(true)), false);
     addObject(current);
     return ;
 }
예제 #13
0
 public virtual void addAttributeValueAssertion(int rfcType, System.String attrName, sbyte[] value_Renamed)
 {
     if (filterStack != null && !(filterStack.Count == 0) && filterStack.Peek() is Asn1SequenceOf)
     {
         //If a sequenceof is on the stack then substring is left on the stack
         throw new LdapLocalException("Cannot insert an attribute assertion in a substring", LdapException.FILTER_ERROR);
     }
     if ((rfcType != EQUALITY_MATCH) && (rfcType != GREATER_OR_EQUAL) && (rfcType != LESS_OR_EQUAL) && (rfcType != APPROX_MATCH))
     {
         throw new LdapLocalException("Invalid filter type for AttributeValueAssertion", LdapException.FILTER_ERROR);
     }
     Asn1Object current = new Asn1Tagged(new Asn1Identifier(Asn1Identifier.CONTEXT, true, rfcType), new RfcAttributeValueAssertion(new RfcAttributeDescription(attrName), new RfcAssertionValue(value_Renamed)), false);
     addObject(current);
     return ;
 }
예제 #14
0
 public FilterIterator(RfcFilter enclosingInstance, Asn1Tagged root)
 {
     InitBlock(enclosingInstance);
     this.root = root;
 }
예제 #15
0
        protected string getTaggedStringValue(Asn1Tagged tagvalue, GeneralEventField tagid)
        {
            Asn1Object obj = tagvalue.taggedValue();

              if ((int)tagid != tagvalue.getIdentifier().Tag)
              {
            throw new IOException("Unknown Tagged Data");
              }

              byte[] dbytes = SupportClass.ToByteArray(((Asn1OctetString) obj).byteValue());
              MemoryStream data = new MemoryStream(dbytes);

              LBERDecoder dec = new LBERDecoder();

              int length = dbytes.Length;

              return (string) dec.decodeCharacterString(data, length);
        }