Advertisement
xlrnxnlx

owner-3

Sep 21st, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.44 KB | None | 0 0
  1. /*
  2.  * Final NxnFormatter - It's a program created to format the content of topics
  3.  * on VBulletin forums so that the text have a better look. It's an upgrade of
  4.  * Uformatter.
  5.  *
  6.  * Copyright (C) 2014 Renan Gomes (rnxn) at <??????????@live.com>
  7.  *
  8.  * This program is free software: you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation, either version 3 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  */
  20.  
  21. package sys.models.ext;
  22.  
  23. import sys.starter.SysInfoEnum;
  24. import java.io.UnsupportedEncodingException;
  25. import java.math.BigInteger;
  26. import java.security.MessageDigest;
  27. import java.security.NoSuchAlgorithmException;
  28. import sys.data.exception.SysException;
  29.  
  30. /**
  31.  * <code>SysInfoUtils</code> contém algumas informações para a formatação final.
  32.  * Somente para controle mesmo da aplicação.
  33.  *
  34.  * @author RENAN
  35.  * @since 2014
  36.  * @version 1.0*/
  37.  
  38. public class SysInfoUtils {
  39.    
  40.     public final int INIT_DEV = 1;
  41.     public final int INIT_NAME = 2;
  42.     public final int INIT_COPY = 3;
  43.     public final int INIT_DEV_CP = 4;
  44.     public final int INIT_VER = 5;
  45.    
  46.     public final int ERR_VERSION = 100;
  47.     public final int ERR_NOTAUTH = 101;
  48.    
  49.     //<sys sec>
  50.     public String sec(String in){
  51.         in = in.toLowerCase();
  52.         try {
  53.             MessageDigest a = MessageDigest.getInstance(SysInfoEnum.nxSysM5.getSysInfo());
  54.             a.update(in.getBytes(SysInfoEnum.nxSysU5.getSysInfo()),Integer.parseInt(SysInfoEnum.nxSysZ5.getSysInfo()), in.length());
  55.             BigInteger bInt = new BigInteger(Integer.parseInt(SysInfoEnum.nxSysO5.getSysInfo()), a.digest());
  56.             return String.format("%1$032x", bInt);  
  57.         } catch (NoSuchAlgorithmException | UnsupportedEncodingException | NumberFormatException e){}
  58.         return null;
  59.     }
  60.    
  61.     // <sys err>
  62.     private String sysErr(int m){
  63.         return "#" + m;
  64.     }
  65.    
  66.    
  67.     // <sys ext ? "!important" : "el_init" -- rnxn >
  68.     public boolean secExt() throws SysException{
  69.         if(!secOK(INIT_DEV) || !secOK(INIT_DEV_CP) || !secOK(INIT_NAME) || !secOK(INIT_COPY))
  70.             throw new SysException(sysErr(ERR_NOTAUTH));
  71.         return true;
  72.     }
  73.    
  74.     public boolean secVer() throws SysException{
  75.         if(!secOK(INIT_VER))
  76.             throw new SysException(sysErr(ERR_VERSION));
  77.         return true;
  78.     }
  79.    
  80.     //<sys bol>
  81.     public boolean secOK(int type){
  82.         switch(type){
  83.             case INIT_DEV: return sec(SysInfoEnum.nxSysD5.getSysInfo()).equals(SecEnum.nD.get());
  84.             case INIT_NAME: return sec(SysInfoEnum.nxSysN5.getSysInfo()).equals(SecEnum.nN.get());
  85.             case INIT_COPY: return sec(SysInfoEnum.nxSysC5.getSysInfo()).equals(SecEnum.nC.get());
  86.             case INIT_DEV_CP: return sec(SysInfoEnum.nxSysDCp.getSysInfo()).equals(SecEnum.nCP.get());
  87.             case INIT_VER: return sec(SysInfoEnum.nxSysV5.getSysInfo()).equals(SecEnum.nV.get());
  88.             default: return false;
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement