/** * Builds a RemoteConfiguration. * @return a RemoteConfiguration */ public RemoteConfiguration build() { return _remoteConfiguration.clone(); }
RemoteRestRuntimeEngineBuilderImpl() { this.config = new RemoteConfiguration(Type.REST); }
/** * Method to communicate with the backend via JMS. * * @param command The {@link Command} object to be executed. * @return The result of the {@link Command} object execution. */ private <T> T executeJmsCommand( Command command ) { Queue sendQueue; boolean isTaskCommand = (command instanceof TaskCommand); if( isTaskCommand ) { sendQueue = config.getTaskQueue(); if( ! config.getUseUssl() && ! config.getDisableTaskSecurity() ) { throw new RemoteCommunicationException("Task operation requests can only be sent via JMS if SSL is used."); } } else { sendQueue = config.getKsessionQueue(); } return internalExecuteJmsCommand(command, config.getConnectionUserName(), config.getConnectionPassword(), config.getUserName(), config.getPassword(), config.getDeploymentId(), config.getProcessInstanceId(), config.getCorrelationProperties(), config.getConnectionFactory(), sendQueue, config.getResponseQueue(), (SerializationProvider) config.getJaxbSerializationProvider(), config.getExtraJaxbClasses(), config.getSerializationType(), config.getTimeout()); }
public RemoteConfiguration(String deploymentId, InitialContext context, String username, String password) { this.deploymentId = deploymentId; this.type = Type.JMS; setAndCheckUserNameAndPassword(username, password); setRemoteInitialContext(context); }
@Test public void remoteConfigurationCloneTest() throws Exception { RemoteConfiguration orig = new RemoteConfiguration("deploy", mock(ConnectionFactory.class), mock(Queue.class), mock(Queue.class), mock(Queue.class), "user", "pass"); orig.setExtraJaxbClasses(new HashSet<Class<?>>()); orig.setProcessInstanceId(123l); orig.setRemoteInitialContext(remoteInitialContext); orig.setTimeout(23l); orig.setUseSsl(false); setField(orig, "jmsSerializationType", 4); RemoteConfiguration copy = orig.clone(); Field[] fields = RemoteConfiguration.class.getDeclaredFields(); for( Field field : fields ) { field.setAccessible(true); Object origVal = field.get(orig); assertNotNull( field.getName() + " should be set to a non-null value to be compared."); assertEquals( field.getName() + " not equal in RemoteConfiguration clone.", origVal, field.get(copy)); } }
if( config.getUserName() == null ) { throw new InsufficientInfoToBuildException("A user name is required to access the JMS queues!"); if( config.getPassword() == null ) { throw new InsufficientInfoToBuildException("A password is required to access the JMS queues!"); if( config.getUseUssl() ) { connParams = new HashMap<String, Object>(7); connParams.put(TransportConstants.PORT_PROP_NAME, jmsBuilder.jmsConnectorPort); config.setConnectionFactory(createdConnectionFactory); jmsBuilder.remoteInitialContext = getRemoteJbossInitialContext(jmsBuilder.jbossServerHostName, config.getUserName(), config.getPassword()); config.setRemoteInitialContext(jmsBuilder.remoteInitialContext); } else { config.checkValidJmsValues(); if( config.getServerBaseUrl() == null ) { throw new InsufficientInfoToBuildException("A URL is required to access the REST services."); if( config.getUserName() == null ) { throw new InsufficientInfoToBuildException("A user name is required to access the REST services."); if( config.getPassword() == null ) { throw new InsufficientInfoToBuildException("A password is required to access the REST services."); if( config.getServerBaseUrl() == null ) { throw new InsufficientInfoToBuildException("A URL is required to access the web services.");
@Override public RemoteApiResponse release( long taskId ) { RemoteApiResponse<Void> response; try { delegate.release(taskId, delegate.getConfig().getUserName()); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
config.getUserName(), config.getDeploymentId(), config.getProcessInstanceId(), config.getCorrelationProperties()); KieRemoteHttpRequest httpRequest = config.createHttpRequest().relativeRequest("/execute"); List<String[]> headers = config.getHeaders(); if( headers != null ) { for( String [] header : config.getHeaders() ) { httpRequest.header(header[0], header[1]); String deploymentId = config.getDeploymentId(); if( ! emptyDeploymentId(deploymentId) ) { httpRequest.header(JaxbSerializationProvider.EXECUTE_DEPLOYMENT_ID_HEADER, deploymentId); String jaxbRequestString = config.getJaxbSerializationProvider().serialize(jaxbRequest); if( logger.isTraceEnabled() ) { try { } else { if( responseStatus == 401 ) { String user = config.getUserName(); throw new RemoteApiException("User '" + user + "'is not authorized for the /rest/execute operation: does '" + user + "' have the 'rest-client' or 'rest-all' role?");
assertEquals( maryUser, maryConfig.getUserName()); assertEquals( maryPass, maryConfig.getPassword()); assertEquals( krisUser, krisConfig.getUserName()); assertEquals( krisPassword, krisConfig.getPassword()); assertEquals( johnUser, johnConfig.getUserName()); assertEquals( johnPassword, johnConfig.getPassword());
RemoteConfiguration config = new RemoteConfiguration("adsf", "user", "pwd" ); config.setServerBaseRestUrl(new URL("http://localhost:80808"));
void preprocessCommand( Command cmd ) { String cmdName = cmd.getClass().getSimpleName(); if( ! config.getDisableTaskSecurity() && cmd instanceof TaskCommand ) { TaskCommand taskCmd = (TaskCommand) cmd; String cmdUserId = taskCmd.getUserId(); String authUserId = config.getUserName(); if( cmdUserId == null ) { taskCmd.setUserId(authUserId); logger.debug("Using user id '" + authUserId + "' for '" + cmdName + "'."); } else if( ! cmdUserId.equals(authUserId) ) { throw new RemoteApiException("The user id used when retrieving task information (" + cmdUserId + ")" + " must match the authenticating user (" + authUserId + ")!"); } } }
@Override public RemoteWebserviceClientBuilder addTimeout(int timeoutInSeconds) { config.setTimeout(timeoutInSeconds); return this; }
@Override public T addProcessInstanceId( long processInstanceId ) { this.config.setProcessInstanceId(processInstanceId); return (T) this; }
@Override public RemoteJmsRuntimeEngineBuilderImpl useSsl(boolean useSsl) { this.createOwnFactory = useSsl; this.config.setUseSsl(useSsl); return this; }
@Override public RemoteRestRuntimeEngineBuilderImpl addUrl(URL url) { config.setServerBaseRestUrl(url); return this; }
@Test public void remoteConfigurationCloneTest() throws Exception { RemoteConfiguration orig = new RemoteConfiguration("deploy", mock(ConnectionFactory.class), mock(Queue.class), mock(Queue.class), mock(Queue.class), "user", "pass"); orig.setExtraJaxbClasses(new HashSet<Class<?>>()); orig.setProcessInstanceId(123l); orig.setRemoteInitialContext(remoteInitialContext); orig.setTimeout(23l); orig.setUseSsl(false); setField(orig, "jmsSerializationType", 4); RemoteConfiguration copy = orig.clone(); Field[] fields = RemoteConfiguration.class.getDeclaredFields(); for( Field field : fields ) { field.setAccessible(true); Object origVal = field.get(orig); assertNotNull( field.getName() + " should be set to a non-null value to be compared."); assertEquals( field.getName() + " not equal in RemoteConfiguration clone.", origVal, field.get(copy)); } }
@Override public RemoteApiResponse activate( long taskId ) { RemoteApiResponse<Void> response; try { delegate.activate(taskId, delegate.getConfig().getUserName()); response = new RemoteApiResponse<Void>(); } catch( RemoteClientException rce ) { response = createRemoteApiResponse(rce); } catch( Exception e ) { response = new RemoteApiResponse<Void>(RemoteOperationStatus.UNKNOWN_FAILURE, e); } return response; }
assertEquals( maryUser, maryConfig.getUserName()); assertEquals( maryPass, maryConfig.getPassword()); assertEquals( krisUser, krisConfig.getUserName()); assertEquals( krisPassword, krisConfig.getPassword()); assertEquals( johnUser, johnConfig.getUserName()); assertEquals( johnPassword, johnConfig.getPassword());
@Override public T addTimeout(int timeoutInSeconds) { config.setTimeout(timeoutInSeconds); return (T) this; }
@Test public void remoteConfigurationCloneTest() throws Exception { RemoteConfiguration orig = new RemoteConfiguration("deploy", mock(ConnectionFactory.class), mock(Queue.class), mock(Queue.class), mock(Queue.class), "user", "pass"); orig.setExtraJaxbClasses(new HashSet<Class<?>>()); orig.setProcessInstanceId(123l); orig.setRemoteInitialContext(remoteInitialContext); orig.setTimeout(23l); orig.setUseSsl(false); setField(orig, "jmsSerializationType", 4); setField(orig, "requestFactory", mock(ClientRequestFactory.class)); RemoteConfiguration copy = orig.clone(); Field[] fields = RemoteConfiguration.class.getDeclaredFields(); for( Field field : fields ) { field.setAccessible(true); Object origVal = field.get(orig); assertNotNull( field.getName() + " should be set to a non-null value to be compared."); assertEquals( field.getName() + " not equal in RemoteConfiguration clone.", origVal, field.get(copy)); } }