001 /** 002 * Copyright 2009-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.codehaus.mojo.properties; 017 018 import org.apache.maven.plugin.AbstractMojo; 019 import org.apache.maven.plugin.MojoExecutionException; 020 import org.jasypt.util.text.BasicTextEncryptor; 021 022 /** 023 * Encrypt the specified text using the specified password 024 * 025 * @goal encrypt 026 */ 027 public class EncryptMojo extends AbstractMojo { 028 029 /** 030 * 031 * The password for encrypting text. This same password can be used to to decrypt the encrypted text 032 * 033 * @parameter expression="${crypto.password}" 034 * @required 035 */ 036 private String password; 037 038 /** 039 * 040 * The text to encrypt. 041 * 042 * @parameter expression="${crypto.text}" 043 * @required 044 */ 045 private String text; 046 047 @Override 048 public void execute() throws MojoExecutionException { 049 BasicTextEncryptor encryptor = new BasicTextEncryptor(); 050 encryptor.setPassword(password); 051 String encrypted = encryptor.encrypt(text); 052 getLog().info(text + " -> " + encrypted); 053 } 054 055 }