mirror of
https://gitee.com/dromara/hutool.git
synced 2025-07-15 23:13:33 +08:00
fix code
This commit is contained in:
parent
64c1dc554b
commit
ebf1632f36
@ -13,7 +13,8 @@
|
|||||||
package org.dromara.hutool.core.lang.wrapper;
|
package org.dromara.hutool.core.lang.wrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简单包装对象
|
* 简单包装对象<br>
|
||||||
|
* 通过继承此类,可以直接使用被包装的对象,用于简化和统一封装。
|
||||||
*
|
*
|
||||||
* @param <T> 被包装对象类型
|
* @param <T> 被包装对象类型
|
||||||
* @author looly
|
* @author looly
|
||||||
|
@ -49,17 +49,17 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlgorithmName() {
|
public String getAlgorithmName() {
|
||||||
return getRaw().getAlgorithm();
|
return this.raw.getAlgorithm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockSize() {
|
public int getBlockSize() {
|
||||||
return getRaw().getBlockSize();
|
return this.raw.getBlockSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOutputSize(final int len) {
|
public int getOutputSize(final int len) {
|
||||||
return getRaw().getOutputSize(len);
|
return this.raw.getOutputSize(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,7 +82,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
* @throws InvalidKeyException 无效key
|
* @throws InvalidKeyException 无效key
|
||||||
*/
|
*/
|
||||||
public void init(final int mode, final JceParameters jceParameters) throws InvalidAlgorithmParameterException, InvalidKeyException {
|
public void init(final int mode, final JceParameters jceParameters) throws InvalidAlgorithmParameterException, InvalidKeyException {
|
||||||
final javax.crypto.Cipher cipher = getRaw();
|
final javax.crypto.Cipher cipher = this.raw;
|
||||||
if (null != jceParameters.parameterSpec) {
|
if (null != jceParameters.parameterSpec) {
|
||||||
if (null != jceParameters.random) {
|
if (null != jceParameters.random) {
|
||||||
cipher.init(mode, jceParameters.key, jceParameters.parameterSpec, jceParameters.random);
|
cipher.init(mode, jceParameters.key, jceParameters.parameterSpec, jceParameters.random);
|
||||||
@ -101,7 +101,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
@Override
|
@Override
|
||||||
public int process(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) {
|
public int process(final byte[] in, final int inOff, final int len, final byte[] out, final int outOff) {
|
||||||
try {
|
try {
|
||||||
return getRaw().update(in, inOff, len, out, outOff);
|
return this.raw.update(in, inOff, len, out, outOff);
|
||||||
} catch (final ShortBufferException e) {
|
} catch (final ShortBufferException e) {
|
||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
@Override
|
@Override
|
||||||
public int doFinal(final byte[] out, final int outOff) {
|
public int doFinal(final byte[] out, final int outOff) {
|
||||||
try {
|
try {
|
||||||
return getRaw().doFinal(out, outOff);
|
return this.raw.doFinal(out, outOff);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ public class JceCipher extends SimpleWrapper<javax.crypto.Cipher> implements Cip
|
|||||||
@Override
|
@Override
|
||||||
public byte[] processFinal(final byte[] data) {
|
public byte[] processFinal(final byte[] data) {
|
||||||
try {
|
try {
|
||||||
return getRaw().doFinal(data);
|
return this.raw.doFinal(data);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ public class Digester extends SimpleWrapper<MessageDigest> implements Serializab
|
|||||||
// 加盐在末尾,自动忽略空盐值
|
// 加盐在末尾,自动忽略空盐值
|
||||||
result = doDigest(data, this.salt);
|
result = doDigest(data, this.salt);
|
||||||
} else if (ArrayUtil.isNotEmpty(this.salt)) {
|
} else if (ArrayUtil.isNotEmpty(this.salt)) {
|
||||||
final MessageDigest digest = getRaw();
|
final MessageDigest digest = this.raw;
|
||||||
// 加盐在中间
|
// 加盐在中间
|
||||||
digest.update(data, 0, this.saltPosition);
|
digest.update(data, 0, this.saltPosition);
|
||||||
digest.update(this.salt);
|
digest.update(this.salt);
|
||||||
|
@ -41,29 +41,29 @@ public class BCMacEngine extends SimpleWrapper<Mac> implements MacEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final byte[] in, final int inOff, final int len) {
|
public void update(final byte[] in, final int inOff, final int len) {
|
||||||
getRaw().update(in, inOff, len);
|
this.raw.update(in, inOff, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] doFinal() {
|
public byte[] doFinal() {
|
||||||
final byte[] result = new byte[getMacLength()];
|
final byte[] result = new byte[getMacLength()];
|
||||||
getRaw().doFinal(result, 0);
|
this.raw.doFinal(result, 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
getRaw().reset();
|
this.raw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMacLength() {
|
public int getMacLength() {
|
||||||
return getRaw().getMacSize();
|
return this.raw.getMacSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlgorithm() {
|
public String getAlgorithm() {
|
||||||
return getRaw().getAlgorithmName();
|
return this.raw.getAlgorithmName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,32 +70,32 @@ public class JCEMacEngine extends SimpleWrapper<Mac> implements MacEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final byte[] in) {
|
public void update(final byte[] in) {
|
||||||
getRaw().update(in);
|
this.raw.update(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(final byte[] in, final int inOff, final int len) {
|
public void update(final byte[] in, final int inOff, final int len) {
|
||||||
getRaw().update(in, inOff, len);
|
this.raw.update(in, inOff, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] doFinal() {
|
public byte[] doFinal() {
|
||||||
return getRaw().doFinal();
|
return this.raw.doFinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
getRaw().reset();
|
this.raw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMacLength() {
|
public int getMacLength() {
|
||||||
return getRaw().getMacLength();
|
return this.raw.getMacLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlgorithm() {
|
public String getAlgorithm() {
|
||||||
return getRaw().getAlgorithm();
|
return this.raw.getAlgorithm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,52 +71,52 @@ public class DSWrapper extends SimpleWrapper<DataSource> implements DataSource,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PrintWriter getLogWriter() throws SQLException {
|
public PrintWriter getLogWriter() throws SQLException {
|
||||||
return getRaw().getLogWriter();
|
return this.raw.getLogWriter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLogWriter(final PrintWriter out) throws SQLException {
|
public void setLogWriter(final PrintWriter out) throws SQLException {
|
||||||
getRaw().setLogWriter(out);
|
this.raw.setLogWriter(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLoginTimeout(final int seconds) throws SQLException {
|
public void setLoginTimeout(final int seconds) throws SQLException {
|
||||||
getRaw().setLoginTimeout(seconds);
|
this.raw.setLoginTimeout(seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLoginTimeout() throws SQLException {
|
public int getLoginTimeout() throws SQLException {
|
||||||
return getRaw().getLoginTimeout();
|
return this.raw.getLoginTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||||
return getRaw().getParentLogger();
|
return this.raw.getParentLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T unwrap(final Class<T> iface) throws SQLException {
|
public <T> T unwrap(final Class<T> iface) throws SQLException {
|
||||||
return getRaw().unwrap(iface);
|
return this.raw.unwrap(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWrapperFor(final Class<?> iface) throws SQLException {
|
public boolean isWrapperFor(final Class<?> iface) throws SQLException {
|
||||||
return getRaw().isWrapperFor(iface);
|
return this.raw.isWrapperFor(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
return getRaw().getConnection();
|
return this.raw.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection(final String username, final String password) throws SQLException {
|
public Connection getConnection(final String username, final String password) throws SQLException {
|
||||||
return getRaw().getConnection(username, password);
|
return this.raw.getConnection(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
final DataSource ds = getRaw();
|
final DataSource ds = this.raw;
|
||||||
if (ds instanceof AutoCloseable) {
|
if (ds instanceof AutoCloseable) {
|
||||||
IoUtil.closeQuietly((AutoCloseable) ds);
|
IoUtil.closeQuietly((AutoCloseable) ds);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user