최신버전에 맞는 타겟플렛폼 설정.
[Tadpole.git] / com.hangum.tadpole.commons.sql / src / com / hangum / tadpole / engine / security / PasswordDialog.java
blobe1e9b2c248c7ca7ed8d999ae9449856bfed0ce1a
1 /*******************************************************************************
2 * Copyright (c) 2017 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7 *
8 * Contributors:
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com.hangum.tadpole.engine.security;
13 import java.util.HashMap;
14 import java.util.Map;
16 import org.apache.log4j.Logger;
17 import org.eclipse.jface.dialogs.Dialog;
18 import org.eclipse.jface.dialogs.MessageDialog;
19 import org.eclipse.swt.widgets.Shell;
20 import org.eclipse.swt.widgets.Text;
22 import com.hangum.tadpole.commons.libs.core.define.PublicTadpoleDefine;
23 import com.hangum.tadpole.commons.libs.core.message.CommonMessages;
24 import com.hangum.tadpole.engine.manager.TadpoleSQLManager;
25 import com.hangum.tadpole.engine.query.dao.system.UserDBDAO;
26 import com.hangum.tadpole.ext.appm.APPMHandler;
27 import com.hangum.tadpole.preference.define.GetAdminPreference;
28 import com.hangum.tadpole.session.manager.SessionManager;
30 /**
31 * password dialog
33 * @author hangum
36 public abstract class PasswordDialog extends Dialog {
37 private static final Logger logger = Logger.getLogger(PasswordDialog.class);
39 protected UserDBDAO userDB;
40 protected Text textPassword;
42 /**
43 * password dialog
45 * @param parentShell
46 * @param userDB
48 protected PasswordDialog(Shell parentShell, UserDBDAO userDB) {
49 super(parentShell);
50 this.userDB = userDB;
53 /**
54 * initialize UI
56 protected void initUI() {
57 try {
58 String strCacchPassword = null;
59 if(PublicTadpoleDefine.YES_NO.YES.name().equals(GetAdminPreference.getIsPasswdCacheUse())) {
60 strCacchPassword = TadpoleSQLManager.getPassword(userDB);
63 if(strCacchPassword != null) {
64 textPassword.setText(strCacchPassword);
65 } else {
66 Map<String, String> mapAppm = new HashMap<String, String>();
67 mapAppm.put("ip", userDB.getHost());
68 mapAppm.put("port", userDB.getPort());
69 mapAppm.put("account", userDB.getUsers());
70 mapAppm.put("session.user", SessionManager.getEMAIL());
72 String strAMMPPassword = APPMHandler.getInstance().getPassword(mapAppm);
73 textPassword.setText(strAMMPPassword);
75 } catch (Exception e) {
76 TadpoleSQLManager.removePassword(userDB);
78 logger.error("appm error", e);
79 MessageDialog.openInformation(getShell(), CommonMessages.get().Error, "APPM interface error :" + e.getMessage());
81 textPassword.setText("");
82 } finally {
83 userDB.setPasswd("");