apache http client NafHttpAuthStrategyDefault

纵然是瞬间 提交于 2019-12-11 07:57:20

问题


When I was using apache http client on android, I got a suspicious message in logcat.

I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) NafHttpAuthStrategyDefault()
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    cached value : gbaSupportIsPossible=null
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    The current context is NOT a context of GBA service.
I/APACHE HTTP (thCr=2252) - GbaSupportPermissionRequestCheckerImpl(9949): (thUse=2252) isCurrentProcessRequestedGba()#finished   result=false
I/APACHE HTTP (thCr=2252) - GbaSupportPermissionRequestCheckerImpl(9949): (thUse=2252) isCurrentProcessAllowedToUseGba()#started   result=false
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252)    The GBA permission wasn't requested for this process.
I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) It is impossible to support GBA now (many possible reasons: no Android Context, current client is GBA service, etc.), then it will be just usual HTTP.
I/APACHE HTTP (thCr=2252) - NafRequestExecutorWrapperRedirectionHandler(9949): (thUse=2252)    It isn't GBA flow, redirection responses are not handled.

I just use like below:

HttpClient httpClient = new DefaultHttpClient();
HttpContext httpContext = new BasicHttpContext();

HttpPost postRequest = new HttpPost(url);
postRequest.addHeader("User-Agent", String.format("%s %s %s %s %s", Build.MANUFACTURER, Build.MODEL, Build.PRODUCT, Build.CPU_ABI, Config.appStr));

MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

reqEntity.addPart("sessionId", new StringBody(sessionId));

ByteArrayBody bab = new ByteArrayBody(afp, "afp");
reqEntity.addPart("afp", bab);

if (pcm != null)
{
    ByteArrayBody bab2 = new ByteArrayBody(pcm, "pcm");
    reqEntity.addPart("pcm", bab2);
}

postRequest.setEntity(reqEntity);

HttpResponse response = httpClient.execute(postRequest, httpContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String sResponse;
StringBuilder s = new StringBuilder();
while ((sResponse = reader.readLine()) != null) {
    s = s.append(sResponse);
    System.out.println(sResponse);
}

What is a meaning of the GBA Service? And how can I get the GBA permission? After getting the message, a thread to send this request looks like getting a exception and being stopped. I executed the code on Galaxy Notes.


回答1:


GBA - Generic Bootstrapping Architecture ( Authentication mechanism defined by 3GPP standard ) ... http://en.wikipedia.org/wiki/Generic_Bootstrapping_Architecture for more info.

On Galaxy Note ( I believe it is T-mobile version ), T-mobile modified APACHE HTTP Client to include GBA Client for Authentication over WiFi especially for MMS over WiFi.

Question is why do want to use GBA ? It is generally for authentication using ISIM keys and operator uses them for their services.

If you app is regular app , Your best bet is to stick with default android HTTP client and do not use Apache HTTP Client.




回答2:


Short version: Ignore the messages.

T-Mobile devices that support WiFi calling and some other features use the GSM mobile standard known as GBA to authenticate their service with T-Mobile. The messages in question are logging statements that say that your app isn't recognized as a T-Mobile app so GBA is not going to be advertised by in the request headers. The only difference you would see, if you did support GBA, would be the inclusion of "gba" in the user-agent header of your request.

If the server application your client is communicating with supports GBA then the developer should have a relationship with T-Mobile and can tell you how to enable GBA authentication in your application.




回答3:


I believe the GBA service you are referring to is described here: http://en.wikipedia.org/wiki/Generic_Bootstrapping_Architecture

I've had that message appear in my logs as well, but the network connection still completes successfully for me.

The one time I had an exception following that was when I was trying to make a network connection from the Main thread, which I believe is disallowed.




回答4:


You should change to HttpURLConnection, which is the preferred way to consume HTTP services. You can learn more about here:

http://android-developers.blogspot.com.br/2011/09/androids-http-clients.html




回答5:


It fixed after uninstalling the app, and installing it again!



来源:https://stackoverflow.com/questions/11840937/apache-http-client-nafhttpauthstrategydefault

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!