Author: chirino
Date: Thu Dec 16 21:33:34 2010
New Revision: 1050175
URL: http://svn.apache.org/viewvc?rev=1050175&view=rev
Log:
Added an encrypt and decrypt command tool
Added:
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Decrypt.scala
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Encrypt.scala
Modified:
activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/commands.index
Modified:
activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/commands.index
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/commands.index?rev=1050175&r1=1050174&r2=1050175&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/commands.index
(original)
+++
activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/commands.index
Thu Dec 16 21:33:34 2010
@@ -20,3 +20,5 @@ org.apache.activemq.apollo.cli.commands.
#org.apache.activemq.apollo.cli.commands.Start
org.apache.activemq.apollo.cli.commands.Stop
org.apache.activemq.apollo.cli.commands.Run
+org.apache.activemq.apollo.cli.commands.Encrypt
+org.apache.activemq.apollo.cli.commands.Decrypt
Added:
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Decrypt.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Decrypt.scala?rev=1050175&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Decrypt.scala
(added)
+++
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Decrypt.scala
Thu Dec 16 21:33:34 2010
@@ -0,0 +1,50 @@
+package org.apache.activemq.apollo.cli.commands
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.felix.gogo.commands.{Action, Option => option, Argument =>
argument, Command => command}
+import org.osgi.service.command.CommandSession
+import java.io.File
+import org.apache.activemq.apollo.util.Logging
+import org.apache.activemq.apollo.broker.security.EncryptionSupport
+import org.jasypt.properties.PropertyValueEncryptionUtils
+
+/**
+ * The apollo encrypt command
+ */
+...@command(scope="apollo", name = "decrypt", description = "decrypts a value")
+class Decrypt extends Action with Logging {
+
+ @argument(name = "value", description = "The value to decrypt", index=0,
required=true)
+ var value:String = _
+
+ def execute(session: CommandSession):AnyRef = {
+ try {
+ val unwrapped = if ( value.startsWith("ENC(") && value.endsWith(")") ) {
+ value.stripPrefix("ENC(").stripSuffix(")")
+ } else {
+ value
+ }
+
session.getConsole.println(EncryptionSupport.encryptor.decrypt(unwrapped));
+ } catch {
+ case x:Helper.Failure=> error(x.getMessage)
+ }
+ null
+ }
+
+
+}
\ No newline at end of file
Added:
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Encrypt.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Encrypt.scala?rev=1050175&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Encrypt.scala
(added)
+++
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Encrypt.scala
Thu Dec 16 21:33:34 2010
@@ -0,0 +1,44 @@
+package org.apache.activemq.apollo.cli.commands
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.felix.gogo.commands.{Action, Option => option, Argument =>
argument, Command => command}
+import org.osgi.service.command.CommandSession
+import java.io.File
+import org.apache.activemq.apollo.util.Logging
+import org.apache.activemq.apollo.broker.security.EncryptionSupport
+
+/**
+ * The apollo encrypt command
+ */
+...@command(scope="apollo", name = "encrypt", description = "encrypts a value")
+class Encrypt extends Action with Logging {
+
+ @argument(name = "value", description = "The value to encrypt", index=0,
required=true)
+ var value:String = _
+
+ def execute(session: CommandSession):AnyRef = {
+ try {
+
session.getConsole.println("ENC("+EncryptionSupport.encryptor.encrypt(value)+")");
+ } catch {
+ case x:Helper.Failure=> x.printStackTrace; error(x.getMessage)
+ }
+ null
+ }
+
+
+}
\ No newline at end of file