use of io.jboot.exception.JbootIllegalConfigException in project jboot by yangfuhai.
the class JwtManager method createJwtToken.
public String createJwtToken(Map map) {
if (!config.isConfigOk()) {
throw new JbootIllegalConfigException("Can not create jwt, please config jboot.web.jwt.secret in jboot.properties.");
}
SecretKey secretKey = createSecretKey();
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
long nowMillis = System.currentTimeMillis();
Date now = new Date(nowMillis);
// 追加保存 JWT 的生成时间
map.put(JwtInterceptor.ISUUED_AT, nowMillis);
String subject = JsonKit.toJson(map);
JwtBuilder builder = Jwts.builder().setIssuedAt(now).setSubject(subject).signWith(signatureAlgorithm, secretKey);
if (config.getValidityPeriod() > 0) {
long expMillis = nowMillis + config.getValidityPeriod();
builder.setExpiration(new Date(expMillis));
}
return builder.compact();
}
use of io.jboot.exception.JbootIllegalConfigException in project jboot by yangfuhai.
the class JbootSeataManager method init.
public void init() {
if (!config.isEnable()) {
return;
}
if (!config.isConfigOk()) {
throw new JbootIllegalConfigException("please config applicationId and txServiceGroup for seata");
}
transactionManager = new SeataGlobalTransactionManager(config.getApplicationId(), config.getTxServiceGroup(), config.getMode());
transactionManager.init();
this.transactionalTemplate = new TransactionalTemplate();
this.globalLockTemplate = new GlobalLockTemplate();
this.enable = true;
}
use of io.jboot.exception.JbootIllegalConfigException in project jboot by yangfuhai.
the class CodeGenHelpler method createMetaBuilder.
public static MetaBuilder createMetaBuilder(DataSource dataSource, String type, boolean removeNoPrimaryKeyTable) {
MetaBuilder metaBuilder = removeNoPrimaryKeyTable ? new MetaBuilder(dataSource) : new MetaBuilder(dataSource) {
@Override
protected void removeNoPrimaryKeyTable(List<TableMeta> ret) {
// do Nothing...
}
};
metaBuilder.setGenerateRemarks(true);
switch(type) {
case DataSourceConfig.TYPE_MYSQL:
metaBuilder.setDialect(new MysqlDialect());
break;
case DataSourceConfig.TYPE_ORACLE:
metaBuilder.setDialect(new OracleDialect());
break;
case DataSourceConfig.TYPE_SQLSERVER:
metaBuilder.setDialect(new SqlServerDialect());
break;
case DataSourceConfig.TYPE_SQLITE:
metaBuilder.setDialect(new Sqlite3Dialect());
break;
case DataSourceConfig.TYPE_ANSISQL:
metaBuilder.setDialect(new AnsiSqlDialect());
break;
case DataSourceConfig.TYPE_POSTGRESQL:
metaBuilder.setDialect(new PostgreSqlDialect());
break;
default:
throw new JbootIllegalConfigException("only support datasource type : mysql、orcale、sqlserver、sqlite、ansisql and postgresql, please check your jboot.properties. ");
}
return metaBuilder;
}
use of io.jboot.exception.JbootIllegalConfigException in project jboot by yangfuhai.
the class ArpManager method configDialect.
/**
* 配置 数据源的 方言
*
* @param activeRecordPlugin
* @param datasourceConfig
*/
private void configDialect(ActiveRecordPlugin activeRecordPlugin, DataSourceConfig datasourceConfig) {
if (datasourceConfig.getDialectClass() != null) {
Dialect dialect = ClassUtil.newInstance(datasourceConfig.getDialectClass(), false);
if (dialect == null) {
throw new NullPointerException("can not new instance by class:" + datasourceConfig.getDialectClass());
}
activeRecordPlugin.setDialect(dialect);
return;
}
switch(datasourceConfig.getType()) {
case DataSourceConfig.TYPE_MYSQL:
activeRecordPlugin.setDialect(new JbootMysqlDialect());
break;
case DataSourceConfig.TYPE_ORACLE:
if (StrUtil.isBlank(datasourceConfig.getContainerFactory())) {
activeRecordPlugin.setContainerFactory(new CaseInsensitiveContainerFactory());
}
activeRecordPlugin.setDialect(new JbootOracleDialect());
break;
case DataSourceConfig.TYPE_SQLSERVER:
activeRecordPlugin.setDialect(new JbootSqlServerDialect());
break;
case DataSourceConfig.TYPE_SQLITE:
activeRecordPlugin.setDialect(new JbootSqlite3Dialect());
break;
case DataSourceConfig.TYPE_ANSISQL:
activeRecordPlugin.setDialect(new JbootAnsiSqlDialect());
break;
case DataSourceConfig.TYPE_POSTGRESQL:
activeRecordPlugin.setDialect(new JbootPostgreSqlDialect());
break;
case DataSourceConfig.TYPE_CLICKHOUSE:
activeRecordPlugin.setDialect(new JbootClickHouseDialect());
break;
case DataSourceConfig.TYPE_INFORMIX:
activeRecordPlugin.setDialect(new JbootInformixDialect());
break;
default:
throw new JbootIllegalConfigException("only support datasource type : mysql、orcale、sqlserver、sqlite、ansisql、postgresql and clickhouse, please check your jboot.properties. ");
}
}
Aggregations