WSO2 ESB - Rampart Password Callback class - WSPasswordCallback cannot be cast - wso2

I want to to invoke a secured backend service in WSO2 ESB 5.0.0 with rampart configuration and Password Callback class
package com.yenlo.wso2.services;
import org.apache.ws.security.WSPasswordCallback;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import java.io.IOException;
public class PWCBHandler implements CallbackHandler {
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
// set the password for our message.
pc.setPassword("YENLO_TEST");
}
}
When i call the proxy service this error occurs:
org.apache.ws.security.WSPasswordCallback cannot be cast to org.apache.ws.security.WSPasswordCallback
I have compiled my source code with wss4j 1.6.17 and 1.5.12. Nothing's Changed.

I've created a new callbackhandler project from scratch and got it working with a few sidenodes:
- I've used the following dependency in the main pom.xml:
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.5.11</version>
</dependency>
I put the resulting '.jar' in repository/components/lib. Also I removed the .jar from repository/components/dropins when redeploying to be sure(ESB creates a file there during startup when processing the .jar)
I've put the entire project here. Build using 'mvn clean package'.
Good luck! I'd like to hear back if you succeeded!

Have a look at the available version of wss4j inside "wso2esb-5.0.0/repository/components/plugins" folder. It looks like you are using a different version in the compile time, that may lead to this kind of issue.
Try to use wss4j with the following dependency version when compiling.
version=1.5.11.wso2v14
groupId=org.apache.ws.security.wso2
artifactId=wss4j

Related

can't import the test helper addon in ember-cli-mirage

Facing the same issue - https://github.com/miragejs/ember-cli-mirage/issues/1445
Uncaught Error: Could not find module project-name/tests/helpers/push-mirage-into-store imported from project-name/mirage/factories/addon
Initially got this error and tried #makepanic instructions
After that
Uncaught Error: Could not find module #ember/test-helpers imported from project-name/mirage/helpers/push-mirage-into-store
can you pls help here to resolve this.
I bet you are running into the error, which is described in this comment by makepanic in the GitHub issue you linked:
When running the app directly, the browser opens index.html which
isn't loading tests.js. This file contains everything related to
tests.
If you open tests/index.html, that will also load tests.js and add any
modules under tests/* to the loader registry.
This means without the tests file loaded, you can't import anything
from tests/*.
You are affected by that issue if you face it when running ember serve.
The comment also includes a possible solution:
With you moving the helpers to /mirage, they gets registered in both index.html and tests/index.html.
An alternative would be to disable mirage in all enrironments except for test. But that is only a feasible solution if you use mirage only for testing but not for development.

how to resolve imports from shared package expo project in a monorepo

I have an import from a shared package of a typescript file inside my mobile package and currently using expo-yarn-workspaces;
import { ButtonStyles } from "#org/shared/components/button";
But then on running expo start --clear --web throws me an error
Module parse failed: Unexpected token (6:7)
You may need an appropriate loader to handle this file type.
| const ButtonTypes = tuple("outlined", "primary", "danger", "link");
Github issue merged here - https://github.com/expo/expo-cli/issues/1080
Due to some reason, we opted out the decision to use react-native itself. So, not tracking myself. Posting if someone finds it relevant for their work.

Unit testing Quartz plugin for Grails

I have some trouble writing the most basic unit test for a job. My problem can be recreated by creating a new job by running grails create-job my in the console.
This will create two files
MyJob.goovy (under the default package myApp - resides in test\unit\myApp)
MyJobSpec.groovy (under the default package myApp - resides in grails-app\jobs\myApp)
Now if i try to use the job MyJob in the test, as example
import myApp.MyJob //This is not resolved
#TestMixin(GrailsUnitTestMixin)
class MyJobSpec extends Specification {
def myJob
I get the compiler error Groovy:unable to resolve class MyJob. Everything so far was automatically created by the plugin. What is going on here? Is there something i did wrong / how do i get this to work?
Using grails 2.3.11.
I don't know which IDE are you using or if you are running everything on a terminal, but I had similar problems with Eclipse and what you need to do is to add grails-app/jobs to the classpath as a source folder.

javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found

I'm trying to consume a webservice in java, using a client generated from the wsdl file with wsdl2java.
I'm using Eclipse version Helios and jdk 1.6.0_20, and I've generated the .class files using wsld2java with the options:
"-d c:\WebServices\Generated -client -verbose -compile -autoNameResolution -p org.dwservice -sn DWService -wsdlLocation /WEB-INF/wsdl/DWService.wsdl c:\WebServices\DWService.wsdl"
I packed the resultant files into a .jar and added it to my project that compiles ok.
But when I try to use the webservice, I got the exception:
javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:311)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:302)
at javax.xml.ws.Service.getPort(Service.java:92)
at org.dwservice.DWService.getWSHttpBindingIDWService(DWService.java:63)
And this is my code:
import org.dwservice.*;
...
private DWService dwService = new DWService();
private IDWService iDWService = ***dwService.getWSHttpBindingIDWService()***;
Any idea would be very much appreciated.
I know this post is over a year old, but it's a highly ranked search result for this error. I'm adding this answer for posterity.
Your wsdl2java command suggests your WSDL is local and you're packaging it into a web app. I suspect the app isn't finding the packaged WSDL at runtime. One option is to load it as a Java resource and pass its location into your service's constructor:
QName qname = new QName("my.name.space", "myName");
URL wsdlLocation = MyServiceClient.class.getResource("/WEB-INF/wsdl/DWService.wsdl");
dwService = new DWService(wsdlLocation, qname);
If you use this approach, triple-check the path to your WSDL. It's easy for getResource() to silently fail, which will produce the same error.

Groovy/Grails Unit Test Error with custom codec

I am having an issue with the "Getting Started with Grails" tutorial from the Grails website. It is having me create a custom codec in the utils directory. I have created the codec and it works in the application, however when I add the codec to my controller unit test, as the tutorial suggests, it fails. Here is the message I get when I run "grails test-app UserController -unit":
"No such property: SHACodec for class: racetrack.UserControllerTests"
I have tried using the loadCodec() method to include the codec, but got the same message.
Does anyone have any suggestions on how to resolve this unit test issue? If it's an import issue, what would the import path be for my SHACodec.groovy file if it is in the /grails-app/utils/?
My tutorial code is available for download at http://arlitt.com/racetrack.zip.
I ran into this too (working through the code in the Grails book).
What I found works is this: explicitly load the codec. You don't need to include it in your imports. Make sure that the SHACodec.groovy file is in the grails-app/utils directory.
The following code snippet shows you how I did it.
class UserControllerTests extends ControllerUnitTestCase{
protected void setUp() {
super.setUp()
loadCodec (org.codehaus.groovy.grails.plugins.codecs.Base64Codec)
loadCodec (racetrack.SHACodec)
}
// ...
}
Codecs are not automatically loaded, you need to load them.
Refer to this post for more details: http://kousenit.wordpress.com/2010/02/24/using-a-codec-in-a-grails-unit-test/