private void init(String sealAlgorithm, int sealKeySize) { if (sealAlgorithm == null || sealKeySize < 1) { return; } _sealAlgorithm = sealAlgorithm; try { KeyGenerator keyGenerator = KeyGenerator.getInstance(_sealAlgorithm); keyGenerator.init(sealKeySize); _secretKey = keyGenerator.generateKey(); } catch (NoSuchAlgorithmException nsae) { throw new SwitchYardException(nsae); } }
private void init(String sealAlgorithm, int sealKeySize) { if (sealAlgorithm == null || sealKeySize < 1) { return; } _sealAlgorithm = sealAlgorithm; try { KeyGenerator keyGenerator = KeyGenerator.getInstance(_sealAlgorithm); keyGenerator.init(sealKeySize); _secretKey = keyGenerator.generateKey(); } catch (NoSuchAlgorithmException nsae) { throw new SwitchYardException(nsae); } }
private String getTransactionManagerName(URI uri) { try { final Map<String, Object> parseParameters = URISupport.parseParameters(uri); String name = (String) parseParameters.get("transactionManager"); if (name != null) { name = name.replace("#", ""); } return name; } catch (URISyntaxException e) { throw new SwitchYardException(e); } }
private String getTransactionManagerName(URI uri) { try { final Map<String, Object> parseParameters = URISupport.parseParameters(uri); String name = (String) parseParameters.get("transactionManager"); if (name != null) { name = name.replace("#", ""); } return name; } catch (URISyntaxException e) { throw new SwitchYardException(e); } }
/** * Seals the specified object. * @param object the object * @return the sealed object */ public SealedObject seal(Serializable object) { try { Cipher cipher = Cipher.getInstance(_sealAlgorithm); cipher.init(Cipher.ENCRYPT_MODE, _secretKey); return new SealedObject(object, cipher); } catch (Exception e) { throw new SwitchYardException(e); } }
/** * Unseals the specified sealed object. * @param object the sealed object * @return the unsealed object */ public Serializable unseal(SealedObject object) { try { Cipher cipher = Cipher.getInstance(_sealAlgorithm); cipher.init(Cipher.DECRYPT_MODE, _secretKey); return (Serializable)object.getObject(cipher); } catch (Exception e) { throw new SwitchYardException(e); } }
/** * Seals the specified object. * @param object the object * @return the sealed object */ public SealedObject seal(Serializable object) { try { Cipher cipher = Cipher.getInstance(_sealAlgorithm); cipher.init(Cipher.ENCRYPT_MODE, _secretKey); return new SealedObject(object, cipher); } catch (Exception e) { throw new SwitchYardException(e); } }
/** * Unseals the specified sealed object. * @param object the sealed object * @return the unsealed object */ public Serializable unseal(SealedObject object) { try { Cipher cipher = Cipher.getInstance(_sealAlgorithm); cipher.init(Cipher.DECRYPT_MODE, _secretKey); return (Serializable)object.getObject(cipher); } catch (Exception e) { throw new SwitchYardException(e); } }
private UriBuilder createUriBuilder(URI baseUri, Class<?> resourceClass, Method method) { UriBuilder builder = null; try { builder = (UriBuilder)URIBUILDER_CLASS.newInstance(); } catch (Exception ie) { throw new SwitchYardException(ie); } builder.uri(baseUri); if (resourceClass.isAnnotationPresent(Path.class)) { builder.path(resourceClass); } if (_method.isAnnotationPresent(Path.class)) { builder.path(method); } return builder; }
/** * Get a JMS Session from an ActiveMQ connection. * @return JMS Session */ public Session getSession() { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(_url); try { if (_connection == null) { _connection = connectionFactory.createConnection(_user, _passwd); _connection.start(); } return _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { throw new SwitchYardException(e); } }
/** * Get a JMS Session from an ActiveMQ connection. * @return JMS Session */ public Session getSession() { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(_url); try { if (_connection == null) { _connection = connectionFactory.createConnection(_user, _passwd); _connection.start(); } return _connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (JMSException e) { throw new SwitchYardException(e); } }
private void init(String keyStoreLocation, String keyStoreType, char[] keyStorePassword, String keyAlias, char[] keyPassword, String keyTransformation) { if (keyStoreLocation == null) { return; } KeyStorePuller keyStorePuller = new KeyStorePuller(keyStoreType, keyStorePassword); KeyStore keyStore = keyStorePuller.pullPath(keyStoreLocation, getClass(), PathType.values()); try { Certificate certificate = keyStore.getCertificate(keyAlias); _publicKey = certificate.getPublicKey(); _keyTransformation = keyTransformation != null ? keyTransformation : _publicKey.getAlgorithm(); } catch (KeyStoreException kse) { throw new SwitchYardException(kse); } }
private void init(String keyStoreLocation, String keyStoreType, char[] keyStorePassword, String keyAlias, char[] keyPassword, String keyTransformation) { if (keyStoreLocation == null) { return; } KeyStorePuller keyStorePuller = new KeyStorePuller(keyStoreType, keyStorePassword); KeyStore keyStore = keyStorePuller.pullPath(keyStoreLocation, getClass(), PathType.values()); try { Certificate certificate = keyStore.getCertificate(keyAlias); _publicKey = certificate.getPublicKey(); _keyTransformation = keyTransformation != null ? keyTransformation : _publicKey.getAlgorithm(); } catch (KeyStoreException kse) { throw new SwitchYardException(kse); } }
@Override public void initialize() { super.initialize(); _composer = getMessageComposer(MappedRecordBindingData.class); _selector = getOperationSelector(MappedRecordBindingData.class); try { ConnectionFactory factory = (ConnectionFactory) new InitialContext().lookup(_connectionFactoryJNDIName); _recordFactory = factory.getRecordFactory(); } catch (Exception e) { throw new SwitchYardException(e); } }
private void bridgeOutgoingTransaction() { try { // disassociate subordinate JTA transaction InboundBridge txInboundBridge = InboundBridgeManager.getInboundBridge(); txInboundBridge.stop(); // disassociate WS-AT transaction final com.arjuna.mw.wst11.TransactionManager wsatManager = TransactionManagerFactory.transactionManager(); if (wsatManager != null) { wsatManager.suspend(); } } catch (final Throwable th) { throw new SwitchYardException(th); } }
private void bridgeOutgoingTransaction() { try { // disassociate subordinate JTA transaction InboundBridge txInboundBridge = InboundBridgeManager.getInboundBridge(); txInboundBridge.stop(); // disassociate WS-AT transaction final com.arjuna.mw.wst11.TransactionManager wsatManager = TransactionManagerFactory.transactionManager(); if (wsatManager != null) { wsatManager.suspend(); } } catch (final Throwable th) { throw new SwitchYardException(th); } }
/** * Loads the Clojure script. */ @Override protected void doStart() { try { final ClojureScriptModel scriptModel = _implModel.getScriptModel(); _var = scriptModel != null ? (Var) clojure.lang.Compiler.load(new StringReader(scriptModel.getScript())) : (Var) clojure.lang.Compiler.load(loadInputStream(_implModel.getScriptFile())); } catch (final Exception e) { throw new SwitchYardException(e); } }
/** * Loads the Clojure script. */ @Override protected void doStart() { try { final ClojureScriptModel scriptModel = _implModel.getScriptModel(); _var = scriptModel != null ? (Var) clojure.lang.Compiler.load(new StringReader(scriptModel.getScript())) : (Var) clojure.lang.Compiler.load(loadInputStream(_implModel.getScriptFile())); } catch (final Exception e) { throw new SwitchYardException(e); } }
/** * Activate JCA message inflow endpoint. */ @Override protected void doStart() { _metadata.getMessageEndpoint().initialize(); try { _metadata.getResourceAdapter().endpointActivation(this, _metadata.getActivationSpec()); } catch (ResourceException e) { throw new SwitchYardException(e); } }
private ServiceHandler handleImplementation(final ComponentServiceModel config, final QName serviceName) { final CamelComponentImplementationModel ccim = (CamelComponentImplementationModel)config.getComponent().getImplementation(); try { final String endpointUri = ComponentNameComposer.composeComponentUri(serviceName); final List<RouteDefinition> routeDefinitions = getRouteDefinition(ccim, getCamelContext()); verifyRouteDefinitions(routeDefinitions, ccim); getCamelContext().addRouteDefinitions(routeDefinitions); final SwitchYardEndpoint endpoint = getCamelContext().getEndpoint(endpointUri, SwitchYardEndpoint.class); endpoint.setMessageComposer(CamelComposition.getMessageComposer()); final SwitchYardConsumer consumer = endpoint.getConsumer(); consumer.setComponentName(config.getComponent().getQName()); consumer.setNamespace(serviceName.getNamespaceURI()); return consumer; } catch (final Exception e) { throw new SwitchYardException(e.getMessage(), e); } }