use of org.jaxen.FunctionCallException in project wso2-synapse by wso2.
the class HMACGenerateFunction method generateSignature.
/**
* Generate the HMAC signature against the secret for given algorithm
*
* @param payload The request body
* @param secret The secret
* @param algorithm The algorithm to generate signature
* @return The generated signature
* @throws FunctionCallException On error during HMAC signature generation
*/
private String generateSignature(String payload, String secret, String algorithm) throws FunctionCallException {
try {
Mac mac = getMacInstance(algorithm);
final SecretKeySpec signingKey = new SecretKeySpec(secret.getBytes(), algorithm);
mac.init(signingKey);
return toHexString(mac.doFinal(payload.getBytes()));
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
String msg = "Error while generating HMAC signature";
log.error(msg, e);
throw new FunctionCallException(msg, e);
}
}
use of org.jaxen.FunctionCallException in project intellij-community by JetBrains.
the class BasicFileInfoFunction method call.
@Nullable
@SuppressWarnings({ "RawUseOfParameterizedType" })
public Object call(Context context, List list) throws FunctionCallException {
final Object arg;
if (list.size() == 0) {
arg = context.getNodeSet().get(0);
} else {
final Object o = list.get(0);
arg = o instanceof List ? ((List) o).get(0) : o;
}
if (!(arg instanceof PsiElement)) {
throw new FunctionCallException("NodeSet expected");
}
final PsiFile psiFile = ((PsiElement) arg).getContainingFile();
assert psiFile != null;
return extractInfo(psiFile);
}
use of org.jaxen.FunctionCallException in project webservices-axiom by apache.
the class JaxenXPathTestBase method getNavigator.
protected final Navigator getNavigator() {
return new NavigatorWrapper(createNavigator()) {
// We need to tweak the getDocument method a bit to load the document from the right
// place.
public Object getDocument(String uri) throws FunctionCallException {
try {
URL url = new URL(TESTS_ROOT + uri);
Object document = loadDocument(url.openStream());
documents.add(document);
return document;
} catch (Exception ex) {
throw new FunctionCallException(ex);
}
}
};
}
use of org.jaxen.FunctionCallException in project mycore by MyCoRe-Org.
the class MCRFunctionCallJava method call.
@Override
public Object call(Context context, List args) throws FunctionCallException {
try {
String clazzName = (String) (args.get(0));
String methodName = (String) (args.get(1));
LOGGER.info("XEditor extension function calling {} {}", clazzName, methodName);
Class[] argTypes = new Class[args.size() - 2];
Object[] params = new Object[args.size() - 2];
for (int i = 0; i < argTypes.length; i++) {
argTypes[i] = args.get(i + 2).getClass();
params[i] = args.get(i + 2);
}
Class clazz = ClassUtils.getClass(clazzName);
Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, argTypes);
return method.invoke(null, params);
} catch (Exception ex) {
LOGGER.warn("Exception in call to external java method", ex);
return ex.getMessage();
}
}
use of org.jaxen.FunctionCallException in project webservices-axiom by apache.
the class DocumentNavigator method getDocument.
/**
* Loads a document from the given URI.
*
* @param uri the URI of the document to load
* @return Returns the document.
* @throws FunctionCallException if the document could not be loaded
*/
@Override
public Object getDocument(String uri) throws FunctionCallException {
InputStream in = null;
try {
if (uri.indexOf(':') == -1) {
in = new FileInputStream(uri);
} else {
URL url = new URL(uri);
in = url.openStream();
}
return OMXMLBuilderFactory.createOMBuilder(in).getDocument();
} catch (Exception e) {
if (in != null) {
try {
in.close();
} catch (IOException ex) {
// Ignore
}
}
throw new FunctionCallException(e);
}
}
Aggregations