How do I set an adapter's security test to come from worklight.properties? - ibm-mobilefirst

My company is working on an application developed with MobileFirst v6.3. I'm looking at creating a server configuration that will allow the server to bypass our standard security test.
This is the type of entry I'm looking to make in my worklight.properties file:
#############
# Worklight Security Test
#############
mt.adapter.security=custom-security-test
And this is how I'm trying to place the value in the adapter's procedure:
<procedure name="getTechUserAdapter" securityTest="${mt.adapter.security}"/>
When I build and deploy it, I get this error:
<error mbeanName="com.worklight.common.server.jmx.api:qualifier=worklight,type=ProjectManagement" node="worklight///10.16.109.75" date="2016-06-02T19:58:02.889Z" phase="PREPARE" code="FAILURE" details="Procedure &apos;getTechUserAdapter&apos; in adapter &apos;TechUserServiceAdapter&apos; requires security test &apos;${mt.adapter.security}&apos; which is not defined in authenticationConfig.xml.">
Worklight is trying to translate it the security test as a string, and not the value that was placed in the worklight.properties file. Does anyone know how to make it use the variable value?

The security test definition does not support custom properties like what you're trying to do... it looks at the authenticationConfig.xml file.
Instead you may need to keep multiple configurations and swap between them before you build the adapter.

Related

how to add db directory to web.xml

I have a java web app configured with apache v9.0 and eclipse IDE. What I need is to keep my database in C:\db so It cannot be access directly from outside and should be away from my webapp project directory. What I don't is how to let my web app know that if a user request for a file it should go and check it in my C:\db and reply back with the file.
Based in my research, some was saying to specify my directory in my webapp web.xml file and others was saying I need to specify it in my tomcat/conf/server.xml file.
I'd really appreciate if somebody tell me what to do?
Try adding your database path C:\db as JVM argument and accessing it in application. you may try this as two ways either set as system property and access when it required or set as JVM argument and access it.
SetSystemProperties
System.setProperty("database", "C:\\db");
.
.
access it as and when required
String databasepath= System.getProperty("database");
Setting as JVM Arguments.
Double Click on your tomcat server on which your web application is present.
Click on "Open launch configuration" link and go to Arguments Tab.
in vmArguments apend the entry like below.
-Ddatabase="C:\db"
A -D is placed in front of each system property that we are passing in as a VM argument, and following this is an equal sign followed by the value of that system property.
And access it in your project where its required like below.
String databasepath= System.getProperty("database");

How to deploy an atg project in weblogic?

I created a simple project using ATG 10.2 .I want to know how to deploy it in weblogic. Please provide detailed procedure with screenshots,if possible.
To provide a 'detailed' procedure is beyond the scope of what StackOverflow is trying to provide. That said, if you have an understanding of the Weblogic Management Console you should be able to follow these steps to setup your initial deployment:
Create a Server
1.1 Specify a server name (eg. commerce) and the port number this server will run on (eg. 8180). Select it as a 'Stand-alone server'.
1.2 Once created go to Configuration > Server Start for the newly created server and modify the 'Arguments' block and include the following setings (assuming you are running windows, for Unix update your own paths)
-Datg.dynamo.data-dir=c:\ATG-Data -Datg.dynamo.server.name=commerce -d64 -XX:ParallelGCThreads=8 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Xms1152m -Xmx2048m -XX:NewSize=128m -XX:MaxNewSize=256m -XX:PermSize=128m -XX:MaxPermSize=256m
1.3 Save your Server
Create DataSources
2.1 In the Console click on 'Services > Data Sources'
2.2 Create 'New' datasources for each of your connections. As a minimum you will need connections for ATGSwitchingDS_A, ATGSwitchingDS_B (Assuming you are doing switching datasources) and ATGProductionDS. These names should match your JNDI names in your property files. Remember to specify the 'commerce' server as the target for each of the datasources.
Create Deployment
3.1 Assuming you've already built your EAR (eg. ATGProduction.ear) and it is available in c:\deployments you need to create a deployment in Weblogic. You need to create the deployment in the console and specify the target as 'commerce'. Once done you need to also 'start serving requests' on the deployment.
Start Server
You should now be able to see your server running on port 8180 with the log files being written to c:\ATG-Data\servers\commerce\logs.
If after this things aren't running, post specific questions about your issues and someone here might be able to help you.

Shared config file for all mobilefirst server adapters

Can i get config for all adapters at one place ? For example, i need store connection strings, httpserver addresses that needed across my mobilefirst server.
Mobilefirst version 8.0.
Thank you for advance!
In MobileFirst Foundation 8.0 you have the following options:
If using JavaScript adapters:
Edit the connectivity settings from the MobileFirst Console,
Or create a config file and use Maven commands (or the MobileFirst CLI in an upcoming CLI update), or other tools, to push the file to each adapter that requires that same set of connection settings.
Using this method there is no downtime to the server.
See the "Pull and Push Configurations" topic here: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/adapters/javascript-adapters/
Customized adapter properties can be shared using the adapter configuration file found in the Configuration files tab.
To do so, use the pull and push commands described below. For the properties to be shared, you need to change the default values given to the properties.
Replace the DmfpfConfigFile placeholder with the actual value, for example: config.json. Then, run the command from the root folder of the adapter Maven project:
To pull the configurations file - mvn adapter:configpull -DmfpfConfigFile=<path to a file that will store the configuration>.
To push the configurations file - mvn adapter:configpush -DmfpfConfigFile=<path to the file that stores the configuration>.
If using Java adapters,
You can add JNDI properties to the server.xml of your application server, and using the configurationAPI (getServerJNDIProperty) you can read those properties in each of your adapters. However note that by using server.xml this will incur a downtime whenever you will want to update your list of connection properties.

IBM Worklight - How to use adapter domain and port properties taken from external file?

I have a web service. Its domain and port can be changed. So I want to read port and domain from file or db. When this information change, I update them in db or file.
Adapter XML:
<domain>${adp.hostname}</domain>
<port>${adp.port}</port>
worklight.properties:
adp.hostname=localhost
adp.port=10080
This is working fine. But I'd like to take adp.hostname and adp.port from file or db.
Something to remember about adapters is that you cannot change in real-time any of the properties set in the adapter XML once it is deployed.
Once the adapter is deployed, it is transformed into an object and is stored in memory. At this time, then, you can no longer interact with its "setup".
The only thing you can do, is to decide what will be the value of these properties before your deploy the adapter. For example, a different set of properties for QA/TEST/UAT/PROD environments...
To setup external properties, starting Worklight 6.0 and above, you can read this documentation topic: Configuring an IBM Worklight project in production by using JNDI environment entries
Specifically for Tomcat in its server.xml:
<Context docBase="app_context_path" path="/app_context_path">
<Environment name="publicWorkLightPort" override="false"
type="java.lang.String" value="9080"/>
</Context>
You change app_context_path to your project's context (project name)
You add environment child elements for each property you need
Important to remember: these properties must also exist in worklight.properties; those will be the default properties, and if using the above example they will be over-written and the environment properties will be used instead.
In the example above you can see that it will replace the default property publicWorkLightPort.

IBM Worklight - Error while validating project during deployment

I have created an application using IBM worklight and i am using customAuthenticator for login process
I am getting following validation error while deploying application
Security test DummyAdapter-securityTest must include user and device
realms for AuthDemo:iphone:1.0:api. [project
module_23_1_CustomLoginModule]
You need to re-read the entire Getting Started section about Authentication and Security. There is more reading material here and here.
From the error I am thinking you have added a securityTest="DummyAdapter-securityTest" attribute to your iphone element in application-descriptor.xml.
As noted by the name of the securityTest, it is not meant for the application but for the adapter. This securityTest is already defined for the adapter procedure in the adapter XML file. Remove the securityTest you've added and it will work.
The sample you are trying to run (module_23_1_CustomLoginModule) is ready-made; no need for editing. You need only to build & deploy and run it.