Search in sources :

Example 76 with ConfigurationException

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);
    }
}
Also used : PGPException(org.bouncycastle.openpgp.PGPException) KeyringConfigCallback(name.neuhalfen.projects.crypto.bouncycastle.openpgp.keys.callbacks.KeyringConfigCallback) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) IOException(java.io.IOException) URL(java.net.URL)

Example 77 with ConfigurationException

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");
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 78 with ConfigurationException

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());
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory)

Example 79 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SenderException(nl.nn.adapterframework.core.SenderException)

Example 80 with ConfigurationException

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);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) OutputStream(java.io.OutputStream) StreamingOutput(javax.ws.rs.core.StreamingOutput) NamingException(javax.naming.NamingException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) WebApplicationException(javax.ws.rs.WebApplicationException) XMLStreamException(javax.xml.stream.XMLStreamException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) NamingException(javax.naming.NamingException) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) IAdapter(nl.nn.adapterframework.core.IAdapter) WsdlGenerator(nl.nn.adapterframework.soap.WsdlGenerator) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)187 IOException (java.io.IOException)52 PipeRunException (nl.nn.adapterframework.core.PipeRunException)25 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)24 Parameter (nl.nn.adapterframework.parameters.Parameter)20 ArrayList (java.util.ArrayList)19 URL (java.net.URL)17 ParameterList (nl.nn.adapterframework.parameters.ParameterList)16 SAXException (org.xml.sax.SAXException)14 TransformerException (javax.xml.transform.TransformerException)12 Test (org.junit.Test)12 CredentialFactory (nl.nn.adapterframework.util.CredentialFactory)11 HashMap (java.util.HashMap)10 File (java.io.File)9 StringTokenizer (java.util.StringTokenizer)8 Connection (java.sql.Connection)7 Map (java.util.Map)7 ListenerException (nl.nn.adapterframework.core.ListenerException)7 ParameterException (nl.nn.adapterframework.core.ParameterException)7 JdbcException (nl.nn.adapterframework.jdbc.JdbcException)7