Can't authentication with WSO2 IS on webapp - spring-mvc

I'm trying to create authentication mechanism on WSO2 IS and I have a trouble as following :
- I implemented to remote_user as the below link and the result is OK. I can login and access WSO API from console
https://svn.wso2.org/repos/wso2/people/asela/user-mgt/remote-user-api/4.2.X/
But When I tried on webpage , I can't authenticate to WSO IS. the following is my code for this :
public void init() throws AxisFault{
userName = HDConstants.USER_NAME;
password = HDConstants.PASSWORD;
backEndServerURL = HDConstants.SERVER_URL;
setKeyStore();
configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
}
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", HDConstants.TRUST_STORE_PATH);
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}
public boolean authenticateUser(String userName, String password) throws Exception {
String serviceURL = null;
ServiceClient client = null;
Options option = null;
boolean isAuthenticated = false;
AuthenticationAdminStub authStub = null;
serviceURL = backEndServerURL + "AuthenticationAdmin";
authStub = new AuthenticationAdminStub(configCtx, serviceURL);
client = authStub._getServiceClient();
option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);
isAuthenticated = authStub.login(userName, password, HDConstants.APP_ID);
authCookie = (String) authStub._getServiceClient().getServiceContext()
.getProperty(HTTPConstants.COOKIE_STRING);
System.out.println(" Auth Cookie ==== " + authCookie);
return isAuthenticated;
}
`
and the in the controller I used below code to call authenticate method:
AuthenticationServiceClient authenticationServiceClient = new AuthenticationServiceClient();
authenticationServiceClient.init();
authenticationServiceClient.authenticateUser("admin", "admin");
But the result is not good. The system inform that :
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:688)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:124)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:887)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at com.home.hduser.wsois.AuthenticationServiceClient.init(AuthenticationServiceClient.java:29)
I don't know why I can authenticate on console but can't on webapp
and the full trace error attached in the file below :
https://drive.google.com/open?id=0B9zEqmu0HBunSlp3X0dpWC1YU0E
I appreciate your help in this case.
Thanks

Just change this dependency in pom.xml file, set provided scope:
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.um.ws.api</artifactId>
<version>${carbon.identity.version}</version>
<scope>provided</scope>
</dependency>
To remove the tomcat dependencies:
[INFO] +- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.user.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.carbon:javax.cache.wso2:jar:4.4.1:provided
[INFO] | | | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:provided
[INFO] | | +- commons-dbcp.wso2:commons-dbcp:jar:1.4.0.wso2v1:provided
[INFO] | | +- org.apache.tomcat.wso2:jdbc-pool:jar:7.0.34.wso2v2:provided
[INFO] | | | \- org.apache.tomcat:tomcat-jdbc:jar:7.0.47:provided
[INFO] | | \- commons-collections.wso2:commons-collections:jar:3.2.0.wso2v1:provided
[INFO] | +- org.wso2.carbon.identity:org.wso2.carbon.user.mgt.common:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.orbit.com.hazelcast:hazelcast:jar:3.5.0.wso2v1:provided
[INFO] | | | \- com.hazelcast:hazelcast-all:jar:3.5:provided
[INFO] | | | +- com.eclipsesource.minimal-json:minimal-json:jar:0.9.2:provided
[INFO] | | | \- org.freemarker:freemarker:jar:2.3.22:provided
[INFO] | | +- org.eclipse.equinox:org.eclipse.equinox.http.helper:jar:1.1.0.wso2v1:provided
[INFO] | | \- org.apache.tomcat:tomcat-catalina-ha:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-juli:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-tribes:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-catalina:jar:7.0.59:provided
[INFO] | | | +- org.apache.tomcat:tomcat-annotations-api:jar:7.0.59:provided
[INFO] | | | \- org.apache.tomcat:tomcat-api:jar:7.0.59:provided
[INFO] | | \- org.apache.tomcat:tomcat-util:jar:7.0.59:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.authenticator.proxy:jar:4.4.1:provided
[INFO] | | \- org.wso2.carbon:org.wso2.carbon.core.common:jar:4.4.1:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.registry.core:jar:4.4.1:provided
[INFO] | | +- commons-io.wso2:commons-io:jar:2.0.0.wso2v2:provided
[INFO] | | +- net.sourceforge.findbugs:annotations:jar:1.3.2:provided
[INFO] | | +- org.wso2.carbon:org.wso2.carbon.registry.xboot:jar:4.4.1:provided
[INFO] | | +- org.compass-project.wso2:compass:jar:2.0.1.wso2v2:provided
[INFO] | | +- org.apache.abdera.wso2:abdera:jar:1.0.0.wso2v3:provided
[INFO] | | +- org.apache.poi.wso2:poi-scratchpad:jar:3.9.0.wso2v1:provided
[INFO] | | | \- org.apache.poi:poi-scratchpad:jar:3.9:provided
[INFO] | | | \- org.apache.poi:poi:jar:3.9:provided
[INFO] | | \- commons-pool.wso2:commons-pool:jar:1.5.6.wso2v1:provided
[INFO] | | \- commons-pool:commons-pool:jar:1.5.6:provided
[INFO] | \- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api.stub:jar:4.5.4:provided
EDIT: I had to set IS_HOME path absolute.
EDIT 2: To use relative path:
This method return the path to the wso2carbon.jks file:
public String setKeyStorePath(){
String path = System.getProperty("carbon.home") + File.separator +
"repository" + File.separator + "resources" +
File.separator + "security" +
File.separator + "wso2carbon.jks";
System.out.println("wso2carbon.jks path: " + path);
return path;
}
Modify the setKeyStore to use setKeyStorePath()
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", setKeyStorePath());
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}

I assume you're deploying your webapp in IS itself. I can see a lot of jars are packed in your war file. Most of them are already available in IS server.
Above error can happen due to dependency conflicts. See this for more information.
To get rid of the error, you can try setting <scope>provided</scope> to dependencies which are already available in the server.

Related

OpenStack Mistral workflow error while executing using GUI

I am getting error while executing OpenStack simple mistral workflow on OpenStack(wallaby) devstack environment. While I can execute the workflow from CLI command and got success But it fails if I try the same thing with GUI
root#openstack:~# openstack workflow definition show test_get
---
version: '2.0'
test_get:
description: Test Get.
tasks:
my_task:
action: std.http
input:
url: http://www.google.com
root#openstack:~# openstack workflow execution create test_get
+--------------------+--------------------------------------+
| Field | Value |
+--------------------+--------------------------------------+
| ID | 482e3803-45ef-411e-a0f4-1427abfc8649 |
| Workflow ID | 9dc0d4a4-8c5b-4288-8126-e1147da3bd02 |
| Workflow name | test_get |
| Workflow namespace | |
| Description | |
| Task Execution ID | <none> |
| Root Execution ID | <none> |
| State | RUNNING |
| State info | None |
| Created at | 2021-06-21 16:58:54 |
| Updated at | 2021-06-21 16:58:54 |
| Duration | ... |
+--------------------+--------------------------------------+
But while executing in GUI I get **
Execution is missing field "workflow_identifier"
**
Faced the same issue in Yoga release. Spent a few hours to investigate it and found interesting thing:
/usr/local/lib/python3.8/dist-packages/mistralclient/api/v2/executions.py
class ExecutionManager(base.ResourceManager):
resource_class = Execution
def create(self, wf_identifier='', namespace='',
workflow_input=None, description='', source_execution_id=None,
**params):
self._ensure_not_empty(
workflow_identifier=wf_identifier or source_execution_id
)
But! in the webform we are using workflow_identifier instead of wf_identifier
/usr/local/lib/python3.8/dist-packages/mistraldashboard/workflows/forms.py
def handle(self, request, data):
try:
data['workflow_identifier'] = data.pop('workflow_name')
data['workflow_input'] = {}
for param in self.workflow_parameters:
value = data.pop(param)
if value == "":
value = None
data['workflow_input'][param] = value
ex = api.execution_create(request, **data)
FIX is to rename workflow_identifier to wf_identifier in the form like
data['wf_identifier'] = data.pop('workflow_name')
After that mistral-dashboard works fine with execution creating.

Failing to start grakn

I'm trying to start grakn but it fails :
grakn server start
====================================================================================================
________ _____ _______ __ __ __ __ _______ _______ _____ _______
| __ || _ \ | _ || | / /| \ | | | _ || _ || _ \ | ____|
| | |__|| | | | | | | || | / / | \ | | | | |__|| | | || | | | | |
| | ____ | |_| / | |_| || |/ / | \| | | | | | | || |_| / | |____
| ||_ || _ \ | _ || _ \ | _ | | | __ | | | || _ \ | ____|
| |__| || | \ \ | | | || | \ \ | | \ | | |_| || |_| || | \ \ | |____
|________||__| \__\|__| |__||__| \__\|__| \__| |_______||_______||__| \__\|_______|
THE KNOWLEDGE GRAPH
====================================================================================================
Version: 1.8.3
Starting Storage....FAILED!
Unable to start Storage.
Process exited with code '1': 'Unrecognized VM option 'CrashOnOutOfMemoryError'
Did you mean 'OnOutOfMemoryError=<value>'?
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
'
An error has occurred during boot-up. Please run 'grakn server status' or check the logs located under the 'logs' directory.
Process exited with code '1': 'Unrecognized VM option 'CrashOnOutOfMemoryError'
Did you mean 'OnOutOfMemoryError=<value>'?
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
'
The most likely cause of this error is that you have an incompatible Java version installed.
You can check the Java version by running java -version in a terminal window.
Grakn 1.8 requires at least version 1.8.0_92 of Java to run.
See also https://github.com/graknlabs/grakn/issues/5267 for more discussion on this topic.

flyway outOfOrder is not working as expected

I am trying to apply an outOfOrder migration using maven on a "production support" branch (i.e. V3.1). The 3.1 branch has 12 migrations 3.1.0.1 through 3.1.0.12. The first 11 have been applied and in my development environment I have two migrations from the next release 3.3 already applied. the info looks like this:
+----------------+----------------------------+---------------------+---------+
| Version | Description | Installed on | State |
+----------------+----------------------------+---------------------+---------+
| 1 | > | 2013-08-16 16:35:22 | Success |
| 3.1.0.1 | CCI DDL | 2013-08-16 16:41:04 | Success |
| 3.1.0.2 | Update 1 | 2013-08-19 12:17:43 | Success |
| 3.1.0.3 | Add SVT ITEM HISTORY | 2013-08-21 16:24:28 | Success |
| 3.1.0.4 | Drop Col Event Key From ED | 2013-08-27 14:15:36 | Success |
| 3.1.0.5 | Add Job Begin Time COL | 2013-10-10 14:59:14 | Success |
| 3.1.0.6 | Update SVT Column Lengths | 2013-10-23 10:25:33 | Success |
| 3.1.0.7 | Add Seq Number to EDC ECRF | 2013-12-03 14:59:31 | Success |
| 3.1.0.8 | Set EDC ECRF ITEM Seq Numb | 2013-12-03 15:27:08 | Success |
| 3.1.0.9 | Add Table EDC USV FORM | 2013-12-03 15:37:47 | Success |
| 3.1.0.10 | Add Table SVT USV FORM MAP | 2013-12-03 15:52:24 | Success |
| 3.1.0.11 | Add Tables SUBJECT VISIT Q | 2014-04-29 17:09:13 | OutOrde |
| 3.1.0.12 | Add Table BOGUS ERIC TEST | | Ignored |
| 3.3.0.1 | Insert iMedidata CRS Info | 2014-04-24 10:50:38 | Future |
| 3.3.0.2 | Insert Study OBJECT TYPE | 2014-04-24 11:14:37 | Future |
+----------------+----------------------------+---------------------+---------+
I run the following command in my mvn build output folder in the V3.1 branch:
mvn flyway:migrate -Dflyway.outOfOrder=true -P
and I get the following output:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:3.0:migrate (default-cli) on project mdmws: org.flywaydb.core.api.FlywayException: Validate failed. Found differences between applied migrations and available migrations: Detected applied migration missing on the classpath: 3.3.0.1 -> [Help 1]
It seems to want to find the 3.3 migrations that have already been applied to the database in the same classpath target/db/migrations folder, but of course these files exist in a later release branch. Either I am missing some configuration setting or I do not understand the way the outOfOrder works. I do not want to pull these files back from the V3.3 branch to the V3.1 branch.
Can somebody please help explain?
My pom inherits the following from a parent pom and most of the configuration values are passed in from the profile:
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<driver>${flyway.driver}</driver>
<url>${flyway.url}</url>
<user>${flyway.user}</user>
<password>${flyway.password}</password>
<outOfOrder>${flyway.outOfOrder}</outOfOrder>
</configuration>
<dependencies>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
</plugin>
Set validateOnMigrate to false and you should be OK. By default it will check whether the resolved and the applied migrations match. In your specific situation this won't work, so you have to disable it.
That's my solution. I configured flyway in Java code. Yes, I set validateOnMigrate - false.
#Bean(name = "flyway")
#Lazy(false)
public Flyway buildConfiguredFlyway() {
Flyway flyway = configure();
if (!validate(flyway)) {
migrate(flyway);
}
return flyway;
}
private Flyway configure() {
Flyway flyway = new Flyway();
flyway.setDataSource(datasource);
flyway.setBaselineOnMigrate(true);//Create meta-data table if it did not exist.
flyway.setValidateOnMigrate(false);
return flyway;
}
private boolean validate(Flyway flyway) {
try {
flyway.validate();
return true;
} catch (FlywayException o) {
return false;
}
}
private void migrate(Flyway flyway) {
try {
int result = flyway.migrate();
LOGGER.info("Number of DB mirgations successfully applied: " + result);
} catch (FlywayException e) {
LOGGER.error(e.getMessage(), e);
((ConfigurableApplicationContext) applicationContext).stop();
}
}

How do I get a list of bundles in symfony2/symfony3?

I've just started using symfony and I'd like to get a list of bundles from a particular vendor, iterate through them and call a $bundle->renderSomething() function on each default controller.
Firstly, I need to get the list of bundles to iterate, or iterate through each object. Any ideas on the best way to do that?
The easiest way to do it in console and that outputs bundle names correctly is:
Symfony 2
php app/console config:dump-reference
Symfony 3
php bin/console config:dump-reference
The key here is not to provide any options or arguments. In this case, the command simply outputs all available bundles:
Available registered bundles with their extension alias if available:
+------------------------------------+-----------------------------------+
| Bundle name | Extension alias |
+------------------------------------+-----------------------------------+
| FrameworkBundle | framework |
| SecurityBundle | security |
| TwigBundle | twig |
| MonologBundle | monolog |
| SwiftmailerBundle | swiftmailer |
| DoctrineBundle | doctrine |
| AsseticBundle | assetic |
| GearmanBundle | gearman |
| SMMemcacheBundle | sm_memcache |
| PrestaSitemapBundle | presta_sitemap |
| DoctrineCacheBundle | doctrine_cache |
| CybernoxAmazonWebServicesBundle | cybernox_amazon_web_services |
| FOSFacebookBundle | fos_facebook |
| HWIOAuthBundle | hwi_oauth |
| FkrSimplePieBundle | fkr_simple_pie |
| RMSPushNotificationsBundle | rms_push_notifications |
| RobertoTruToInlineStyleEmailBundle | roberto_tru_to_inline_style_email |
| InsomniaMaxMindGeoIpBundle | insomnia_max_mind_geo_ip |
| EWZRecaptchaBundle | ewz_recaptcha |
| MopaBootstrapBundle | mopa_bootstrap |
| JanThomas89MailSafeBundle | jan_thomas89_mail_safe |
| WebProfilerBundle | web_profiler |
| SensioDistributionBundle | sensio_distribution |
| SensioGeneratorBundle | |
+------------------------------------+-----------------------------------+
If you have container object available then you can get array of the enabled bundles by $this->container->getParameter('kernel.bundles');
You can define a static function in each bundle. Ex: YourBundle::yourStaticFunction();
Use $this->container->getParameter('kernel.bundles') to get the list of bundles. This only returns the bundle class names instead of the Bundle object. Go through each bundle, check if the bundle has the function yourStaticFunction(), Hint: Use method_exists(). If the method exists, then call ::yourStaticFunction();
In console you can use php app/console container:debug --parameter=kernel.bundles
If you want to call a non static method of registered bundle object (not class) then you can do the following:
$kernel = $this->container->get('kernel');
$bundles = $kernel->getBundles();
$bundles['YourBundleName']->someMethod();
Where 'YourBundleName' is the name of your bundle, which you can get by calling from console:
php app/console config:dump-reference

can't add custom SBT action

I just got started with SBT.
To add a custom action, I made a following task and add that .scala file to 'project' folder as SBT wiki guides.
//MyProject.scala
import sbt._
class HelloWorldProject(info: ProjectInfo) extends DefaultProject(info)
{
lazy val hi = task { println("Hello World"); None }
}
after adding the scala src file for configuration, layout of the project folder look like this.
/development/scala/SomeScalaProject/
|~lib/
|~project/
| |~boot/
| | |~scala-2.7.7/
| | | |~lib/
| | | | |-scala-compiler.jar [RO]
| | | | `-scala-library.jar [RO]
| | | `~org.scala-tools.sbt/
| | | `~sbt/
| | | `+0.7.4/
| | |~scala-2.8.1/
| | | `~lib/
| | | |-scala-compiler.jar [RO]
| | | `-scala-library.jar [RO]
| | `-sbt.boot.lock
| |-build.properties
| |
| `-MyProject.scala //here
|
|+src/
But even after 'reload' or 'update', running the hi task in SBT is not available at all. what am i missing?
D:\development\scala\SBEStudy>java -Xmx512M -jar "D:\development\.common\sbt-la
nch-0.7.4.jar" update
[info] Building project SomeScalaProject 1.0 against Scala 2.8.1
[info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
[info]
[info] == update ==
[warn] No dependency configuration found, using defaults.
[info] :: retrieving :: nephilim.practice#scalabyexample_2.8.1 [sync]
[info] confs: [default]
[info] 0 artifacts copied, 0 already retrieved (0kB/391ms)
[info] == update ==
[success] Successful.
[info]
[info] Total time: 1 s, completed 2010. 12. 8 오후 7:14:39
[info]
[info] Total session time: 2 s, completed 2010. 12. 8 오후 7:14:39
[success] Build completed successfully.
> reload
[info] Building project SomeScalaProject 1.0 against Scala 2.8.1
[info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
> hi
[error] No action named 'hi' exists.
[info] Execute 'help' for a list of commands or 'actions' for a list of availab
e project actions and methods.
It was my mistake. :(
"MyProject.scala" should be located under /project/build directory instead of /project directory.

Resources