I have an ear project with war and ejb. Using omnifaces, I normally set the error message in the war project. But on one project I'm using picketlink for authentication, and unfortunately I need to move my #Picketlink annotated class inside the ejb, otherwise it won't work.
Then my authentication classes are also in the ejb project, then the problem when the user enter a wrong credential I need to show a localized error. How do I do that in the ejb project?
Or is there a way to make picketlink work moving the authentication classes back to the war project.
Sample codes:
Authentication class:
#PicketLink
public class PicketlinkAuthenticator extends BaseAuthenticator { }
JBoss deployment file
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<sub-deployment name="my-project-web.war">
<dependencies>
<module name="org.picketlink" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Thanks
I've found 2 solutions with my problem:
1.) Move the authentication classes (picketlink) to the web layer, so that the message can be set and localized.
2.) Implement a JPA IDMConfiguration in the ejb layer. And an authentication class in the web layer.
Refer to this project from github: picketlink-authorization-idm-jpa. In this way we've created a picketlink resource that we will use in web layer authentication.
Related
I have an existing application which is using the embedded jetty. Right now jetty has only one WebappContext and serving the files from a directory and also it has web.xml (which has spring security configuration in it)
Now I need to serve some static files using a new war.
What is the easy way to configure existing webappcontext to add a new resource base?
If I add new webappcontext how I can tell jetty to use existing web.xml and spring security?
The serving of static files is just the role of the DefaultServlet
See prior answer about that ...
https://stackoverflow.com/a/20223103/775715
As for the existing web.xml and spring security question, the WebAppContext's are, by design, and by the nature of the servlet spec, isolated from each other.
If you want a single spring security configuration that applies for both webapps, you'll need to setup/install CAS.
I'm trying to split ASP MVC areas into separate applications within New Relic.
Within each area I have created a new web.config file that simply contains the below XML. This doesn't seem to be creating a new application like I would expect it to.
It works when it is in the root web.config. I don't have this key in the root config of this MVC application, however.
Any help would be appreciated - otherwise it might just be something that cannot be done?
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="NewRelic.AppName" value="My Area Name" />
</appSettings>
</configuration>
The New Relic .NET agent can only gather settings from a web.config file in the app root. Unfortunately, there isn't a way to set NewRelic.AppName on the fly using the API or specify a path for per-app config files. You might write into support#newrelic.com and submit a feature request.
I currently use my own Dependency Injection framework. It is extremely lightweight and does the job, however I am looking to do Aspect Oriented Programming and need something better. I am testing Castle Windsor because of it's capability to do proxy-based runtime interception.
I wrote a simple MVC application using Castle Windsor installing from web.config and it works fine. The problem is that I had to register each controller individually. In an application with a lot of controllers, this will become tedious.
web.config
<castle>
<components>
<component id="LoggerInterceptor" type="MvcApp.LoggerInterceptor, MvcApp" lifestyle="Singleton"/>
<component Name="AccountController" type="MvcApp.Controllers.AccountController, MvcApp" lifestyle="Transient">
<interceptors>
<interceptor>${LoggerInterceptor}</interceptor>
</interceptors>
</component>
<component Name="HomeController" type="MvcApp.Controllers.HomeController, MvcApp" lifestyle="Transient">
<interceptors>
<interceptor>${LoggerInterceptor}</interceptor>
</interceptors>
</component>
</components>
</castle>
Using the Fluent Registration API method of registration, it is possible to register all of the controllers in a single line of code. Unfortunately, this completely defeats the purpose of using runtime proxies. If I want my AOP configuration to compile with my code, I will use something like PostSharp which does compile time weaving.
Fluent Registration API
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Classes.FromThisAssembly()
.BasedOn<IController>()
.LifestyleTransient()
.Configure((c => c.LifeStyle.Transient.Interceptors<LogInterceptor>())));
}
I will always be registering my controllers so having that in code is not an issue, however I will want to determine what dependencies, parameters and interceptors are used via config.
So ...
Is there a way to register all of the controllers via web.config with a single component element?
Or
Is there a way to mix the configurations such that the controllers are registered via code, but their interceptors are done in the web.config?
Is there a way to register all of the controllers via web.config with
a single component element?
I guees not
Is there a way to mix the configurations such that the controllers are
registered via code, but everything else is done in the web.config?
Sure. Let say you have one of your controller depending on a specific service.
You can register all your controllers via Fluent api as you did and register that single service explicitly in the config.
Just keep in mind what you register in the config will be registered first int the container.
Order registration is relevant only in case of multiple registration for same interface, not for resolution itself.
I'm writing a Grails app which I'd like 3rd parties to augment at runtime. Ideally they would be able to add a JAR/WAR to the webapp directory which contains new domain, controller and service classes, new views, and other content.
Is there a simple way to do this within grails? Would it be simplest to create a startup script which copies the new classes etc. into the relevant directories and then updates grails.xml and web.xml?
You will be able to do this in version 2 of grails in which plugins will be also OSGI plugins http://jira.codehaus.org/browse/GRAILS/fixforversion/15421
It seems that the Grails plugins will actually fit quite well for this: http://www.grails.org/Understanding+Plugins
A plugin can do just about anything... One thing a plugin cannot do though is modify the web-app/WEB-INF/web.xml or web-app/WEB-INF/applicationContext.xml files. A plugin can participate in web.xml generation, but not modify the file or provide a replacement. A plugin can NEVER change the applicationContext.xml file, but can provide runtime bean definitions
I have to use Sync Framework 2.0 in our WPF app that will contain SQL Compact 3.5 and will synchronize with SQL Server 2008.
I followed this video : http://download.microsoft.com/download/6/7/3/6730f0e7-a649-4656-96ab-150c7501a583/IntroToSyncServicesADODetNet_HighQuality.wmv.
But instead DataSet I've used EntityFramework 4.0 and C#.
I'm very interested in code auto generation by adding Local Database Cache file with extension sync. It is great, and I can modify code in my partial class to change base functionality.
Everything works grate when I have code for client and server place in WPF application.
Everything works grate when I use WCF Class Library that contains server synchronization logic.
But... In the following example they show us how to run solution and host WCF in local "WCF Host" only on my computer.
The first question is:
"How can I create instance of class from WCF Class Library that contains all server synchronization logic and then host it and expose in ASP.NET MVC 2.0 application."
The most important thing is to keep this *.sync files and don't write all the code manually it gives me the option to automatically update this code when database schema would change.
The second question is:
"How can I configure endpoints and behaviors for this instance of WCF Class Library in my web.config when it has its on app.config in class library?..."
Unfortunately wizard for *.sync files only sees local WPF application, or WCF Class Library, I can't choose directly ASP.NET MVC 2.0 (it would be great) to generate class for synchronization in web app.
I would be very pleased to see working example.
Regards,
Daniel Skowroński
Solution to create WCF Class Library instance with synchronization logic hosted in ASP.NET MVC 2.0:
follow http://download.microsoft.com/download/6/7/3/6730f0e7-a649-4656-96ab-150c7501a583/IntroToSyncServicesADODetNet_HighQuality.wmv to create WCF Class Library
create ASP.NET MVC 2.0 App and add WCF Service
delete C# file *.cs behind *.svc
add Project Referece from ASP.NET projet to WCF Class Library
edit your *.svc file in ASP.NET
here you will see something like:
<%# ServiceHost Language="C#" Debug="true" Service="namespace-assembly.class" CodeBehind="filename.svc.cs" %>
where Service is Factory method that will create instance of "namespace-assembly.class" so, you have to change this to "wcf_librrary_namespace-assembly.****DataCacheSyncService" and CodeBehind to "wcf_librrary_namespace-assembly.filename.cs"
next modify wcf instance in WCF Class Library that will enable hosting it with the same credentials as asp.net app, simply add : [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] attribute
next configure web.config:
<service name="asp.net-namespace.wcf_service_name" behaviorConfiguration="service_nameBehavior">
<host>
<baseAddresses>
<add baseAddress="http://ipaddres/asp.net-app-name/service-name.svc" />
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="basicHttpBinding" contract="wcf_librrary_namespace assembly.I****DataCacheSyncContract" />
</service>
<behavior name="service_nameBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
add also
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
below
<system.serviceModel>
now simply publish it to your server and create ASP.NET app
now add Service Reference to your Client Application
here we have problem that when you will execute:
**DataCacheSyncAgent syncAgent = new **DataCacheSyncAgent(new **DataCacheSyncContractClient());
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
You will probably get Exception: “Cannot convert type ** to Microsoft.Synchronization.Data.SyncGroupMetadata, One solution to resolve this issue for now that I’ve found is to expand your service reference and b CTR+H rename all “asp-net-assembly-SyncGroupMetadata” and other similar files to “Microsoft.Synchronization.Data.SyncGroupMetadata” etc.
Now synchronization should start
HTH
Regards,
Daniel Skowroński