Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Final NxnFormatter - It's a program created to format the content of topics
- * on VBulletin forums so that the text have a better look. It's an upgrade of
- * Uformatter.
- *
- * Copyright (C) 2014 Renan Gomes (rnxn) at <??????????@live.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package sys.models.ext;
- import sys.starter.SysInfoEnum;
- import java.io.UnsupportedEncodingException;
- import java.math.BigInteger;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import sys.data.exception.SysException;
- /**
- * <code>SysInfoUtils</code> contém algumas informações para a formatação final.
- * Somente para controle mesmo da aplicação.
- *
- * @author RENAN
- * @since 2014
- * @version 1.0*/
- public class SysInfoUtils {
- public final int INIT_DEV = 1;
- public final int INIT_NAME = 2;
- public final int INIT_COPY = 3;
- public final int INIT_DEV_CP = 4;
- public final int INIT_VER = 5;
- public final int ERR_VERSION = 100;
- public final int ERR_NOTAUTH = 101;
- //<sys sec>
- public String sec(String in){
- in = in.toLowerCase();
- try {
- MessageDigest a = MessageDigest.getInstance(SysInfoEnum.nxSysM5.getSysInfo());
- a.update(in.getBytes(SysInfoEnum.nxSysU5.getSysInfo()),Integer.parseInt(SysInfoEnum.nxSysZ5.getSysInfo()), in.length());
- BigInteger bInt = new BigInteger(Integer.parseInt(SysInfoEnum.nxSysO5.getSysInfo()), a.digest());
- return String.format("%1$032x", bInt);
- } catch (NoSuchAlgorithmException | UnsupportedEncodingException | NumberFormatException e){}
- return null;
- }
- // <sys err>
- private String sysErr(int m){
- return "#" + m;
- }
- // <sys ext ? "!important" : "el_init" -- rnxn >
- public boolean secExt() throws SysException{
- if(!secOK(INIT_DEV) || !secOK(INIT_DEV_CP) || !secOK(INIT_NAME) || !secOK(INIT_COPY))
- throw new SysException(sysErr(ERR_NOTAUTH));
- return true;
- }
- public boolean secVer() throws SysException{
- if(!secOK(INIT_VER))
- throw new SysException(sysErr(ERR_VERSION));
- return true;
- }
- //<sys bol>
- public boolean secOK(int type){
- switch(type){
- case INIT_DEV: return sec(SysInfoEnum.nxSysD5.getSysInfo()).equals(SecEnum.nD.get());
- case INIT_NAME: return sec(SysInfoEnum.nxSysN5.getSysInfo()).equals(SecEnum.nN.get());
- case INIT_COPY: return sec(SysInfoEnum.nxSysC5.getSysInfo()).equals(SecEnum.nC.get());
- case INIT_DEV_CP: return sec(SysInfoEnum.nxSysDCp.getSysInfo()).equals(SecEnum.nCP.get());
- case INIT_VER: return sec(SysInfoEnum.nxSysV5.getSysInfo()).equals(SecEnum.nV.get());
- default: return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement