代码优化

This commit is contained in:
MaxKey
2024-01-13 21:48:32 +08:00
parent 47c725624c
commit a1213a7539
64 changed files with 341 additions and 144 deletions

View File

@@ -48,6 +48,7 @@ public class LightNoise extends Configurable implements NoiseProducer
* @param factorThree
* @param factorFour
*/
@Override
public void makeNoise(BufferedImage image, float factorOne,
float factorTwo, float factorThree, float factorFour)
{
@@ -100,8 +101,9 @@ public class LightNoise extends Configurable implements NoiseProducer
// for the maximum 3 point change the stroke and direction
for (i = 0; i < pts.length - 1; i++)
{
if (i < 3)
if (i < 3) {
graph.setStroke(new BasicStroke(0.7f * (2 - i)));
}
graph.drawLine((int) pts[i].getX(), (int) pts[i].getY(),
(int) pts[i + 1].getX(), (int) pts[i + 1].getY());
}

View File

@@ -37,6 +37,7 @@ public class Ripple extends Configurable implements GimpyEngine
* @param baseImage the base image
* @return the distorted image
*/
@Override
public BufferedImage getDistortedImage(BufferedImage baseImage)
{
NoiseProducer noiseProducer = getConfig().getNoiseImpl();

View File

@@ -49,6 +49,7 @@ public class RandomColorWordRenderer extends Configurable implements WordRendere
* The height of the image to be created.
* @return The BufferedImage created from the word.
*/
@Override
public BufferedImage renderWord(String word, int width, int height)
{
int fontSize = getConfig().getTextProducerFontSize();

View File

@@ -97,6 +97,7 @@ public class InMemorySessionManager implements SessionManager{
return session;
}
@Override
public int getValiditySeconds() {
return validitySeconds;
}

View File

@@ -92,7 +92,7 @@ public class RedisSessionManager implements SessionManager {
return session;
}
@Override
public int getValiditySeconds() {
return validitySeconds;
}

View File

@@ -85,6 +85,7 @@ public class SessionManagerFactory implements SessionManager{
}
}
@Override
public void create(String sessionId, Session session) {
inMemorySessionManager.create(sessionId, session);
if(isRedis) {
@@ -92,6 +93,7 @@ public class SessionManagerFactory implements SessionManager{
}
}
@Override
public Session remove(String sessionId) {
Session session = inMemorySessionManager.remove(sessionId);
if(isRedis) {
@@ -100,6 +102,7 @@ public class SessionManagerFactory implements SessionManager{
return session;
}
@Override
public Session get(String sessionId) {
Session session = inMemorySessionManager.get(sessionId);
if(session == null && isRedis) {
@@ -108,6 +111,7 @@ public class SessionManagerFactory implements SessionManager{
return session;
}
@Override
public Session refresh(String sessionId, LocalDateTime refreshTime) {
Session session = null;
if(isRedis) {
@@ -120,6 +124,7 @@ public class SessionManagerFactory implements SessionManager{
return session;
}
@Override
public Session refresh(String sessionId) {
Session session = null;
if(isRedis) {
@@ -134,6 +139,7 @@ public class SessionManagerFactory implements SessionManager{
return session;
}
@Override
public List<HistoryLogin> querySessions() {
//clear session id is null
jdbcTemplate.execute(NO_SESSION_UPDATE_STATEMENT);
@@ -158,6 +164,7 @@ public class SessionManagerFactory implements SessionManager{
new int[] { Types.VARCHAR, Types.VARCHAR });
}
@Override
public void terminate(String sessionId, String userId, String username) {
String lastLogoffTime = DateUtils.formatDateTime(new Date());
_logger.trace("{} user {} terminate session {} ." ,lastLogoffTime,username, sessionId);
@@ -166,6 +173,7 @@ public class SessionManagerFactory implements SessionManager{
this.remove(sessionId);
}
@Override
public int getValiditySeconds() {
return validitySeconds;
}

View File

@@ -27,15 +27,17 @@ public abstract class AbstractIpLocation implements IpLocation{
int failCount = 0;
@Override
public int getFailCount() {
return failCount;
};
@Override
public int plusFailCount() {
return failCount++;
};
@Override
public String getLocation(String region) {
if(region.endsWith("电信") || region.endsWith("移动") || region.endsWith("联通")) {
region.substring(0, region.length() - 2).trim();

View File

@@ -22,8 +22,7 @@ import org.springframework.security.core.Authentication;
public class AuthenticationProviderFactory extends AbstractAuthenticationProvider {
private static ConcurrentHashMap<String,AbstractAuthenticationProvider> providers =
new ConcurrentHashMap<String,AbstractAuthenticationProvider>();
private static ConcurrentHashMap<String,AbstractAuthenticationProvider> providers = new ConcurrentHashMap<>();
@Override
public Authentication authenticate(LoginCredential authentication){

View File

@@ -42,9 +42,9 @@ import org.springframework.security.core.AuthenticationException;
*
*/
public class MfaAuthenticationProvider extends AbstractAuthenticationProvider {
private static final Logger _logger =
LoggerFactory.getLogger(MfaAuthenticationProvider.class);
private static final Logger _logger = LoggerFactory.getLogger(MfaAuthenticationProvider.class);
@Override
public String getProviderName() {
return "mfa" + PROVIDER_SUFFIX;
}

View File

@@ -48,6 +48,7 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
SmsOtpAuthnService smsOtpAuthnService;
@Override
public String getProviderName() {
return "mobile" + PROVIDER_SUFFIX;
}

View File

@@ -43,9 +43,9 @@ import org.springframework.security.core.AuthenticationException;
*
*/
public class NormalAuthenticationProvider extends AbstractAuthenticationProvider {
private static final Logger _logger =
LoggerFactory.getLogger(NormalAuthenticationProvider.class);
private static final Logger _logger = LoggerFactory.getLogger(NormalAuthenticationProvider.class);
@Override
public String getProviderName() {
return "normal" + PROVIDER_SUFFIX;
}

View File

@@ -35,9 +35,9 @@ import org.springframework.security.core.Authentication;
*
*/
public class TrustedAuthenticationProvider extends AbstractAuthenticationProvider {
private static final Logger _logger =
LoggerFactory.getLogger(TrustedAuthenticationProvider.class);
private static final Logger _logger = LoggerFactory.getLogger(TrustedAuthenticationProvider.class);
@Override
public String getProviderName() {
return "trusted" + PROVIDER_SUFFIX;
}

View File

@@ -96,6 +96,7 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
/**
* passwordMatches.
*/
@Override
public boolean passwordMatches(UserInfo userInfo, String password) {
boolean passwordMatches = false;
//jdbc password check

View File

@@ -77,6 +77,7 @@ public final class ActiveDirectoryServer implements IAuthenticationServer {
this.filter = filter;
}
@Override
public boolean isMapping() {
return mapping;
}

View File

@@ -97,6 +97,7 @@ public final class StandardLdapServer implements IAuthenticationServer {
this.filterAttribute = filterAttribute;
}
@Override
public boolean isMapping() {
return mapping;
}

View File

@@ -66,23 +66,23 @@ public class HttpCertsEntryPoint implements AsyncHandlerInterceptor {
for (X509Certificate cert : certificates) {
cert.checkValidity();
_logger.debug("cert validated");
_logger.debug("cert infos " + cert.toString());
_logger.debug("Version " + cert.getVersion());
_logger.debug("SerialNumber " + cert.getSerialNumber().toString(16));
_logger.debug("SubjectDN " + cert.getSubjectDN());
_logger.debug("IssuerDN " + cert.getIssuerDN());
_logger.debug("NotBefore " + cert.getNotBefore());
_logger.debug("SigAlgName " + cert.getSigAlgName());
_logger.debug("cert infos {}" , cert.toString());
_logger.debug("Version {}" , cert.getVersion());
_logger.debug("SerialNumber {}" , cert.getSerialNumber().toString(16));
_logger.debug("SubjectDN {}" , cert.getSubjectDN());
_logger.debug("IssuerDN {}" , cert.getIssuerDN());
_logger.debug("NotBefore {}" , cert.getNotBefore());
_logger.debug("SigAlgName {}" , cert.getSigAlgName());
byte[] sign = cert.getSignature();
_logger.debug("Signature ");
for (int j = 0; j < sign.length; j++){
_logger.debug(sign[j] + ",");
_logger.debug("{} , ",sign[j] );
}
java.security.PublicKey pk = cert.getPublicKey();
byte[] pkenc = pk.getEncoded();
_logger.debug("PublicKey ");
for (int j = 0; j < pkenc.length; j++){
_logger.debug(pkenc[j] + ",");
_logger.debug("{} ,",pkenc[j]);
}
}
return true;

View File

@@ -30,6 +30,7 @@ public class RemoteKerberosService implements KerberosService{
private static Logger _logger = LoggerFactory.getLogger(RemoteKerberosService.class);
List<KerberosProxy> kerberosProxys;
@Override
public List<KerberosProxy> getKerberosProxys() {
return kerberosProxys;
}
@@ -38,6 +39,7 @@ public class RemoteKerberosService implements KerberosService{
this.kerberosProxys = kerberosProxys;
}
@Override
public String buildKerberosProxys(){
List<Map<String,String>>userDomainUrlList=new ArrayList<Map<String,String>>();
for (KerberosProxy kerberosProxy :kerberosProxys){

View File

@@ -92,6 +92,7 @@ public class JdbcRemeberMeManager extends AbstractRemeberMeManager {
public RemeberMe read(RemeberMe remeberMe) {
List<RemeberMe> listRemeberMe = jdbcTemplate.query(DEFAULT_DEFAULT_SELECT_STATEMENT,
new RowMapper<RemeberMe>() {
@Override
public RemeberMe mapRow(ResultSet rs, int rowNum) throws SQLException {
RemeberMe remeberMe = new RemeberMe();
remeberMe.setId(rs.getString(1));

View File

@@ -31,6 +31,7 @@ public class WsFederationServiceImpl implements WsFederationService{
this.wsFederationConfiguration = wsFederationConfiguration;
}
@Override
public WsFederationConfiguration getWsFederationConfiguration() {
return wsFederationConfiguration;
}