creating a cagrid data service cagrid data service backed by cacore sdk 4.1.1 cagrid knowledge...
TRANSCRIPT
Creating a caGrid Data
Service caGrid Data Service
backed by caCORE SDK 4.1.1
caGrid Knowledge [email protected]
May 6, 2009
Introduction
This tutorial walks you through the process of creating a caGrid 1.3 Data Service to share data on the Grid. This data is stored in a database and accessed via the caCORE SDK 4.1.1 APIs. The model is the same model as used in the caCORE SDK 4.1.1 systems. For more details, refer to other tutorial in the May 5-6, 2009 caBIG Developer Boot Camp.
PrerequisitesThis tutorial has the following prerequisites:
• caCORE SDK 4.1.1 is installed locally. • The SDK has been configured with the boot camp model.• Your caCORE installation has been configured with your data source information.• You have deployed the resulting web application to JBoss or Tomcat• You have started your container to make the caCORE SDK web application
available on port 8080.• The caGrid software has been installed on your host at c:\bootcamp\cagrid
caGrid Software
Overview
The hosts provided for this Boot Camp have been preinstalled with the caGrid 1.3
software.
caGrid and required software:
• The caGrid 1.3 Installer: C:\bootcamp\cagrid\caGrid-installer-1.3
• caGrid 1.3: C:\bootcamp\cagrid\caGrid
• Apache Ant: C:\bootcamp\cagrid\apache-ant-1.7.0
• Globus Toolkit for Java: C:\bootcamp\cagrid\ws-core-4.0.3
Additional software:
• Notepad++, A free file editor application: C:\bootcamp\cagrid\Notepad++
• Software Distributions: C:\bootcamp\cagrid\dist
• Completed caGrid Boot Camp Data Service: C:\bootcamp\cagrid\BootCampDataSvc-Solution
caGrid Development Phases
The phases to generating a caGrid Data Service backed by the caCORE SDK.
1. Deploy a Secure Tomcat Container
2. Create the Data Service Skeleton
3. The Data Service caCORE SDK 4.1 Wizard
4. Set Service Metadata
5. Creating a Test Class
6. Create Test Files
7. Deploying the Data Service
8. Executing the Tests
9. Add Security
10.Join the May Bootcamp Group
11.Re-run the tests
Phase 1: Deploy a Secure Tomcat Container (1)
Begin Secure Tomcat Deployment
These steps use a caGrid Installer that has been configured to use a local Tomcat installer rather than download from the Apache web site. This is to avoid the time required to perform the download.
Note: your caGrid install has been configured to use the Community Training Grid. You must synchronize with the Community Training Grid trust fabric first.
1.Open a Windows Command Prompt
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Synchronize with Community Training Grid trust fabric
%> c:\bootcamp\cagrid\syncWithTrustFabric.bat
3.Change directory to the caGrid Installer
%> cd c:\bootcamp\cagrid\caGrid-installer-1.3
4.Execute the provided installer batch
%> installLocal.bat
The caGrid Installer will launch.
Deploy a Secure Tomcat Container (2)
4. Select the "I agree to this license" checkbox and click the "Next" button.
Deploy a Secure Tomcat Container (3)
5. Select the "Install/Configure Grid Service Container" checkbox. De-select the “Install/Configure caGrid Software” checkbox. Click the "Next" button.
Deploy a Secure Tomcat Container (4)
6. Select Tomcat as the Container you would like to install.
7. Check the box "Should this container be secure?" and click the "Next" button.
Deploy a Secure Tomcat Container (5)
8. We will use the default hostname and ports identified by the Installer. Click the "Next" button.
Note: In real word usage the hostname must
be externally routable and fully-qualified
name or IP Address.
For example, the Training Grid Master
GTS external hostname is
mastergts.training.cagrid.org and
internal, non-routable hostname is ‘
cagrid-1_3-training-master-gts.cagrid.org.
We specified mastergts.training.cagrid.org.
Deploy a Secure Tomcat Container (6)
Obtain Grid account and Host CertificateIn order to deploy a secure container to the Grid you must have host certificates that have been created by the Dorian Service. Using these steps you will register an account and obtain host certificates using the GAARDS UI.
9.Select the “Use GAARDS to
obtain host credentials” option
to create credentials and click the
"Next" button.
10.The GAARDS UI will
automatically open.
Deploy a Secure Tomcat Container (7)
Register with GAARDS
Note: if you have an NCI account (or KC account), you can skip this step.
11. Click the Account Management
Menu item, then select Local Accounts
->Registration.
12. Provided the requested information,
then click “Apply”.
Note on password requirements: A valid password CANNOT contain a dictionary word and MUST contain at least one upper case letter, at least one lower case letter, at least one number, and at least one symbol (~!@#$%^&*()_-+={}[]|:;<>,.?)
Deploy a Secure Tomcat Container (8)
Login to the Community Training Grid
13. Click the "Login" button.
14. In the Login dialog, enter your User ID and Password and click the “Login” button.
Note: if you are using your NCI/KC username and password, select the NCI organization. Otherwise, use the default of “Training”.
Deploy a Secure Tomcat Container (9)
Request Host Certificate
Host certificates are used to establish secure communications between clients and services.
15.Open the "Request Host Certificate" Panel via the "My Account" menu and "Request Host Certificate” menu item.
Deploy a Secure Tomcat Container (10)
16. Accept the Host name that GAARDS identifies.
17. Accept the default location for creating
the host credentials. On Windows, this
will be a path like "C:\Documents and
Settings\Administrator\.cagrid\certificates”.
18.Click Request Certificate. A
dialog will display the outcome of
your request. Note: if you receive an error (see the pic to the right), then follow the steps on the next slides. You will see the “Host Certificate Issued” dialog to the lower right after a successful request. Note the location of the certificate and key as shown in the dialog.
19.Close the GAARDS UI.
20. Click the “Next” button on the installer.
Host Certificate Request Error Workaround (1)
If you receive the error to the right, type in a new hostname in the Request Host Certificate dialog.
You can see the “host” text field to the right, where you should type a new hostname.
After successfully retrieving a certificate, you will see the window to the right. Please note the file locations for your certificate and key files. You will use these next. Close GAARDS.
Host Certificate Request Error Workaround (2)
Next, you will see the installer error below. Click OK.
Click “Previous”. Select “Browse to host credential on the file system”. Click Next.
Host Certificate Request Error Workaround (3)
Browse to the certificate and key. Click Next.
Deploy a Secure Tomcat Container (11)
Finish Tomcat Installation
21. Please enter C:\bootcamp\cagrid in the "Directory" text box and click the "Next" button.
Deploy a Secure Tomcat Container (12)
22.The next screen will display a list of tasks that the installer will perform to install and configure tomcat, click the "Next" button.
23.Once the installer has completed installing all the components, click the "Next" button.
24.The final screen ask you to set the following environment variables: ANT_HOME, GLOBUS_LOCATION and CATALINA_HOME. These should already have been set by the Bootcamp administrators.
25.Click Finish.
26.Click Close.
Phase 2: Create the Data Service Skeleton (1)
This phase of this tutorial involves starting the Introduce toolkit and using it to create the skeleton of the new grid data service that will communicate with the caCORE SDK service that you have created.
1.Open a Windows Command Prompt
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to the caGrid Installer
%> cd c:\bootcamp\cagrid\caGrid
3.Start Introduce using the provided Ant task
%> ant introduce
Create the Data Service Skeleton (2)
Create the Service Skeleton
1.Click Create caGrid Service Skeleton button on the toolbar at the top of the Introduce portal. The Create caGrid Service Skeleton screen will appear (see right).
2.STEP 1: Type the following as your service directory "C:\bootcamp\cagrid\BootCampDataSvc". ]
3. STEP 2: Type "BootCampDataSvc" in the Service Name field.4. STEP 3: Type "gov.nih.nci.cagrid.bootcamp” in the Package Name field.5. STEP 4: Verify that the Namespace field contains
"http://bootcamp.cagrid.nci.nih.gov/BootCampDataSvc".6. Click the “Data Service” radio button in the “Customize the Service” pane.7. Click the “Create” button.
Create the Data Service Skeleton (3)
Select the Service Style
The caGrid data services extension provides a pluggable framework for creating highly custom data services known as data service styles. Styles may be provided by a third party, or installed with caGrid. Styles are provided to create data services backed by various versions of the caCORE SDK.
1.When the Data Service Configuration window appears, use the drop down menu to select the caCORE SDK v 4.1 option.
2.Leave the check boxes for
WS-Enumeration and Bulk Data
Transport unchecked for this tutorial.
3.Click the OK button.
Phase 3: The Data Service caCORE SDK 4.1 Wizard (1)
The caCORE SDK v. 4.1 Data Service style provides a wizard interface which is run prior to generation of the data service's source code. This wizard provided facilities to select the client interface to the caCORE SDK and configure it, as well as selection of a domain model and mapping that domain to XML schemas for use on the grid.
The first panel of the wizard is strictly informational. The wizard displays the current step in the lower left hand corner of the window, and provides simple 'Previous' and 'Next' buttons to navigate the steps.
The Data Service caCORE SDK 4.1 Wizard (2)
1. Click the “Next: SDK Directory” button.
The Data Service caCORE SDK 4.1 Wizard (3)
Selecting the caCORE SDK Directory
The second step of the caCORE SDK v 4.1 Data Service Creation Wizard asks the service developer to select the directory in which the caCORE SDK system resides. Note: it is a requirement that this caCORE SDK installation has only one project in the “output” folder for the wizard to work.
2.Click the “Browse” button at the top-right.
3.Use the file browsing dialog to select the “C:\bootcamp\SDK411-Solution\sdk411” directory.
4.Click “Next: API Type”
to continue the wizard.
The Data Service caCORE SDK 4.1 Wizard (4)
Choose the API Type
There are two API types available when communicating with the caCORE SDK application. The Local API option requires that the grid data service be deployed on the same machine as the caCORE SDK application, which offers better query performance because the queries will not use the network. The Remote API option will work regardless of where the caCORE SDK application and grid data service are deployed (same machine or another machine). We will use the Remote API option.
The Data Service caCORE SDK 4.1 Wizard (5)
Choose the API Type (continued)
1. Select the Remote API option from the API Type group.
2. Enter “127.0.0.1” as the Hostname.
3. Enter “8080” as the Port Number.
4. Leave the Use HTTPS option unchecked.
5. Click the “Next: Login” button.
The Data Service caCORE SDK 4.1 Wizard (6)
Log In to the caCORE SDK Application
Step four allows the service developer to supply login information to the caCORE SDK Application Service in the form of a username and password combination. If these values are supplied, the caCORE SDK Application Service API will be initialized with them when the grid data service starts up.
6. Click “Next: Domain Model”
as we will not use a login in this
tutorial.
The Data Service caCORE SDK 4.1 Wizard (6)
Select the Domain Model
Step five of the wizard requires the service developer to supply the domain model which the new data service will expose to the grid. Domain Models define the classes, their attributes, and relationships such that data services may be discovered by the types they expose, and CQL queries can be formulated without a priori knowledge of an arbitrary data service's contents.
There are three potential sources for the domain model:
Default XMI: This setting directs the wizard to convert the XMI model which is used by the caCORE SDK system specified on step 2 as the domain model. The XMI will be converted to a domain model XML document.
Pre-Generated: This option allows the service developer to specify a pre-generated domain model XML document from the local file system.
caDSR: This option lets the service developer select a project and packages from the cancer Data Standards Repository (caDSR) and generate a domain model extract from it for use in their data service.
The Data Service caCORE SDK 4.1 Wizard (7)
Select the Domain Model (continued)
7.For this tutorial, select Default XMI as the Domain Model Source.
8.Type “1.0” as the Project Version to create a caGrid version of your Domain Model. Verify the other fields are as shown in the picture below.
9.Click the “Next: Schemas” button.
The Data Service caCORE SDK 4.1 Wizard (7)
Map XML Schema to Model PackagesEvery class included in the domain model must have a corresponding XML schema representation so it may be utilized in the grid. The mapping panel of this wizard streamlines this process by simultaneously generating the mapping from model to schema and configuring serialization of the XML data types to correspond to the domain model's Java beans.
The table shows the following information: 1) packages included in the domain model, 2) the current mapping status of the package, and 3) a “Map Schema” button to manually resolve the mapping for each package. The Automatically Map From SDK Generated Schemas button in the bottom of the panel makes use of the XML schemas provided by the caCORE SDK's output to map each package of the domain model.
The Data Service caCORE SDK 4.1 Wizard (8)
Map XML Schema to Model Packages (continued)
10.Click the Automatically Map From SDK Generated Schemas button to perform the mapping from domain model packages to XML schema.
11.Verify that the “Status” field changes from “No Schema Assigned” to “OK”.
12.Click Done to complete the wizard.
The Data Service caCORE SDK 4.1 Wizard (9)
Save your Service!You will see a progress bar during creation of your caCORE backed caGrid Data Service.
13.Click the “Save” button at the bottom of the "Modify Service Interface”.
Phase 4: Set Service Metadata (1)
Service Metadata contains information about the developer of the service, the maintainer or administrator of the service and the hosting research center as well as optional information such as a web site URL. This information is used when registering your service with the Index Service for the Grid and is accessible via the caGrid Portal.
In order to deploy your Grid service via Introduce or the command line you will need to set the service metadata.
Set Service Metadata (2)
Open the Introduce Service Metadata Resource Property Editor
1.In Introduce click the Services tab of your Grid service.
2.Underneath "BootCampDataSvc", click the ServiceMetadata Resource Property
3.Click the Edit Resource Property button, on the right.
Set Service Metadata (3)
The Resource Property EditorThe Resource Property Editor allows you to define your service metadata. Required fields will be identified by a pink background and a red "x”.
Set Service Metadata (4)
Hosting Center and Point of Contact
Hosting Center and Point of Contact fields identify where the service is deployed and an individual responsible for the service such as an administrator.
1. Type “National Cancer Institute” in the Display Name field.
2. Type “NCI” in the Short Name field.
3. Click “<unspecified>” in the Current Points of Contact.
4. Type your first name in the First Name field.
5. Type your last name in the Last Name field.
6. Type your email in the Email address field.
7. Type your Affiliation. Ex. Your department
8. Select the “Maintainer” Role.
Set Service Metadata (5)
Hosting Center Address
Provide the address of your Hosting Center. For this tutorial we'll use the NCI address: 2115 E. Jefferson, Rockville, MD 20852
1. Click the Address Tab2. Set “2115 E. Jefferson” to Street 1
field.3. Leave Street 2 empty.4. Set “Rockville” in the Locality(City).5. Set “MD” as the 2-character State
abbreviation.6. Set “20852” as the Zip Code. 7. Set "US” as the 2-character Country
Code.
Set Service Metadata (6)
Hosting Center Additional Information
This tab provides you with the ability to supply metadata that allows users to find more information about you. All fields are optional.
Set Service Metadata (7)
Service Information Point of Contact
The Service Information tab provides information about a POC for the Service itself.
1. Click “Service Information” tab.2. Click “<unspecified>” in the
Current Points of Contact.3. Type your first name in the First
Name field.4. Type your last name in the Last
Name field.5. Type your email in the Email
address field.6. Type your Affiliation. Ex. Your
department7. Select the “Maintainer” Role.8. Click “Done” to finish editing
metadata.Note: If you have missed a required
field you will get an error message.
Set Service Metadata (8)
Save Your Service!
Remember to save your service. Introduce will allow you to roll back to a save point. This can be very useful in the event that you run into problems.
Click the Save button at the bottom of the "Modify Service Interface"
Phase 5: Create a Test Class (1)
Once the tutorial caGrid data service has been created and deployed to a service container, it may be invoked by a grid service client. This portion of the tutorial covers creating the test client Java class that will be used to query our caCORE SDK application.
Note:
Introduce generated services are generated to be supported by the Eclipse development environment. The service can be imported easily. For this tutorial we will use a more light weight editor, Notepad++, provided in c:\bootcamp\cagrid\Notepad++ directory.
Create a Test Class (2)
Open the Base Test Class File
To begin making use of the tutorial data service service, we'll need a place to put source code, as well as a Java source file to make use of the generic data service client and handle our query results. While the client class produced with the service itself can be used for very basic testing, domain specific logic should never be placed in the client when used in a production level system. This is because the client may be regenerated, or have methods added and removed by the Introduce toolkit as changes are made to the service model.
1.Open a Windows Command Prompt
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Execute the makeQueryRunner.bat file
%> c:\bootcamp\cagrid\makeQueryRunner.bat
Create a Test Class (3)
Edit the Test Class file
1. Open Windows Explorer and navigate to C:\bootcamp\cagrid\Notepad++
2. Double-click "Notepad++.exe”
3. Open the file: C:\bootcamp\cagrid\BootCampDataSvc\src\gov\nih\nci\cagrid\bootcamp\test\QueryRunner.java
Create a Test Class (4)
Create the Class Constructor
Now we need to add some implementation to the test class.
Start by creating a very simple class constructor for the QueryRunner class. Copy and paste the following code into the new Java file, immediately after the class declaration and opening bracket (i.e., after “public class QueryRunner {”):
private String serviceUrl;
private String queryFilename;
public QueryRunner(String serviceUrl, String queryFilename) {
this.serviceUrl = serviceUrl;
this.queryFilename = queryFilename;
}
Create a Test Class (5)
Import Required Classes and implement the performQuery method
Now, a method must be added to the class which can handle calling the data service. To make code from caGrid available in this class some import statements must be added to the class.
At the top of the class file, below the package declaration and before the class declaration, add the following:
import java.util.Iterator;
import gov.nih.nci.cagrid.common.Utils;
import gov.nih.nci.cagrid.cqlquery.CQLQuery;
import gov.nih.nci.cagrid.cqlresultset.CQLQueryResults;
import gov.nih.nci.cagrid.data.client.DataServiceClient;
import gov.nih.nci.cagrid.data.utilities.CQLQueryResultsIterator;
Create a Test Class (6)
Add the following method after the main() method: private void performQuery() {
try {
DataServiceClient client = new DataServiceClient (serviceUrl); // initialize the generic data service client
// deserialize the CQL query
CQLQuery query = (CQLQuery) Utils.deserializeDocument(queryFilename, CQLQuery.class);
System.out.println ("Querying"); // execute the query on the data service
CQLQueryResults results = client.query(query); // create a results iterator
System.out.println("Iterating");
Iterator iter = new CQLQueryResultsIterator(results, true);
while (iter.hasNext()) { // iterate and print XML
String value = (String) iter.next();
System.out.println("-- RESULT --");
System.out.println(value);
}
System.out.println("Done");
} catch (Exception ex) {
ex.printStackTrace();
}
}
Create a Test Class (7)
Modify the main() method with the following content:
public static void main(String[] args) {
QueryRunner runner = new QueryRunner(args[0], args[1]);
runner.performQuery();
}
Note: C:\bootcamp\cagrid\dist\QueryRunner-final.java contains the complete file. You can copy this over to QueryRunner.java if you so choose.
Create a Test Class (8)
Save the file.
1.Select “Save” from the File menu or type Ctrl+S
Phase 6: Create Test Files (1)
The Test FilesTo make use of the QueryRunner test class, we'll need CQL queries, and Ant script and two convenience batch files. These files will be used to execute queries against the data service developed earlier.
Copy prepared test files into your BootCampDataSvc directory:
1.Open Windows Explorer
2.Double-click the file c:\bootcamp\cagrid\copyTestFiles.bat
The Organism Query (C:\bootcamp\cagrid\BootCampDataSvc\organismCQLQuery.xml)
The following query will return a list of the organisms defined in the Organism database table and defined by our Data Model.
<ns1:CQLQuery xmlns:ns1="http://CQL.caBIG/1/gov.nih.nci.cagrid.CQLQuery">
<ns1:Target name="gov.nih.nci.training.BootCamp.domain.Organism">
</ns1:Target>
</ns1:CQLQuery>
Create Test Files (2)
Specific Organism Query
(C:\bootcamp\cagrid\BootCampDataSvc\mouseCqlQuery.xml)
The following query will return the organisms defined with the commonName of "Mouse" in the Organism database table and defined by our Data Model.
<ns1:CQLQuery xmlns:ns1=http://CQL.caBIG/1/gov.nih.nci.cagrid.CQLQuery>
<ns1:Target name="gov.nih.nci.training.BootCamp.domain.Organism">
<ns1:Attribute name="commonName" value="Mouse" predicate="EQUAL_TO"/>
</ns1:Target>
</ns1:CQLQuery>
Create Test Files (3)
Query Runner Ant Script
The QueryRunner class can be executed from the command line. In order to do this, we'll use a simple Ant build script, queryRunnerExec.xml.
In Notepad++, open the file c:\bootcamp\cagrid\BootCampDataSvc\queryRunnerExec.xml.
This simple Ant build script reads your current environment variables and locates $GLOBUS_LOCATION, and sets several build properties which reference Java library locations. It then defines a single target, “run”, to invoke the JVM using the QueryRunner class's main method, and passing the system properties service.url and cql.file as arguments to it. It uses Jar files found in the library directories it defined earlier as the classpath for the Java runtime.
Create Test Files (4)
Batch Files
The QueryRunner tests will be invoked via command line. The following files will be used to execute the Ant tasks.
Organism Query Ant Batch File
(C:\bootcamp\cagrid\BootCampDataSvc\runQueryOrganism.bat)
Executes the Ant run task with the organism CQL query.
Contents:
ant -f queryRunnerExec.xml -Dservice.url=https://127.0.0.1:8443/wsrf/services/cagrid/BootCampDataSvc -Dcql.file=organismCqlQuery.xml
Mouse Query Ant Batch File
(C:\bootcamp\cagrid\BootCampDataSvc\runQueryMouse.bat)
Executes the Ant run task with the mouse CQL query.
Contents:
ant -f queryRunnerExec.xml -Dservice.url=https://127.0.0.1:8443/wsrf/services/cagrid/BootCampDataSvc -Dcql.file=mouseCqlQuery.xml
Phase 7: Deploying the Grid Data Service (1)
The caGrid data service has been created. It must be deployed to a container and started so that it can be invoked.
This tutorial uses the secure Tomcat container that you configured earlier.
Deploy the Grid Data Service
The following Ant command will recompile the service and deploy it to the Tomcat container installed at the %CATALINA_HOME%:
1.Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to our caGrid Data Service.
Type cd C:\bootcamp\cagrid\BootCampDataSvc
•Execute the Ant deploy task.Type ant all deployTomcat
Deploying the Grid Data Service (1)
Starting Tomcat
Start the Tomcat container so that the service can be invoked.
1.Using a Windows Command Prompt
2.Change directory to your Tomcat directory
Type cd %CATALINA_HOME%\bin
3.Start Tomcat
Type startup.bat
A new Windows command window will open and will contain the startup information from your Tomcat.
Deploying the Grid Data Service (2)
Example Tomcat Startup Output
Deploying the Grid Data Service (3)
Verify Service Deployment
1.Open Internet Explorer
2.Go to: https://localhost:8443/wsrf/services/cagrid/BootCampDataSvc
3.Click “Yes” (or “Continue to this website”) if prompted for a “Security Alert” to access our secured service.
Phase 8: Executing the Tests (1)
We have created the batch files, XML query files and the Ant build file that will enable us to easily test our data service. We have also started our Grid Service Tomcat server.
Please make sure that your caCORE SDK Application (JBoss server) is running.
1.Open Internet Explorer
2.Go to : http://localhost:8080/example/
3.Verify that the caCore SDK page appears
Executing the Tests (2)
Execute the Organism Query
The QueryRunner tests will be invoked via command line. The following files will be used to execute the Ant tasks.
Perform the following steps to run a query for all Organisms defined our DataModel as "gov.nih.nci.training.BootCamp.domain.Organism”.
1. Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2. Navigate to your BootCampDataSvc
Type cd c:\bootcamp\cagrid\BootCampDataSvc
3. Execute the Organism query batch
Type runQueryOrganism.bat
Test Output, next page.
Executing the Test (3)
Successful Organism Query
Executing the Test (4)
Execute the Mouse Query
Perform the following steps to run a query for Organisms with the commonName "Mouse" as defined in our DataModel as gov.nih.nci.training.BootCamp.domain.Organism.
1. Open, or use an existing command prompt
2. Navigate to your BootCampDataSvc
Type cd c:\bootcamp\cagrid\BootCampDataSvc
3. Execute the mouse query batch
Ttype runQueryMouse.bat
Test Output, next page.
Executing the Test (5)
Successful Mouse Query
Phase 9: Add Security (1)
In this section of the lesson, we will enable security on our service. Note that up until now we haven’t added any security specifically to our code. We have just focused on the “business logic”.
In the next section, we will enable service-level authentication and authorization requirements. This means we will have the following requirements for every service client: 1) they are logged in so that the service can verify their identity, and 2) they are on the list of selected users allowed to access the service.
We will use Introduce to configure our security policy. Then we will re-deploy our service so that we have our new security policy enabled. Then we will re-test our queries without having given ourselves access to the service to make sure they fail as expected. Then we will re-test our queries after giving ourselves access to make sure they complete as expected.
Phase 9: Add Security (2)
This phase of this tutorial returns to the Introduce toolkit and using it to add security to your data service.
If you closed the Introduce toolkit from earlier, here are the steps to restart it:
1.Open a Windows Command Prompt
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to the caGrid Installer
%> cd c:\bootcamp\cagrid\caGrid
3.Start Introduce using the provided Ant task
%> ant introduce
4.Click the Modify Service button
5.Browse to and select the C:\bootcamp\cagrid\BootCampDataSvc directory
Phase 9: Add Security (3)
We will enable secure access to your service via Introduce.
1.Click the “Services” tab.
2.Select “BootCampDataSvc”.
3.Click “Modify Service”.
Phase 9: Add Security (4)
1.Click the “Security” tab.
2.Select “Custom”.
3.Check “Transport Layer Security”.
Add authentication requirements.
Phase 9: Add Security (5)
1.Click the “Authorization” tab.
2.Select “Grid Grouper” Authorization Mechanism.
3.Click “Load”.
4.Expand the Grid Grouper Service tree to show “May Bootcamp”.
5.Click “AND” in the Grid Grouper Expression Editor on the right.
6.Click the “Add Group” button.
7.Click “Done”.
Add authorization requirements.
Phase 9: Add Security (6)
Save Your Service!
Remember to save your service. Introduce will allow you to roll back to a save point. This can be very useful in the event that you run into problems.
Click the Save button at the bottom of the "Modify Service Interface"
Phase 10: Re-run the tests (1)
Now that the service is secure, we will re-deploy the service and re-run the tests. It is required to re-deploy the service any time there are changes that you want to test. Because we created a secure container earlier, you can re-deploy your service to the same container.
Stopping Tomcat
Stop the Tomcat container so we can deploy the service.
1.Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to your Tomcat directory
Type cd %CATALINA_HOME%\bin
•Start Tomcat
Type shutdown.bat
This will close the (already open) Windows command prompt that Tomcat was running inside.
Phase 10: Re-run the tests (2)
Deploy the Grid Data Service
The following Ant command will recompile the service and deploy it to the Tomcat container installed at the %CATALINA_HOME%:
1.Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to our caGrid Data Service.
Type cd C:\bootcamp\cagrid\BootCampDataSvc
•Execute the Ant deploy task.Type ant all deployTomcat
Phase 10: Re-run the tests (3)
Starting Tomcat
Start the Tomcat container so that the service can be invoked.
1.Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to your Tomcat directory
Type cd %CATALINA_HOME%\bin
•Start Tomcat
Type startup.bat
A new Windows command window will open and will contain the startup information from your Tomcat.
Deploying the Grid Data Service (2)
Example Tomcat Startup Output
Deploying the Grid Data Service (3)
Verify Service Deployment
1.Open Internet Explorer
2.Go to: https://localhost:8443/wsrf/services/cagrid/BootCampDataSvc
3.Click “Yes” (or “Continue to this website”) if prompted for a “Security Alert” to access our secured service.
Executing the Tests (2)
Execute the Organism Query
The QueryRunner tests will be invoked via command line. The following files will be used to execute the Ant tasks. Now that the service has been made secure, the test will fail because you have not been added to the May Bootcamp group yet.
Perform the following steps to run a query for all Organisms defined our DataModel as "gov.nih.nci.training.BootCamp.domain.Organism”.
1. Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2. Navigate to your BootCampDataSvc
Type cd c:\bootcamp\cagrid\BootCampDataSvc
3. Execute the Organism query batch
Type runQueryOrganism.bat
Test Output, next page.
Executing the Test (3)
Failed Organism Query
Phase 11: Join the May Bootcamp Group (1)
In this section, you add yourself to the May Bootcamp group. You can do this by simply joining the group.
This phase of this tutorial involves starting the GAARDS UI to modify the Grid Grouper group on the Training Grid.
1.Open a Windows Command Prompt
Click “Start”->”Run” and type “cmd”, then press the Enter key
2.Change directory to the caGrid Installer
%> cd c:\bootcamp\cagrid\caGrid
3.Start GAARDS UI using the provided Ant task
%> ant gaardsui
4.Manage Grid Grouper
Select the Group Management -> Group Browser menu item
Phase 11: Join the May Bootcamp Group (2)
Add a Grid Grouper service to manage.
1.Click the “Add Grid Grouper” button.
2.Select your credentials using the drop-down box.
3.Click “Add”.
Phase 11: Join the May Bootcamp Group (3)
Add yourself to the May Bootcamp group.
1.Expand the “NCI Bootcamp” node of the tree down to the “May Bootcamp” node.
2.Double-click “May Bootcamp” so that the “May Bootcamp” tab appears on the right.
3.Click “Members” tab.
4.Click “Add” button at the bottom”.
Phase 11: Join the May Bootcamp Group (4)
Add yourself to the May Bootcamp group.
1.Highlight and copy your identity string from the Credentials box (shown in top red box).
2.Paste your identity into the Member Identity text box (show in middle red box).
3.Click “Add”.
Phase 11: Re-run the tests (1)
Now that you added yourself to the May Bootcamp group, we will re-run the tests. We do not need to re-deploy the service as the we have not changed it.
Executing the Tests (2)
Now that you added yourself to the May Bootcamp group, we will re-run the tests.
Execute the Organism Query
The QueryRunner tests will be invoked via command line. The following files will be used to execute the Ant tasks.
Perform the following steps to run a query for all Organisms defined our DataModel as "gov.nih.nci.training.BootCamp.domain.Organism”.
1. Open a Windows Command Prompt.
Click “Start”->”Run” and type “cmd”, then press the Enter key
2. Navigate to your BootCampDataSvc
Type cd c:\bootcamp\cagrid\BootCampDataSvc• Execute the Organism query batch
Type runQueryOrganism.bat
Test Output, next page.
Executing the Test (3)
Successful Organism Query
Executing the Test (4)
Execute the Mouse Query
Perform the following steps to run a query for Organisms with the commonName "Mouse" as defined in our DataModel as gov.nih.nci.training.BootCamp.domain.Organism.
1. Open, or use an existing command prompt
2. Navigate to your BootCampDataSvc
Type cd c:\bootcamp\cagrid\BootCampDataSvc
3. Execute the mouse query batch
Ttype runQueryMouse.bat
Test Output, next page.
Executing the Test (5)
Successful Mouse Query
Conclusion
Congratulations!
You have successfully created a caCORE-backed caGrid 1.3 data service with security enabled. If you have further questions, please visit the caGrid Knowledge Center: https://cabig-kc.nci.nih.gov/CaGrid/KC/index.php/Main_Page