Ejemplo n.º 1
0
        /// <summary>
        /// SPNG Client Packet API, which is to generate SpngInitialNegToken
        /// </summary>
        /// <param name="payloadType">An enum parameter, indicates the inner payload type,
        /// e.g. PayloadType.NegInit is for NegTokenInit</param>
        /// <param name="negotiationState">Indicate the negotation status, e.g. incomplete, completed.</param>
        /// <param name="mechToken">Binary mechToken byte array, or responseToken.
        /// This field could be null when the first time invoked.</param>
        /// <param name="mechListMIC">This field, if present, contains an MIC token for
        /// the mechanism list in the initial negotiation message.
        /// This field could be null.</param>
        /// <returns>SpngInitialNegToken2 packet</returns>
        /// <exception cref="ArgumentOutOfRangeException">PayloadType is not in scope. </exception>
        public SpngInitialNegToken CreateInitialNegToken(SpngPayloadType payloadType,
                                                         NegState negotiationState, byte[] mechToken, byte[] mechListMIC)
        {
            Asn1Object       asn1Element;
            NegotiationToken negToken;
            Asn1OctetString  asn10MechListMic = null;

            if (mechListMIC != null)
            {
                asn10MechListMic = new Asn1OctetString(mechListMIC);
            }

            switch (payloadType)
            {
            case SpngPayloadType.NegInit:
                asn1Element = new NegTokenInit(this.Config.MechList,
                                               this.Config.Asn1ContextAttributes,
                                               new Asn1.Asn1OctetString(mechToken),
                                               asn10MechListMic
                                               );
                // save the initial MechType list. Will be used when computing MechListMIC
                this.Context.InitMechTypeList = (asn1Element as NegTokenInit).mechTypes;
                negToken = new NegotiationToken(NegotiationToken.negTokenInit, asn1Element);
                break;

            default:
                //throw exception here
                throw new ArgumentOutOfRangeException("payloadType");
            }

            InitialNegToken intialToken = new InitialNegToken(new MechType(this.Config.SpngOidIntArray), negToken);

            return(new SpngInitialNegToken(intialToken));
        }
 public InitialNegToken(
  MechType spnegoMech,
  NegotiationToken negToken)
 {
     this.spnegoMech = spnegoMech;
     this.negToken = negToken;
 }
 public InitialNegToken(
     MechType spnegoMech,
     NegotiationToken negToken)
 {
     this.spnegoMech = spnegoMech;
     this.negToken = negToken;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// SPNG Client Packet API, which is to generate SpngNegotiationToken.
        /// </summary>
        /// <param name="payloadType">An enum parameter, indicates the inner payload type,
        /// e.g. PayloadType.NegInit is for NegTokenInit</param>
        /// <param name="negotiationState">Indicate the negotation status, e.g. incomplete, completed.</param>
        /// <param name="responseToken">Byte array of responseToken.
        /// This field could be null when the first time invoked.</param>
        /// <param name="mechListMIC">This field, if present, contains an MIC token for
        /// the mechanism list in the initial negotiation message.
        /// This field could be null.</param>
        /// <returns>SpngNegotiationToken packet</returns>
        /// <exception cref="ArgumentOutOfRangeException">PayloadType is not in scope. </exception>
        public SpngNegotiationToken CreateNegotiationToken(
            SpngPayloadType payloadType, NegState negotiationState, byte[] responseToken, byte[] mechListMIC)
        {
            NegotiationToken token;

            switch (payloadType)
            {
            case SpngPayloadType.NegResp:
                SpngNegTokenResp negResp = CreateNegTokenResp(negotiationState, responseToken, mechListMIC);
                token = new NegotiationToken(NegotiationToken.negTokenResp, negResp.Asn1Token);
                break;

            case SpngPayloadType.NegInit:
                NegTokenInit negInit = new NegTokenInit(
                    this.config.MechList,
                    SpngUtility.ConvertUintToContextFlags(this.config.ContextAttributes),
                    new Asn1OctetString(responseToken),
                    new Asn1OctetString(mechListMIC)
                    );
                token = new NegotiationToken(NegotiationToken.negTokenInit, negInit);
                break;

            default:
                throw new ArgumentOutOfRangeException("payloadType");
            }

            return(new SpngNegotiationToken(token));
        }
 public InitialNegToken()
 {
     this.spnegoMech = null;
     this.negToken = null;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// Generally used when encoding
 /// </summary>
 /// <param name="token">The Asn.1 formatted token contains in the class</param>
 public SpngNegotiationToken(NegotiationToken token)
     : base(token)
 {
 }