use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class PGPAction method configure.
/**
* Generates a keyring configuration with public keys and the private key.
*
* @throws ConfigurationException When the files do not exist, or unexpected PGP exception has occurred.
*/
public void configure() throws ConfigurationException {
try {
// Create configuration
KeyringConfigCallback callback = KeyringConfigCallbacks.withUnprotectedKeys();
if (secretPassword != null)
callback = KeyringConfigCallbacks.withPassword(secretPassword);
keyringConfig = KeyringConfigs.forGpgExportedKeys(callback);
// Add public keys
if (publicKeys != null) {
for (String s : publicKeys) {
URL url = ClassUtils.getResourceURL(this, s);
keyringConfig.addPublicKey(IOUtils.toByteArray(url.openStream()));
}
}
// Add private key
if (secretKey != null) {
URL url = ClassUtils.getResourceURL(this, secretKey);
keyringConfig.addSecretKey(IOUtils.toByteArray(url.openStream()));
}
} catch (IOException | PGPException e) {
throw new ConfigurationException("Unknown exception has occurred.", e);
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class GalmMonitorAdapter method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
hostname = Misc.getHostname();
AppConstants appConstants = AppConstants.getInstance();
sourceId = appConstants.getResolvedProperty(SOURCE_ID_KEY);
if (StringUtils.isEmpty(sourceId)) {
throw new ConfigurationException("cannot read sourceId from [" + SOURCE_ID_KEY + "]");
}
if (sourceId.indexOf(' ') >= 0) {
StringBuffer replacement = new StringBuffer();
boolean replacementsMade = false;
for (int i = 0; i < sourceId.length(); i++) {
char c = sourceId.charAt(i);
if (Character.isLetterOrDigit(c) || c == '_') {
replacement.append(c);
} else {
replacement.append('_');
replacementsMade = true;
}
}
if (replacementsMade) {
if (log.isDebugEnabled())
log.debug("sourceId [" + sourceId + "] read from [" + SOURCE_ID_KEY + "] contains spaces, replacing them with underscores, resulting in [" + replacement.toString() + "]");
sourceId = replacement.toString();
}
}
dtapStage = appConstants.getString(DTAP_STAGE_KEY, null);
if (StringUtils.isEmpty(dtapStage)) {
throw new ConfigurationException("cannot read dtapStage from [" + DTAP_STAGE_KEY + "]");
}
if (!("DEV".equals(dtapStage)) && !("TEST".equals(dtapStage)) && !("ACCEPT".equals(dtapStage)) && !("PROD".equals(dtapStage))) {
throw new ConfigurationException("dtapStage [" + dtapStage + "] read from [" + DTAP_STAGE_KEY + "] not equal to one of DEV, TEST, ACCEPT, PROD");
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class LdapQueryPipeBase method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
if (StringUtils.isNotEmpty(getLdapProviderURL())) {
if (StringUtils.isNotEmpty(getHost()) || getPort() > 0) {
throw new ConfigurationException("attributes 'host', 'port' and 'useSsl' cannot be used together with ldapProviderUrl");
}
} else {
if (StringUtils.isEmpty(getHost())) {
throw new ConfigurationException("either 'ldapProviderUrl' or 'host' (and possibly 'port' and 'useSsl') must be specified");
}
}
cf = new CredentialFactory(getAuthAlias(), getUsername(), getPassword());
if (StringUtils.isNotEmpty(getNotFoundForwardName())) {
notFoundForward = findForward(getNotFoundForwardName());
}
if (StringUtils.isNotEmpty(getExceptionForwardName())) {
exceptionForward = findForward(getExceptionForwardName());
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class SenderMonitorAdapter method configure.
@Override
public void configure() throws ConfigurationException {
if (getSender() == null) {
throw new ConfigurationException("No sender found");
}
if (StringUtils.isEmpty(getSender().getName())) {
getSender().setName("sender of " + getName());
}
super.configure();
if (!senderConfigured) {
getSender().configure();
senderConfigured = true;
} else {
try {
getSender().close();
} catch (SenderException e) {
log.error("cannot close sender", e);
}
}
try {
getSender().open();
} catch (SenderException e) {
throw new ConfigurationException("cannot open sender", e);
}
}
use of nl.nn.adapterframework.configuration.ConfigurationException in project iaf by ibissource.
the class Webservices method getWsdl.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/webservices/{resourceName}")
@Relation("webservices")
@Produces(MediaType.APPLICATION_XML)
public Response getWsdl(@PathParam("resourceName") String resourceName, @DefaultValue("true") @QueryParam("indent") boolean indent, @DefaultValue("false") @QueryParam("useIncludes") boolean useIncludes) throws ApiException {
String adapterName;
boolean zip;
int dotPos = resourceName.lastIndexOf('.');
if (dotPos >= 0) {
adapterName = resourceName.substring(0, dotPos);
zip = resourceName.substring(dotPos).equals(".zip");
} else {
adapterName = resourceName;
zip = false;
}
if (StringUtils.isEmpty(adapterName)) {
return Response.status(Response.Status.BAD_REQUEST).entity("<error>no adapter specified</error>").build();
}
IAdapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("<error>adapter not found</error>").build();
}
try {
String servletName = getServiceEndpoint(adapter);
String generationInfo = "by FrankConsole";
WsdlGenerator wsdl = new WsdlGenerator(adapter.getPipeLine(), generationInfo);
wsdl.setIndent(indent);
wsdl.setUseIncludes(useIncludes || zip);
wsdl.init();
StreamingOutput stream = new StreamingOutput() {
@Override
public void write(OutputStream out) throws IOException, WebApplicationException {
try {
if (zip) {
wsdl.zip(out, servletName);
} else {
wsdl.wsdl(out, servletName);
}
} catch (ConfigurationException | XMLStreamException | NamingException e) {
throw new WebApplicationException(e);
}
}
};
ResponseBuilder responseBuilder = Response.ok(stream);
if (zip) {
responseBuilder.type(MediaType.APPLICATION_OCTET_STREAM);
responseBuilder.header("Content-Disposition", "attachment; filename=\"" + adapterName + ".zip\"");
}
return responseBuilder.build();
} catch (Exception e) {
throw new ApiException("exception on retrieving wsdl", e);
}
}
Aggregations