Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

alabax

@alabax
About
Posts
12
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Web-service enforced authentication
    A alabax

    To use the http authentication one has to override the GetWebRequest function and append http authorization header as follows: using System; using System.Collections.Generic; using System.Text; using System.Web.Services.Protocols; using System.Net; namespace WindowsApplication1.WebServiceAPI { public class WebServiceAPIAuth : WebServiceAPI { public string UserName; public string Password; private string S2Base(string s) { byte [] ba; ba=Encoding.ASCII.GetBytes(s); return Convert.ToBase64String(ba); } protected override System.Net.WebRequest GetWebRequest(Uri uri) { CredentialCache cc = new CredentialCache(); WebRequest wr = base.GetWebRequest(uri); wr.Headers.Add(HttpRequestHeader.Authorization, "Basic "+S2Base(UserName+':'+Password)); return wr; } } }

    Web Development csharp java security json tutorial

  • Web-service enforced authentication
    A alabax

    Hello! I have large Java application, which is controlled through web-services. Some functions are available for anonymous users, it works ok. Some functions are only for authenticated users. The service expects login credentials in the http request. The following .net code using System; using System.Net; class Program { static void Main(string[] args) { WebServiceX.SomeAPI api = new WebServiceX.SomeAPI.SomeAPI(); api.Credentials = new NetworkCredential("MyUserName", "MyPassword"); api.PreAuthenticate = true; api.Url = "http://mysite/myapp/api"; api.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap11; api.someMethod(parameter); } } throws an exception: System.Web.Services.Protocols.SoapException: java.rmi.RemoteException: ---omitted---: CLQAHDEBUG: Permission Denied : User anonymous does not have permission ---internal method name--- in System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClien tMessage message, WebResponse response, Stream responseStream, Boolean asyncCall ) in System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodNa me, Object[] parameters) in WebServicesConsumer2.LMSRoster.LMSRosterAPI.unrosterUsers(String[] in0) in .\WebServicesConsumer2\Web References\LMSRoster\Reference.cs:line 1 31 in WebServicesConsumer2.Program.Main(String[] args) in .\WebService sConsumer2\Program.cs:line 19 Captured communication packets do not contain any credential data. Why? How to make it work?

    Web Development csharp java security json tutorial

  • difflib for .net
    A alabax

    Python has library 'difflib' which can be used to find coincidence percent between two sequences (strings). I am looking for the way to do the same (compare 2 strings) within .net platform. So what is the name for an algorithm I am looking for? And where to look for it?

    C# question csharp python algorithms

  • vector<bool> can't convert to 'bool*'?
    A alabax

    Scott Meyers in his book "Effective STL" says vector is not really vector - it's a bitset and it uses proxy when you try to address an element. You cannot use it like an array. :( Try different element type instead.

    ATL / WTL / STL help graphics question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    I mean questions like this appear every month on the newsgroups and message boards. =)

    ATL / WTL / STL c++ tutorial question

  • Converting a wstring to UTF8?
    A alabax

    In the Microsoft stl libraries, localization uses C interface. The locale class calls setlocale function. And it cannot work with UTF-8. From the Remarks section on the setlocale function reference: "The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API (except code pages that require more than two bytes per character, like UTF-8)."

    ATL / WTL / STL question c++ com

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    Ok, here comes cute solution :) wstring s2w(const string &s,const locale &loc=global_locale) { size_t l=s.length(); vector pw(l+1); use_facet>(loc).widen(&s[0],&s[l],&pw[0]); wstring ws(&pw[0]); return ws; } widen does not append trailing L'\0'! The question is: does vector always initialize values to 0?

    ATL / WTL / STL c++ tutorial question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    locale global_locale; wstring s2w(const string &s,const locale &loc=global_locale) { size_t l=s.length()+1; const char *pc=s.c_str(); wchar_t *pw=new wchar_t[l]; if (pw==0) throw; use_facet>(loc).widen(pc,pc+l-1,pw); pw[l-1]=L'\0'; wstring ws(pw); delete [] pw; return ws; }

    ATL / WTL / STL c++ tutorial question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    OMG! It's such a shame I did new without delete ;) GC is deep in my mind! wstring s2w(const string &s) { size_t l=s.size()+1; const char *pc=s.c_str(); wchar_t *pw=new wchar_t[l]; if (pw==0) throw; locale loc(""); use_facet>(loc).widen(pc,pc+l-1,pw); wstring ws(pw); delete [] pw; return ws; }

    ATL / WTL / STL c++ tutorial question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    like this: wstring s2w(const string &s) { size_t l=s.size()+1; const char *pc=s.c_str(); wchar_t *pw=new wchar_t[l]; locale loc(""); use_facet>(loc).widen(pc,pc+l-1,pw); return wstring(pw); } -- modified at 14:03 Wednesday 12th April, 2006

    ATL / WTL / STL c++ tutorial question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    that's the only ;)

    ATL / WTL / STL c++ tutorial question

  • How to convert string to wstring by means of STL and C++ headers only?
    A alabax

    Yeah once again about it! I know, there is a way to do it using crt function mbstowcs. The first thing I do not like about it I have single-byte character string (in the cp1251 encoding for example). The second it's not about stl.

    ATL / WTL / STL c++ tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups