Which event to handle in HttpModule for setting the current principal when dealing with providers? - events

I am facing a problem where I have to integrate with a custom HttpModule where the principal and identity are set on the current thread so that HttpContext.Current.User contains these. However I get the feeling that the eventhandler they used (PostAcquireRequestState) is way too late.
Which is the best event to handle before the initialization of the providers happen in the HttpModule? All I want is my custom provider to work with the correct principal and identity.

This is probably best done in the PostAuthenticateRequest event. ASP.NET assumes that after this event the security information is stable.

Related

Disallow user to make a call when there are no more credits: Sinch Javascript SDK

My application allows unlimited instant messages for free, but takes credits for calls. I want to be able to disallow user to make a call when he does not have any more credits. How in a ideal scenario is this managed using javascript SDK?
I am coming from a standpoint, that although I am able to control this behavior through some validations in code itself, but what happens when the user is a hacker? He can go to console and call javascript methods of its own such as removeListeners and then callClient.callUser(userId). How do you protect sinchClient in such case? Thanks.
Note: I am open to provide more information if the question is not clear.
Sinch exposes a REST based callback mechanism to control your call flow. You can set a callback URL in the Sinch Portal under Applications >> Voice and Video settings. Each call will then trigger a Incoming Call Event (documented here: https://www.sinch.com/docs/voice/rest/#callbackapi) and you can control whether or not to connect this call via the callback response.

Glympse API event handling

I am trying to launch glympse app by using an intent and receiving the information through broadcast. Is there any way that I will be notified about the events occurring like ticket removed, expired, updated etc?
There sure is.
We created a library project to make this easier for you. It can be found here: https://github.com/Glympse/glympse-app-sdk/tree/master/Android/GlympseIntentsLib
A sign-in is required to view these documents that might be helpful.
Tutorial: https://developer.glympse.com/Content/client/app/guides/Glympse_Intents_Tutorial.html
Reference Docs: https://developer.glympse.com/Content/client/app/guides/Glympse_Intents_Reference.html
Specifically, check out the method CreateGlympseParams.setCallbackAction(String). This will allow you to set an action which will be used to broadcast a message back to your app.
Another option is to use CreateGlympseParams.setEventsListener(EventsListener). With this method, you can supply an object that implements GlympseApp.EventsListener. Using this method, our library handles the broadcast under the covers and your object's methods will be invoked as the event occur.

Is it possible to access Controller/Action attributes from a Message Handler?

Is there a practical way to access the attributes decorating a controller or action from a Message Handler/ DelegatingHandler?
From the diagram on Pedro Felix's blog entry, it looks like Message Handler's are too early in the pipeline and the info won't be available until the Controller Dispatcher Message Handler runs. Correct?
About my use case:
I'm working with the Thinktecture identity model, and it would be useful to be able to look for the AllowAnonymous attribute in the AuthenticationHandler.
By nature, this seems to be the wrong place to implement it. As you have noted, Message Handlers work across all requests and responses. If you depend on an attribute, this would naturally be a filter. So I suggest you follow that route.
In fact in the handler you cannot assume there is going to an ApiController or an action. Handlers can be equally used on clients.

Implementation of a message service in ASP.NET MVC

I have an infrastructure, bussiness rules and other logic, that I use in a WPF application, in it I have a messaging service that implements an message service interface, this service is register in a Container, I use Castle Windsor.
Every time that the infrastructure needs to show any kind of messages it uses this service and shows a message and waits for the reply, with this I don't have to a request to the GUI/WPF to show a message.
My problem is that I'm using this same infrastructure for a ASP.NET MVC site and I having some problems in find a solution where I can use this same interface. Basically if the message service has to show a messages it should be able to post a message box in the browser, preferably via AJAX and wait for the reply of the user and then continue the execution according to the answer.
I don't know if I'm made my self clear enough on the problem.
Any hints on how to implement such a service would be much appreciated.
Thanks.
The problem is the server knows nothing about open browsers, therefore it can't signal the broswer to show the message.
The solution would appear to be to queue messages from the service, have some script on the page that checks (using ajax) for items in the queue, and display messages as appropriate.

Implementing a two-way communication between Microsoft Dynamics CRM and 3rd party app

I need to implement a bi-directional communication between Microsoft Dynamics CRM and a 3rd party server. The ideal scenario is as follows:
User tries to create an entity in CRM
In pre-create hook a 3rd party library function is called (or web service or whatever), filled with relevant info, which tries to create the respective entity on the server
If the call fails, creation fails in CRM
If the call succeeds, the entity is created in the CRM AND additional fields are filled with return values from the call
More specifically, I want to do something like this when user tries to create a new entity instance:
try {
ExternalWebService.CreateTrade(ref TradeInfo info)
//this was initialized on the external server
myCRM_Trade_Entity.SerialNo = info.SerialNo;
CreateNew(myCRM_Trade_Entity);
} catch (whatever) {
fail;
}
What would be the suggested way to do this? I am new to Dynamics, have read about Workflows and Plugins but am not sure how should I do this properly.
The way to do that is obviously a plugin, except if the process called by the web service is very long and could timeout.
The only way to avoid creating an entity, is to create a plugin and hook it on the pre-create event, like you are saying.
When using a workflow, the entity must be saved before the workflow is executed.
I think you are on the good way. I would, however, avoid including a library, the webservice solution should be better, because it does not required to register other libraries before registering the plugin assembly.

Resources