void Page_Load(object sender, EventArgs e) { login_required(); btnSignIn.Text = L_SubmitLabel_Text; btnCancel.Text = L_CancelLabel_Text; if (Page.IsPostBack) { return; } String deliveryMethod = (string)Session["Delivery"]; RADIUSAttributes atts = new RADIUSAttributes(); if (deliveryMethod != null) { deliveryLabel.Text = deliveryMethod; VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, deliveryMethod); vsa.SetRADIUSAttribute(ref atts); } RADIUSClient client = new RADIUSClient(radiusServer, 1812, radiusSecret); RADIUSPacket response = client.Authenticate(username, password, atts); if (response == null) { Session["Message"] = "No response from RADIUS server"; logoff(); } onRadiusResponse(response); }
// Check validity of token (radius session id) by authenticating against // the RADIUS server // // Called when clicking on applications // // Returns 401 if not valid protected void Page_Load(object sender, EventArgs e) { username = (string)Session["DomainUserName"]; HttpCookie tokenCookie = Request.Cookies["RadiusSessionId"]; if (tokenCookie == null) { throw new HttpException(401, "Token required"); } token = tokenCookie.Value; VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, "LAUNCH"); RADIUSAttributes atts = new RADIUSAttributes(); vsa.SetRADIUSAttribute(ref atts); try { RADIUSPacket response = radiusClient.Authenticate(username, token, atts); if (response.Code == RadiusPacketCode.AccessAccept) { Response.Write("Ready to launch application. Granted access!"); } else { throw new HttpException(401, "Token is no longer valid!"); } } catch (Exception ex) { throw new HttpException(500, "Exception! failure. " + ex.Message); } }
/// <summary> /// Adds a Radius attribute to this packet. Can also be used /// to add Vendor-Specific sub-attributes. If a attribute with /// a vendor code != -1 is passed in, a VendorSpecificAttribute /// is created for the sub-attribute. /// @param attribute RadiusAttribute object /// </summary> public void AddAttribute(RadiusAttribute attribute) { if (attribute == null) { throw new ArgumentNullException("attribute", "attribute is null"); } attribute.Dictionary = Dictionary; if (attribute.VendorId == -1) { _attributes.Add(attribute); } else { var vsa = new VendorSpecificAttribute(attribute.VendorId); vsa.AddSubAttribute(attribute); _attributes.Add(vsa); } }
// Check validity of token (radius session id) by authenticating against // the RADIUS server // // Called when clicking on applications // // Returns 401 if not valid protected void Page_Load(object sender, EventArgs e) { string username = (string)Session["DomainUserName"]; HttpCookie tokenCookie = Request.Cookies["RadiusSessionId"]; // This must not be cached - we rely on this page being called on every application // start attempt in order to open the launch window. Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetMaxAge(TimeSpan.Zero); if (tokenCookie == null) { throw new HttpException(401, "Token required"); } string token = tokenCookie.Value; VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, "LAUNCH"); RADIUSAttributes atts = new RADIUSAttributes(); vsa.SetRADIUSAttribute(ref atts); try { RADIUSPacket response = _radiusClient.Authenticate(username, token, atts); if (response.Code == RadiusPacketCode.AccessAccept) { Response.Write("Ready to launch application. Granted access!"); } else { throw new HttpException(401, "Token is no longer valid!"); } } catch (Exception ex) { throw new HttpException(500, "Exception! failure. " + ex.Message); } }
/// <summary> /// Adds a Radius attribute to this packet. Can also be used /// to add Vendor-Specific sub-attributes. If a attribute with /// a vendor code != -1 is passed in, a VendorSpecificAttribute /// is created for the sub-attribute. /// @param attribute RadiusAttribute object /// </summary> public void AddAttribute(RadiusAttribute attribute) { if (attribute == null) throw new ArgumentNullException("attribute", "attribute is null"); attribute.Dictionary = Dictionary; if (attribute.VendorId == -1) _attributes.Add(attribute); else { var vsa = new VendorSpecificAttribute(attribute.VendorId); vsa.AddSubAttribute(attribute); _attributes.Add(vsa); } }
void Page_Load(object sender, EventArgs e) { login_required(); btnSignIn.Text = L_SubmitLabel_Text; btnCancel.Text = L_CancelLabel_Text; if (Page.IsPostBack){ return; } String deliveryMethod = (string)Session["Delivery"]; RADIUSAttributes atts = new RADIUSAttributes(); if (deliveryMethod != null){ deliveryLabel.Text = deliveryMethod; VendorSpecificAttribute vsa = new VendorSpecificAttribute(VendorSpecificType.Generic, deliveryMethod); vsa.SetRADIUSAttribute(ref atts); } RADIUSClient client = new RADIUSClient(radiusServer, 1812, radiusSecret); RADIUSPacket response = client.Authenticate(username, password, atts); if (response == null) { Session["Message"] = "No response from RADIUS server"; logoff(); } onRadiusResponse(response); }