Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
first stub at #161 - send messages to secured broker
  • Loading branch information
dejanb committed Apr 10, 2013
1 parent 66bd2dc commit b98fafa
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
6 changes: 6 additions & 0 deletions hawtio-web/pom.xml
Expand Up @@ -154,6 +154,12 @@
<version>${activemq-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-jaas</artifactId>
<version>${activemq-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>${activemq-leveldb-artifactid}</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions hawtio-web/src/main/webapp/app/camel/js/send.ts
@@ -1,5 +1,5 @@
module Camel {
export function SendMessageController($scope, workspace:Workspace) {
export function SendMessageController($scope, workspace:Workspace, localStorage) {
var LANGUAGE_FORMAT_PREFERENCE = "defaultLanguageFormat";
var sourceFormat = workspace.getLocalStorage(LANGUAGE_FORMAT_PREFERENCE) || "javascript";
$scope.message = "";
Expand Down Expand Up @@ -58,7 +58,7 @@ module Camel {
notification("error", "Could not find CamelContext MBean!");
}
} else {
jolokia.execute(mbean, "sendTextMessage(java.lang.String)", body, onSuccess(sendWorked));
jolokia.execute(mbean, "sendTextMessage(java.lang.String, java.lang.String, java.lang.String)", body, localStorage["activemqUserName"], localStorage["activemqPassword"], onSuccess(sendWorked));
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions hawtio-web/src/main/webapp/app/core/html/preferences.html
Expand Up @@ -51,6 +51,24 @@
</div>
</div>
</form>

<strong>activemq</strong>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="activemqUserName" title="The user name to be used when connecting to the broker">User Name</label>

<div class="controls">
<input id="activemqUserName" type="text" placeholder="username" ng-model="activemqUserName"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="activemqPassword" title="Password to be used when connecting to the broker">Password</label>

<div class="controls">
<input id="activemqPassword" type="password" placeholder="password" ng-model="activemqPassword"/>
</div>
</div>
</form>
</div>

<!-- TODO Split into its file and include as a partial -->
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/core/js/preferences.ts
Expand Up @@ -21,7 +21,7 @@ module Core {
console.log("AutoRefresh", $scope.autoRefresh);
});

var names = ["gitUserName", "gitUserEmail"];
var names = ["gitUserName", "gitUserEmail", "activemqUserName", "activemqPassword"];
angular.forEach(names, (name) => {
$scope[name] = localStorage[name] || "";
$scope.$watch(name, () => {
Expand Down
20 changes: 18 additions & 2 deletions hawtio-web/src/test/resources/applicationContext.xml
Expand Up @@ -16,7 +16,7 @@
<!-- This creates an embedded ActiveMQ Broker -->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" useJmx="true">
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:31317)"/>
<networkConnector uri="static:(tcp://localhost:31317)" userName="admin" password="admin"/>
</networkConnectors>
<transportConnectors>
<transportConnector uri="tcp://localhost:31316"/>
Expand All @@ -25,11 +25,18 @@
<persistenceAdapter>
<levelDB directory="target/activemq/broker1/data/leveldb" logSize="107374182"/>
</persistenceAdapter>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="admin" password="admin" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
</broker>

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker2" useJmx="true">
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:31316)"/>
<networkConnector uri="static:(tcp://localhost:31316)" userName="admin" password="admin"/>
</networkConnectors>
<transportConnectors>
<transportConnector uri="tcp://localhost:31317"/>
Expand All @@ -38,13 +45,22 @@
<persistenceAdapter>
<levelDB directory="target/activemq/broker2/data/leveldb" logSize="107374182"/>
</persistenceAdapter>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="admin" password="admin" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
</broker>

<!-- Lets connect the Camel ActiveMQ component to the embedded broker.
See http://camel.apache.org/activemq.html for more information.
-->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="failover:tcp://localhost:31316"/>
<property name="userName" value="admin"/>
<property name="password" value="admin"/>
</bean>

<!-- tell Camel to use localhost as the JMX MBean naming to have a fixed name style -->
Expand Down

0 comments on commit b98fafa

Please sign in to comment.