How to avoid auto horizontal scrolling in Eclipse

Windows Vista/7 have introduced a new feature called dynamic multi-dimensional scrolling. I’ve found it pretty annoying as a developer when the full path of code files can be quite long in which it triggers the auto horizontal scrolling in eclipse.

Couple of months ago, I’ve found a work around to disable this feature in Windows 7.

The trick was to change the Compatibility Mode for eclipse.exe to Windows XP.

*Note: If you don’t want to apply the compatibility change all the time. You may create a Windows shortcut to eclipse.exe, and apply the compatibility update on the shortcut file.

, , , , ,

No Comments

Mono doesn't support LINQ to Entity framework

Recently, I’ve stopped paying for the Windows VPS hosting service for one of my projects – mobochats.com. I’d like to find a free hosting service that can support the following:

  • .NET 3.5
  • LINQ to Entity
  • SQL Server

It turned out that Somee.com facilitates these criteria very well! The only thing that I didn’t like was the forced advertisements which screwed up some of the html styles on the iPhone portion of the application.

Then, I’ve tried two other free ASP.NET hosting services – 0000free.com and HelioHost.org. The two services are very similar. Both used Mono/Apache for running ASP.NET web applications. The only problem is that they didn’t support SQL Server, but instead, they provided free MySQL hosting (which was not surprising).

I started with some initial porting from SQL Server to MySQL. The first milestone that I want to make sure is that LINQ to Entity for MySQL works on the server. After writing a simple proof-of-concept application and published through front page extension, I found that System.Data.Entity wasn’t supported by Mono. This is out of the development plan on the Mono webpage. Thus, I’d need to explore other options such as LINQ to nHibernate with MySQL.

, , ,

2 Comments

SSIS Consume Web Service with Complex Types (GAC Avoided solution)

This blog explains the easiest method SSIS can consume web service methods consist of complex types as the request or response parameters.

If a web service method consist of complex types as the request or response parameters, we can’t use the build-in Web Service Task. Although, there are posts online where we can consume it programmatically within VSA (Script Task).

Since we can’t directly add Web Reference from the VSA editor, some people suggested to build a separate library project that make the web service calls, and let the VGA from SSIS reference this library. The problem with this solution is that the built library would have to be registered to GAC on server running the SSIS package. This may sometimes be policatically difficult epecially when the package is being executed by SQL Server Agent. We wouldn’t want to install library to GAC on a SQL Server machine for just making a web service call.

In order to avoid going down the path to touch GAC, what we can do is to use the WSDL.exe tool to generate the proxy class and import this class into the Script Task code, and consume the web service from there.

Proxy Class Generation

  1. Please open Visual Studio Command Prompt. It should located under “Visual Studio Tools” subfolder in the Start Menu.
  2. cd into an empty directory and type in the following command
    • wsdl http://Domain/WebServiceURL?wsdl /l:vb

Import Proxy Class to VSA editor

  1. Add a new Script Task, and go into the Design Script window
  2. Add a new class under the Script Task project
  3. Copy and paste all the content from the generated class to this new added class file
  4. This is optional, you may wrap this class into a namespace to make it cleaner.

Consuming the service

We may now consume the web service by instantiating the client object. In order for the script knows which endpoint the client is calling, you may need to set the end point manually like this:

, , , ,

No Comments

VS 2008 File Finder with Wildcard Character Search

I’ve been working with Eclipse for almost too long. The Open Resource window has been a very convenient tool to me. After doing some quick googling, I’ve found that there’s a VS plugin written by Steve Huff that does almost the same thing as Eclipse’s Open Resource Window. It works very smooth and very easy to install! Please check out the official website here: http://www.huffs.us/blogEngine/page/VS-2008-File-Finder.aspx

The only one thing I also want in this File Finder plugin is the Wildcard Search function. So I’ve downloaded the code and made some simple adjustments.

The changes are made in the ProjectItemFinder.vb class:

vsFileFinder_001

The highlighted code was added by me. It’s for calling a new method which is similar to the existing MatchString function.

vsFileFinder_003

This new method WildcardMatchString simply uses the Like function to do wildcard character match.

Now VS 2008 File Finder now supports Wildcard search!!!

vsFileFinder_004

I would not post the new compiled plugin library here while I’m not the originally author. If you’d like to use File Finder with Wildcard Character Search like me, please download the source code from Steve Huff’s website and make the small modifications described above.

, , , , , ,

1 Comment

Escape and Unescape functions for Javascript and ASP.NET

I’ve been working on a chatroom application that requires some AJAX calls to submit messages from user input. Usually, when you want to pass string parameters into the web service, you may do something like this:

escapeDemo_002

This jQuery script calls an asp.net web service method called submitMessage with two parameters sessionIdStr and messageText. The source of parameter messageText is from a input textbox. Since the user may enter any characters (including special characters), and if they have a single quote (‘) in their input, the above statement will break. To resolve this problem, we can simply make use of the escape and unescape functions from javascript.

escapeDemo_003

The escape javascript function simply encode a string to remove all the special characters in order to ensure that messageText parameter is transmitted successfully within the ajax call. For more information about this function, click here.

Now that our messageText paramter can passed successfully to the web service, we may need to do an unscape operation within the web service method to revert it back to the original input. Microsoft has provided us with a very handy library in namescape Microsoft.JScript.GlobalObject.

escapeDemo_004

Now we have the messageText parameter revert back to the original message. We may do our handling code accordingly.

Note that both Javascript and Micorosft.JScript.GlobalObject has escape and unscape operations, you may use the combination in the reverse way (within web service response).

This is it for this short tutorial. Recently, I’ve been dealing with the .NET System.Datetime and Javascript Date conversion, when I have sometime, I’ll share my experience with you here!

, , , , , ,

No Comments

iPhone Game Programming Tutorial Suggested Link

I’ve been trying to study the development API for iPhone for awhile now. I wasn’t able to find a good one until yesterday.
This one from iCodeBlog is very awesome! The author Brandon Trebitowski has written a very detail Introductory tutorial to iPhone development. I find it very useful!

Part one explains basic use of xCode and Interface Builder. He also demonstrated some basic game design framework.
Part two talks about user interactions.
Part three discusses about putting a Splash screen to an applicaiton.

, , ,

No Comments

SQL Server Integration Service Package Elevation Tips

When developing SSIS package, very often, the development environment is different from the testing environment as well as the production environment. Different environment would probably have different connection strings for different connections. They can be database connection string, flat file location path etc. To make elevation easier, connection information under Connection Manager are designed to be configurable when the package is being registered under SQL Agent. Moreover, initial value of the variables can also can configure when attaching the package as part of the SQL job.

In the blog, I’ll show you some How to deploy SSIS packages for SQL Agent to execute with custom configuration.
I’ve created a simple SSIS package that take a global variable “env” and write it to a csv file along with a timestamp obtain from a database. Here’s a copy of the dtsx for download: demo.dtsx

Job Creation

When creating a job to execute a SSIS package, you can either use the GUI from SQL Server Management Studio or by SQL query. I usually use the graphic interface first, then extract it as a SQL script and modify it from there. Let’s try it out together!

Open Microsoft SQL Server Management Studio and connect to the database instance where you want the job to be located. Once connected, under SQL Server Agent, right click on jobs and choose to create a new job. After entering a job name and the owner name, hit “Step” on the left menu bar and click on the “New” button for a new step.

On the Job Step Property screen, choose SQL Server Integration Service Package for type and File System for package source. Note that we’re using File System in this demo for simplicity, however, you may save the package into the ssis package store on SQL Server and select the package from there.

ssisDemo_001

My database instance is localhost, so I simply reference the package as local file on the system. If the database instance you connects to is not your localhost, you can simply create a network share and reference your dtsx file like: \\yourhostname\shareName\demo.dtsx.

Please note that the job we’re setting right now is purely for development purpose, and the location of the package can be modify when we deploy to another environment.

After setting the General tab, let’s move onto the Data sources tab.

ssisDemo_002

In this tab, you can specify connection strings for each of the connection managers in the package. These are the connection information SQL agent is going to use when executing the package. Since we’re creating this job for development testing, let’s select the two connection managers and we’ll customize the values when we generate the elevation scripts for testing and production environments.

In this SSIS package, a global variable named “env” is set to “DEV” by default, we’ll specify the value once again on the “Set Values” tab for the elevation script.

ssisDemo_005

Please take a note on the syntax: \package.variables[env].Value = “DEV”

Now we can press OK twice to save the job.

We may try running the SQL job manually to see if it runs ok. The next step for us is to prepare elevation script to different environments. Let’s right click on the job, and generate the SQL script used to create this job.

The script would look something like this:

USE [msdb]
GO
/****** Object:  Job [testJob]    Script Date: 09/15/2009 01:19:13 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object:  JobCategory [[Uncategorized (Local)]]]    Script Date: 09/15/2009 01:19:13 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END

DECLARE @jobId BINARY(16)
EXEC @ReturnCode =  msdb.dbo.sp_add_job @job_name=N'testJob',
		@enabled=1,
		@notify_level_eventlog=0,
		@notify_level_email=0,
		@notify_level_netsend=0,
		@notify_level_page=0,
		@delete_level=0,
		@description=N'No description available.',
		@category_name=N'[Uncategorized (Local)]',
		@owner_login_name=N'DC\Jack Wong', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
/****** Object:  Step [Execute demo SSIS]    Script Date: 09/15/2009 01:19:14 ******/
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'Execute demo SSIS',
		@step_id=1,
		@cmdexec_success_code=0,
		@on_success_action=1,
		@on_success_step_id=0,
		@on_fail_action=2,
		@on_fail_step_id=0,
		@retry_attempts=0,
		@retry_interval=0,
		@os_run_priority=0, @subsystem=N'SSIS',
		@command=N'/FILE "C:\projects\ssisVariableDemo\ssisVariableDemo\bin\demo.dtsx" /CONNECTION "localhost.master";"Data Source=localhost;Initial Catalog=master;Provider=SQLNCLI.1;Integrated Security=SSPI;Auto Translate=False;" /CONNECTION result;"c:\result.csv" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /SET "\package.variables[env].Value";"""DEV""" /REPORTING E',
		@database_name=N'master',
		@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
    IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:

For elevation to different environment, we’d probably need to modify the connection manager strings and the default value for the global variable “env”. Also, the owner of the job would probably need to be modified as well.

On line 25, you may update the @owner_login_name to set the owner of the job

On line 38, the @command parameter is to specify any runtime specific customize values and configurations. There are three things you can modify.

  • The ssis package source: you may specify the source type and location. Thus your ssis package can be elevated and staged and needs no changes for different environments
  • Connection Manager – connection strings: You may specify a new location of the csv file and/or a new database with user credential
  • Variable values: You may specify initial values for any variables within the package.

This is it for this blog. I hope it can be helpful to you.

, , , , , , ,

No Comments

Weblogic Portal 10.3 Single Sign On (SSO) Implementation Options

I was working on a portal project that has a requirement of doing user impersonation from one application to anther application. This would require some kind Single Sign On mechanism. In Oracle WebLogic 10.3 framework, I’ve found four solutions that we can implement SSO easily. Depending on the environment setup, the design of your applications and the level of configurations we’d like to touch, one solution is better than the other one. Let’s go into more details for each of them.

Four solutions for SSO in Weblogic 10.3

  1. Session Sharing
  2. Security Realm Subject (Single Domain)
  3. Global Trust
  4. SAML 1.1/2.0

Session Sharing

When two applications share the same session, we can store user information in a session variable from one application, and use it in another application to check whether the user is authenticated or not.

Configuring session sharing in Weblogic is very simple. The applications would need to be deployed under same EAR file. Then we need to configure the weblogic-application.xml file under the EAR project.

<?xml version="1.0" encoding="ISO-8859-1"?>
<wls:weblogic-application xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">

 <wls:session-descriptor>
     <wls:persistent-store-type>memory</wls:persistent-store-type>
     <wls:sharing-enabled>true</wls:sharing-enabled>
 </wls:session-descriptor>
</wls:weblogic-application>

One of the advantages using session sharing is that it requires no domain level configurations. However, one disadvantage is the type of session variables have to be common for session sharing applications. Although we can simply implement some sort of common project that holds all the common types to resolve potential data type conflicts, this would require a lot of code changes and it isn’t preferred when you already have a lot of the code written and tested. Moreover, bundling multiple unrelated web applications into one single EAR for only the purpose of Single Sign On may sound a little awkward. For these reasons, it’s worth to look at other options.

Security Realm Subject (Single Domain)

The basic idea is if a user is authenticated in one application, the user principals are signed and stored in a subject container which is visible to all applications within the same domain. For more explanation regarding Weblogic Security Realm, please check out some documents from BEA.

I’ll describe very briefly and just to point out some key procedures in implementing SSO using this solution. When I get a chance, I’ll write another post to describe it in details. I’ve tested and verified that it works in environment with multiple managed servers.

Let’s assume we have two applications AppA and AppB such that AppA will have authenticate user from a form and provides an anchor to access

  1. In Weblogic Admin Console, under security realm, add your own authentication provider. (Possibly ActiveDirectory or SQL Database provider)
  2. In AppA, Authenticate user using UsernamePasswordLoginModule from weblogic which implements the standard JAAS LoginModule interface.
    @Jpf.Action
    public Forward login(MyForm form) throws Exception {
        try {
            this.login(form.getLoginName(), form.getLoginPassword());
            // Login Successful
            return new Forward();
        }
        catch (Exception ex) {
            // Login Failed
            throw ex;
        }
    }
    
  3. In AppB, check for user principle.
    @Override
    public boolean preRender(HttpServletRequest request, HttpServletResponse response) {
        if (request.getUserPrincipal() == null) {
           // User is unauthenticated
        }
        else {
            // User is logged in
        }
    }
    

    Alternatively, you may secure contents in AppB by modifying the weblogic.xml and web.xml as follows:

    weblogic.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <wls:weblogic-web-app xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
        <security-role-assignment>
    		<role-name>Users</role-name>
    		<principal-name>everyone</principal-name>
    	</security-role-assignment>
    </wls:weblogic-web-app>
    



    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
        <security-constraint>
    		<web-resource-collection>
    			<web-resource-name>SecurePages</web-resource-name>
    			<description>These pages are only accessible by authorized users.</description>
                <url-pattern>/com/cit/ecommerce/controller/sso/SsoController.jpf</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
    		</web-resource-collection>
    		<auth-constraint>
    			<description>These are the roles who have access.</description>
    			<role-name>Users</role-name>
    		</auth-constraint>
    		<user-data-constraint>
    			<description>This is how the user data must be transmitted.</description>
    			<transport-guarantee>NONE</transport-guarantee>
    		</user-data-constraint>
    	</security-constraint>
        <login-config>
    		<auth-method>CLIENT-CERT</auth-method>
    		<realm-name>myrealm</realm-name>
    	</login-config>
    	<security-role>
    		<description>These are the roles who have access.</description>
    		<role-name>Users</role-name>
    	</security-role>
    </web-app>
    

The good part about this solution is that it requires no custom configurations on the domain level. Though, it constraints applications to be deployed on a single domain. To support cross domain SSO, let’s look at the next option.

Global Trust

I haven’t had a chance to try this one out. But from readings, it’s really like spreading Domain Subjects pool across domains via RMI. Check this link out for details.

SAML 1.1/2.0

There’s a very detail explanation about how to configure SSO with SAML 1.1 in this article. It is secured and one of the standard protocol to exchange user principals across domains. One main advantage to use SAML over Global Trust is it works with other web applications that doesn’t neccessarily need to sit under Weblogic server.

, , , , , , , , , , , ,

8 Comments