Coverage Report - jp.co.y_net.amm.page.PasswordInfoPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
PasswordInfoPanel
0%
0/36
0%
0/20
0
PasswordInfoPanel$1
0%
0/9
0%
0/4
0
 
 1  0
 package jp.co.y_net.amm.page;
 2  
 
 3  
 import jp.co.y_net.amm.common.AppUtils;
 4  
 import jp.co.y_net.amm.common.CalcHash;
 5  
 import jp.co.y_net.amm.common.ResourceReader;
 6  
 import jp.co.y_net.amm.dao.Pwtckt;
 7  
 import jp.co.y_net.amm.dao.Usr;
 8  
 import jp.co.y_net.amm.service.PasswordTicketManager;
 9  
 
 10  
 import org.apache.wicket.markup.html.WebMarkupContainer;
 11  
 import org.apache.wicket.markup.html.basic.Label;
 12  
 import org.apache.wicket.markup.html.panel.Panel;
 13  
 import org.apache.wicket.spring.injection.annot.SpringBean;
 14  
 
 15  
 public class PasswordInfoPanel extends Panel {
 16  
     private static final long serialVersionUID = 1L;
 17  
     
 18  
     @SpringBean(name="passwordTicketManager")
 19  
     protected PasswordTicketManager passwordTicketManager;
 20  
     
 21  
     
 22  
     public PasswordInfoPanel(String id, Usr usr, boolean isSystemAdmin) {
 23  0
         this(id, usr, isSystemAdmin, false);
 24  0
     }
 25  
     public PasswordInfoPanel(String id, final Usr usr, boolean isSystemAdmin, boolean 有効期限を超過している場合も表示する) {
 26  0
         super(id);
 27  
         
 28  
         /*
 29  
          * 運営管理者でなければパネルごと非表示
 30  
          */
 31  0
         if(isSystemAdmin == false) {
 32  0
             this.setVisible(false);
 33  0
             return;
 34  
         }
 35  
         
 36  
         /* 対象ユーザが指定sれていなければパネルごと非表示 */
 37  0
         if(usr == null) {
 38  0
             this.setVisible(false);
 39  0
             return;
 40  
         }
 41  
         
 42  
         
 43  
         
 44  0
         Pwtckt pwtckt = passwordTicketManager.getユーザに紐づくチケット(usr.getUsrid());
 45  
         
 46  0
         String パスワード登録用のURL = "";
 47  0
         if(pwtckt != null) {
 48  0
             パスワード登録用のURL = ResourceReader.getStringQuick("urlroot") + "entrypassword?value=" + pwtckt.getTicket();
 49  
         }
 50  
         
 51  0
         String 有効期限 = "yyyy/MM/dd HH:mm:ss";
 52  0
         if(pwtckt != null) {
 53  0
             有効期限 = AppUtils.toStrYyyyMMdd_HHmmss(pwtckt.getTicketdate());
 54  
         }
 55  
         
 56  0
         Long now = AppUtils.createNowLong();
 57  0
         boolean is有効期限を超過している = false;
 58  0
         if(pwtckt != null) {
 59  0
             is有効期限を超過している = pwtckt.getTicketdate() < now; // 現在日付より過去のとき
 60  
         }
 61  
         
 62  
         
 63  
         
 64  
         /* パスワード登録用URLの発行状況の領域 */
 65  0
         WebMarkupContainer pwtcktInfo = new WebMarkupContainer("pwtcktInfo");
 66  0
         add(pwtcktInfo);
 67  
         
 68  0
         if(有効期限を超過している場合も表示する) {
 69  0
             pwtcktInfo.setVisible(pwtckt != null);
 70  
             
 71  0
         } else {
 72  0
             pwtcktInfo.setVisible(pwtckt != null && is有効期限を超過している == false);
 73  
         }
 74  
         
 75  
         
 76  
         /* URL */
 77  0
         Label url = new Label("url", パスワード登録用のURL);
 78  0
         pwtcktInfo.add(url);
 79  
         
 80  
         /* パスワードの有効期限 */
 81  0
         Label pwtcktLabel = new Label("pwtckt", 有効期限);
 82  0
         pwtcktInfo.add(pwtcktLabel);
 83  
         
 84  
         /* 「期限が切れています。」 */
 85  0
         Label msg = new Label("msg", "有効期限が切れています。");
 86  0
         msg.setVisible(is有効期限を超過している);
 87  0
         pwtcktInfo.add(msg);
 88  
         
 89  
         
 90  
         /*
 91  
          * 管理者のDefaultパスワードチェック
 92  
          */
 93  0
         Label adminInfo = new Label("adminInfo", "この管理者のパスワードは初期値のままです。"){
 94  
             @Override
 95  
             public boolean isVisible() {
 96  0
                 if(usr.getKind() == Usr.KIND_運営管理者) {
 97  0
                     String defaultPasshash = "";
 98  0
                     defaultPasshash = CalcHash.passowrdHash(Usr.管理者初期パスワード, usr.getLoginid()); // 初期パスワード
 99  0
                     if(usr.getPwhash().equals(defaultPasshash)) {
 100  0
                         return true;
 101  
                     } else {
 102  0
                         return false;
 103  
                     }
 104  
                 } else {
 105  0
                     return false;
 106  
                 }
 107  
             }
 108  
         };
 109  0
         add(adminInfo);
 110  0
     }
 111  
 
 112  
 
 113  
     
 114  
 
 115  
 }