All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jk.data.vendors.eclipselink.JKSessionPCustomizer Maven / Gradle / Ivy

Go to download

This contains a set of API's that ease the database programming with Java, in both: JDBC and JPA Persisitnce).

There is a newer version: 7.0.0-M7
Show newest version
/*
 * Copyright 2002-2022 Dr. Jalal Kiswani. 
 * Email: [email protected]
 * Check out https://smart-api.com for more details
 * 
 * All the opensource projects of Dr. Jalal Kiswani are free for personal and academic use only, 
 * for commercial usage and support, please contact the author.
 *
 * 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.
 */
package com.jk.data.vendors.eclipselink;


import java.util.Base64;
import java.util.Base64.Decoder;
import java.util.Properties;

// TODO: Auto-generated Javadoc
/**
 * The Class JKSessionPCustomizer.
 */
public class JKSessionPCustomizer {

	/**
	 * Customize.
	 *
	 * @param prop the prop
	 * @throws Exception the exception
	 */
	public void customize(Properties prop) throws Exception {
		Object userNameProperty = prop.getProperty("jk.username");
		Object passwordProperty = prop.getProperty("jk.password");
		System.out.println("Username : " + userNameProperty + " , Password : " + passwordProperty);

		String userName = decode(userNameProperty.toString());

		String password = decode(passwordProperty.toString());

//		prop.getLogin().setUserName(userName);
//		prop.getLogin().setPassword(password);
//
//		prop.getProperties().put("javax.persistence.jdbc.user", userName);
//		prop.getProperties().put("javax.persistence.jdbc.password", password);

	}

	/**
	 * Decode.
	 *
	 * @param name the name
	 * @return the string
	 */
	public static String decode(String name) {
		Decoder decoder = Base64.getDecoder();
		return new String(decoder.decode(name));
	}

	/**
	 * Encode.
	 *
	 * @param value the value
	 * @return the string
	 */
	public static String encode(String value) {
		return new String(Base64.getEncoder().encodeToString(value.getBytes()));
	}

	/**
	 * The main method.
	 *
	 * @param args the arguments
	 */
	public static void main(String[] args) {
		System.out.println(encode("root"));
		System.out.println(encode("123456"));
		System.out.println(decode("ZmluOTc1MzE="));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy