001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.q2.security; 020 021import org.jdom2.Element; 022import org.jpos.q2.QBeanSupport; 023import org.jpos.q2.QFactory; 024import org.jpos.security.SMAdapter; 025import org.jpos.util.NameRegistrar; 026 027/** 028 * SMAdaptor Adaptor 029 * 030 * <b>Sample Configuration</b> 031 * <pre> 032 * <s-m-adaptor class="org.jpos.q2.security.SMAdaptor" logger="Q2"> 033 * <attr name="impl">org.jpos.security.jceadapter.JCESecurityModule</attr> 034 * 035 * <property name="provider" value="com.sun.crypto.provider.SunJCE" /> 036 * <property name="lmk" value="path/to/your/lmk" /> 037 * </s-m-adaptor> 038 * </pre> 039 * 040 * @author Hani Kirollos 041 * @author Alejandro Revilla 042 * @version $Revision$ $Date$ 043 */ 044public class SMAdaptor extends QBeanSupport implements SMAdaptorMBean 045{ 046 private static final String DEFAULT_IMPL = "org.jpos.security.jceadapter.JCESecurityModule"; 047 String clazz; 048 SMAdapter sm; 049 public SMAdaptor () { 050 super (); 051 clazz = DEFAULT_IMPL; 052 } 053 protected void initService () throws Exception { 054 Element e = getPersist (); 055 QFactory factory = getServer().getFactory(); 056 sm = (SMAdapter) factory.newInstance (getImpl ()); 057 factory.setLogger (sm, e); 058 factory.setConfiguration (sm, e); 059 NameRegistrar.register (getName (), sm); 060 } 061 062 public void setImpl (String clazz) { 063 this.clazz = clazz; 064 } 065 066 public String getImpl() { 067 return clazz; 068 } 069 protected void stopService () throws Exception { 070 NameRegistrar.unregister (getName ()); 071 } 072}