mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
代码优化
This commit is contained in:
parent
47c725624c
commit
a1213a7539
@ -48,6 +48,7 @@ public class LightNoise extends Configurable implements NoiseProducer
|
|||||||
* @param factorThree
|
* @param factorThree
|
||||||
* @param factorFour
|
* @param factorFour
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void makeNoise(BufferedImage image, float factorOne,
|
public void makeNoise(BufferedImage image, float factorOne,
|
||||||
float factorTwo, float factorThree, float factorFour)
|
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 the maximum 3 point change the stroke and direction
|
||||||
for (i = 0; i < pts.length - 1; i++)
|
for (i = 0; i < pts.length - 1; i++)
|
||||||
{
|
{
|
||||||
if (i < 3)
|
if (i < 3) {
|
||||||
graph.setStroke(new BasicStroke(0.7f * (2 - i)));
|
graph.setStroke(new BasicStroke(0.7f * (2 - i)));
|
||||||
|
}
|
||||||
graph.drawLine((int) pts[i].getX(), (int) pts[i].getY(),
|
graph.drawLine((int) pts[i].getX(), (int) pts[i].getY(),
|
||||||
(int) pts[i + 1].getX(), (int) pts[i + 1].getY());
|
(int) pts[i + 1].getX(), (int) pts[i + 1].getY());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public class Ripple extends Configurable implements GimpyEngine
|
|||||||
* @param baseImage the base image
|
* @param baseImage the base image
|
||||||
* @return the distorted image
|
* @return the distorted image
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public BufferedImage getDistortedImage(BufferedImage baseImage)
|
public BufferedImage getDistortedImage(BufferedImage baseImage)
|
||||||
{
|
{
|
||||||
NoiseProducer noiseProducer = getConfig().getNoiseImpl();
|
NoiseProducer noiseProducer = getConfig().getNoiseImpl();
|
||||||
|
|||||||
@ -49,6 +49,7 @@ public class RandomColorWordRenderer extends Configurable implements WordRendere
|
|||||||
* The height of the image to be created.
|
* The height of the image to be created.
|
||||||
* @return The BufferedImage created from the word.
|
* @return The BufferedImage created from the word.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public BufferedImage renderWord(String word, int width, int height)
|
public BufferedImage renderWord(String word, int width, int height)
|
||||||
{
|
{
|
||||||
int fontSize = getConfig().getTextProducerFontSize();
|
int fontSize = getConfig().getTextProducerFontSize();
|
||||||
|
|||||||
@ -97,6 +97,7 @@ public class InMemorySessionManager implements SessionManager{
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getValiditySeconds() {
|
public int getValiditySeconds() {
|
||||||
return validitySeconds;
|
return validitySeconds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public class RedisSessionManager implements SessionManager {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getValiditySeconds() {
|
public int getValiditySeconds() {
|
||||||
return validitySeconds;
|
return validitySeconds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void create(String sessionId, Session session) {
|
public void create(String sessionId, Session session) {
|
||||||
inMemorySessionManager.create(sessionId, session);
|
inMemorySessionManager.create(sessionId, session);
|
||||||
if(isRedis) {
|
if(isRedis) {
|
||||||
@ -92,6 +93,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Session remove(String sessionId) {
|
public Session remove(String sessionId) {
|
||||||
Session session = inMemorySessionManager.remove(sessionId);
|
Session session = inMemorySessionManager.remove(sessionId);
|
||||||
if(isRedis) {
|
if(isRedis) {
|
||||||
@ -100,6 +102,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Session get(String sessionId) {
|
public Session get(String sessionId) {
|
||||||
Session session = inMemorySessionManager.get(sessionId);
|
Session session = inMemorySessionManager.get(sessionId);
|
||||||
if(session == null && isRedis) {
|
if(session == null && isRedis) {
|
||||||
@ -108,6 +111,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Session refresh(String sessionId, LocalDateTime refreshTime) {
|
public Session refresh(String sessionId, LocalDateTime refreshTime) {
|
||||||
Session session = null;
|
Session session = null;
|
||||||
if(isRedis) {
|
if(isRedis) {
|
||||||
@ -120,6 +124,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Session refresh(String sessionId) {
|
public Session refresh(String sessionId) {
|
||||||
Session session = null;
|
Session session = null;
|
||||||
if(isRedis) {
|
if(isRedis) {
|
||||||
@ -134,6 +139,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<HistoryLogin> querySessions() {
|
public List<HistoryLogin> querySessions() {
|
||||||
//clear session id is null
|
//clear session id is null
|
||||||
jdbcTemplate.execute(NO_SESSION_UPDATE_STATEMENT);
|
jdbcTemplate.execute(NO_SESSION_UPDATE_STATEMENT);
|
||||||
@ -158,6 +164,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
new int[] { Types.VARCHAR, Types.VARCHAR });
|
new int[] { Types.VARCHAR, Types.VARCHAR });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void terminate(String sessionId, String userId, String username) {
|
public void terminate(String sessionId, String userId, String username) {
|
||||||
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
||||||
_logger.trace("{} user {} terminate session {} ." ,lastLogoffTime,username, sessionId);
|
_logger.trace("{} user {} terminate session {} ." ,lastLogoffTime,username, sessionId);
|
||||||
@ -166,6 +173,7 @@ public class SessionManagerFactory implements SessionManager{
|
|||||||
this.remove(sessionId);
|
this.remove(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getValiditySeconds() {
|
public int getValiditySeconds() {
|
||||||
return validitySeconds;
|
return validitySeconds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,15 +27,17 @@ public abstract class AbstractIpLocation implements IpLocation{
|
|||||||
|
|
||||||
int failCount = 0;
|
int failCount = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getFailCount() {
|
public int getFailCount() {
|
||||||
return failCount;
|
return failCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
public int plusFailCount() {
|
public int plusFailCount() {
|
||||||
return failCount++;
|
return failCount++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getLocation(String region) {
|
public String getLocation(String region) {
|
||||||
if(region.endsWith("电信") || region.endsWith("移动") || region.endsWith("联通")) {
|
if(region.endsWith("电信") || region.endsWith("移动") || region.endsWith("联通")) {
|
||||||
region.substring(0, region.length() - 2).trim();
|
region.substring(0, region.length() - 2).trim();
|
||||||
|
|||||||
@ -22,8 +22,7 @@ import org.springframework.security.core.Authentication;
|
|||||||
|
|
||||||
public class AuthenticationProviderFactory extends AbstractAuthenticationProvider {
|
public class AuthenticationProviderFactory extends AbstractAuthenticationProvider {
|
||||||
|
|
||||||
private static ConcurrentHashMap<String,AbstractAuthenticationProvider> providers =
|
private static ConcurrentHashMap<String,AbstractAuthenticationProvider> providers = new ConcurrentHashMap<>();
|
||||||
new ConcurrentHashMap<String,AbstractAuthenticationProvider>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication authenticate(LoginCredential authentication){
|
public Authentication authenticate(LoginCredential authentication){
|
||||||
|
|||||||
@ -42,9 +42,9 @@ import org.springframework.security.core.AuthenticationException;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MfaAuthenticationProvider extends AbstractAuthenticationProvider {
|
public class MfaAuthenticationProvider extends AbstractAuthenticationProvider {
|
||||||
private static final Logger _logger =
|
private static final Logger _logger = LoggerFactory.getLogger(MfaAuthenticationProvider.class);
|
||||||
LoggerFactory.getLogger(MfaAuthenticationProvider.class);
|
|
||||||
|
@Override
|
||||||
public String getProviderName() {
|
public String getProviderName() {
|
||||||
return "mfa" + PROVIDER_SUFFIX;
|
return "mfa" + PROVIDER_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
|
|||||||
|
|
||||||
SmsOtpAuthnService smsOtpAuthnService;
|
SmsOtpAuthnService smsOtpAuthnService;
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getProviderName() {
|
public String getProviderName() {
|
||||||
return "mobile" + PROVIDER_SUFFIX;
|
return "mobile" + PROVIDER_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,9 +43,9 @@ import org.springframework.security.core.AuthenticationException;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NormalAuthenticationProvider extends AbstractAuthenticationProvider {
|
public class NormalAuthenticationProvider extends AbstractAuthenticationProvider {
|
||||||
private static final Logger _logger =
|
private static final Logger _logger = LoggerFactory.getLogger(NormalAuthenticationProvider.class);
|
||||||
LoggerFactory.getLogger(NormalAuthenticationProvider.class);
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getProviderName() {
|
public String getProviderName() {
|
||||||
return "normal" + PROVIDER_SUFFIX;
|
return "normal" + PROVIDER_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,9 +35,9 @@ import org.springframework.security.core.Authentication;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TrustedAuthenticationProvider extends AbstractAuthenticationProvider {
|
public class TrustedAuthenticationProvider extends AbstractAuthenticationProvider {
|
||||||
private static final Logger _logger =
|
private static final Logger _logger = LoggerFactory.getLogger(TrustedAuthenticationProvider.class);
|
||||||
LoggerFactory.getLogger(TrustedAuthenticationProvider.class);
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getProviderName() {
|
public String getProviderName() {
|
||||||
return "trusted" + PROVIDER_SUFFIX;
|
return "trusted" + PROVIDER_SUFFIX;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,6 +96,7 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
|
|||||||
/**
|
/**
|
||||||
* passwordMatches.
|
* passwordMatches.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean passwordMatches(UserInfo userInfo, String password) {
|
public boolean passwordMatches(UserInfo userInfo, String password) {
|
||||||
boolean passwordMatches = false;
|
boolean passwordMatches = false;
|
||||||
//jdbc password check
|
//jdbc password check
|
||||||
|
|||||||
@ -77,6 +77,7 @@ public final class ActiveDirectoryServer implements IAuthenticationServer {
|
|||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isMapping() {
|
public boolean isMapping() {
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,7 @@ public final class StandardLdapServer implements IAuthenticationServer {
|
|||||||
this.filterAttribute = filterAttribute;
|
this.filterAttribute = filterAttribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isMapping() {
|
public boolean isMapping() {
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,23 +66,23 @@ public class HttpCertsEntryPoint implements AsyncHandlerInterceptor {
|
|||||||
for (X509Certificate cert : certificates) {
|
for (X509Certificate cert : certificates) {
|
||||||
cert.checkValidity();
|
cert.checkValidity();
|
||||||
_logger.debug("cert validated");
|
_logger.debug("cert validated");
|
||||||
_logger.debug("cert infos " + cert.toString());
|
_logger.debug("cert infos {}" , cert.toString());
|
||||||
_logger.debug("Version " + cert.getVersion());
|
_logger.debug("Version {}" , cert.getVersion());
|
||||||
_logger.debug("SerialNumber " + cert.getSerialNumber().toString(16));
|
_logger.debug("SerialNumber {}" , cert.getSerialNumber().toString(16));
|
||||||
_logger.debug("SubjectDN " + cert.getSubjectDN());
|
_logger.debug("SubjectDN {}" , cert.getSubjectDN());
|
||||||
_logger.debug("IssuerDN " + cert.getIssuerDN());
|
_logger.debug("IssuerDN {}" , cert.getIssuerDN());
|
||||||
_logger.debug("NotBefore " + cert.getNotBefore());
|
_logger.debug("NotBefore {}" , cert.getNotBefore());
|
||||||
_logger.debug("SigAlgName " + cert.getSigAlgName());
|
_logger.debug("SigAlgName {}" , cert.getSigAlgName());
|
||||||
byte[] sign = cert.getSignature();
|
byte[] sign = cert.getSignature();
|
||||||
_logger.debug("Signature ");
|
_logger.debug("Signature ");
|
||||||
for (int j = 0; j < sign.length; j++){
|
for (int j = 0; j < sign.length; j++){
|
||||||
_logger.debug(sign[j] + ",");
|
_logger.debug("{} , ",sign[j] );
|
||||||
}
|
}
|
||||||
java.security.PublicKey pk = cert.getPublicKey();
|
java.security.PublicKey pk = cert.getPublicKey();
|
||||||
byte[] pkenc = pk.getEncoded();
|
byte[] pkenc = pk.getEncoded();
|
||||||
_logger.debug("PublicKey ");
|
_logger.debug("PublicKey ");
|
||||||
for (int j = 0; j < pkenc.length; j++){
|
for (int j = 0; j < pkenc.length; j++){
|
||||||
_logger.debug(pkenc[j] + ",");
|
_logger.debug("{} ,",pkenc[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public class RemoteKerberosService implements KerberosService{
|
|||||||
private static Logger _logger = LoggerFactory.getLogger(RemoteKerberosService.class);
|
private static Logger _logger = LoggerFactory.getLogger(RemoteKerberosService.class);
|
||||||
List<KerberosProxy> kerberosProxys;
|
List<KerberosProxy> kerberosProxys;
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<KerberosProxy> getKerberosProxys() {
|
public List<KerberosProxy> getKerberosProxys() {
|
||||||
return kerberosProxys;
|
return kerberosProxys;
|
||||||
}
|
}
|
||||||
@ -38,6 +39,7 @@ public class RemoteKerberosService implements KerberosService{
|
|||||||
this.kerberosProxys = kerberosProxys;
|
this.kerberosProxys = kerberosProxys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String buildKerberosProxys(){
|
public String buildKerberosProxys(){
|
||||||
List<Map<String,String>>userDomainUrlList=new ArrayList<Map<String,String>>();
|
List<Map<String,String>>userDomainUrlList=new ArrayList<Map<String,String>>();
|
||||||
for (KerberosProxy kerberosProxy :kerberosProxys){
|
for (KerberosProxy kerberosProxy :kerberosProxys){
|
||||||
|
|||||||
@ -92,6 +92,7 @@ public class JdbcRemeberMeManager extends AbstractRemeberMeManager {
|
|||||||
public RemeberMe read(RemeberMe remeberMe) {
|
public RemeberMe read(RemeberMe remeberMe) {
|
||||||
List<RemeberMe> listRemeberMe = jdbcTemplate.query(DEFAULT_DEFAULT_SELECT_STATEMENT,
|
List<RemeberMe> listRemeberMe = jdbcTemplate.query(DEFAULT_DEFAULT_SELECT_STATEMENT,
|
||||||
new RowMapper<RemeberMe>() {
|
new RowMapper<RemeberMe>() {
|
||||||
|
@Override
|
||||||
public RemeberMe mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public RemeberMe mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
RemeberMe remeberMe = new RemeberMe();
|
RemeberMe remeberMe = new RemeberMe();
|
||||||
remeberMe.setId(rs.getString(1));
|
remeberMe.setId(rs.getString(1));
|
||||||
|
|||||||
@ -31,6 +31,7 @@ public class WsFederationServiceImpl implements WsFederationService{
|
|||||||
this.wsFederationConfiguration = wsFederationConfiguration;
|
this.wsFederationConfiguration = wsFederationConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public WsFederationConfiguration getWsFederationConfiguration() {
|
public WsFederationConfiguration getWsFederationConfiguration() {
|
||||||
return wsFederationConfiguration;
|
return wsFederationConfiguration;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,8 +67,9 @@ public final class HexUtils {
|
|||||||
int high = Character.digit(hex[i * 2], 16);
|
int high = Character.digit(hex[i * 2], 16);
|
||||||
int low = Character.digit(hex[i * 2 + 1], 16);
|
int low = Character.digit(hex[i * 2 + 1], 16);
|
||||||
int value = (high << 4) | low;
|
int value = (high << 4) | low;
|
||||||
if (value > 127)
|
if (value > 127) {
|
||||||
value -= 256;
|
value -= 256;
|
||||||
|
}
|
||||||
raw[i] = (byte) value;
|
raw[i] = (byte) value;
|
||||||
}
|
}
|
||||||
return raw;
|
return raw;
|
||||||
|
|||||||
@ -170,14 +170,12 @@ public final class ReciprocalUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String decoderHex(String ciphers, String secretKey, String algorithm) {
|
public static String decoderHex(String ciphers, String secretKey, String algorithm) {
|
||||||
if(StringUtils.isBlank(ciphers))return "";
|
if(StringUtils.isNotBlank(ciphers) && keyLengthCheck(secretKey, algorithm)) {
|
||||||
|
|
||||||
if (keyLengthCheck(secretKey, algorithm)) {
|
|
||||||
byte[] byteSimple = HexUtils.hex2Bytes(ciphers);
|
byte[] byteSimple = HexUtils.hex2Bytes(ciphers);
|
||||||
|
|
||||||
return decoder(byteSimple, secretKey, algorithm);
|
return decoder(byteSimple, secretKey, algorithm);
|
||||||
}
|
}
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String encode2Hex(String simple, String secretKey) {
|
public static String encode2Hex(String simple, String secretKey) {
|
||||||
|
|||||||
@ -69,7 +69,9 @@ public final class X509V3CertGen {
|
|||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if(publicKeyInputStream !=null)publicKeyInputStream.close();
|
if(publicKeyInputStream !=null) {
|
||||||
|
publicKeyInputStream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,9 @@ public class DesedeEncoder implements PasswordEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String decoder(CharSequence encodedPassword) {
|
public String decoder(CharSequence encodedPassword) {
|
||||||
if(encodedPassword == null) return null;
|
if(encodedPassword == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String encodedPasswordString = encodedPassword.toString();
|
String encodedPasswordString = encodedPassword.toString();
|
||||||
if(encodedPasswordString.startsWith(CRYPT)) {
|
if(encodedPasswordString.startsWith(CRYPT)) {
|
||||||
return ReciprocalUtils.decoderHex(encodedPasswordString.substring(PREFFIX_LENGTH), DEFAULT_SALT);
|
return ReciprocalUtils.decoderHex(encodedPasswordString.substring(PREFFIX_LENGTH), DEFAULT_SALT);
|
||||||
@ -64,6 +66,7 @@ public class DesedeEncoder implements PasswordEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
if(encodedPassword.startsWith(PLAIN)) {
|
if(encodedPassword.startsWith(PLAIN)) {
|
||||||
encodedPassword = encode(encodedPassword.substring(PREFFIX_LENGTH));
|
encodedPassword = encode(encodedPassword.substring(PREFFIX_LENGTH));
|
||||||
@ -78,7 +81,9 @@ public class DesedeEncoder implements PasswordEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String encode(CharSequence plain,boolean isEncode) {
|
public String encode(CharSequence plain,boolean isEncode) {
|
||||||
if(plain == null) return null;
|
if(plain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if(isEncode) {
|
if(isEncode) {
|
||||||
return CRYPT + ReciprocalUtils.encode2Hex(plain + "", DEFAULT_SALT);
|
return CRYPT + ReciprocalUtils.encode2Hex(plain + "", DEFAULT_SALT);
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@ -117,6 +117,7 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
|||||||
* @return the encoded password in the specified format
|
* @return the encoded password in the specified format
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String encode(CharSequence rawPass) {
|
public String encode(CharSequence rawPass) {
|
||||||
byte[] salt = this.saltGenerator.generateKey();
|
byte[] salt = this.saltGenerator.generateKey();
|
||||||
return encode(rawPass, salt);
|
return encode(rawPass, salt);
|
||||||
@ -172,6 +173,7 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
|||||||
*
|
*
|
||||||
* @return true if they match (independent of the case of the prefix).
|
* @return true if they match (independent of the case of the prefix).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
return matches(rawPassword == null ? null : rawPassword.toString(), encodedPassword);
|
return matches(rawPassword == null ? null : rawPassword.toString(), encodedPassword);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,6 +114,7 @@ public class Md4PasswordEncoder implements PasswordEncoder {
|
|||||||
* @return Hex string of password digest (or base64 encoded string if
|
* @return Hex string of password digest (or base64 encoded string if
|
||||||
* encodeHashAsBase64 is enabled.
|
* encodeHashAsBase64 is enabled.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String encode(CharSequence rawPassword) {
|
public String encode(CharSequence rawPassword) {
|
||||||
String salt = PREFIX + this.saltGenerator.generateKey() + SUFFIX;
|
String salt = PREFIX + this.saltGenerator.generateKey() + SUFFIX;
|
||||||
return digest(salt, rawPassword);
|
return digest(salt, rawPassword);
|
||||||
@ -151,6 +152,7 @@ public class Md4PasswordEncoder implements PasswordEncoder {
|
|||||||
* @param encodedPassword previously encoded password
|
* @param encodedPassword previously encoded password
|
||||||
* @return true or false
|
* @return true or false
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
String salt = extractSalt(encodedPassword);
|
String salt = extractSalt(encodedPassword);
|
||||||
String rawPasswordEncoded = digest(salt, rawPassword);
|
String rawPasswordEncoded = digest(salt, rawPassword);
|
||||||
|
|||||||
@ -130,6 +130,7 @@ public class MessageDigestPasswordEncoder implements PasswordEncoder {
|
|||||||
* @return Hex string of password digest (or base64 encoded string if
|
* @return Hex string of password digest (or base64 encoded string if
|
||||||
* encodeHashAsBase64 is enabled.
|
* encodeHashAsBase64 is enabled.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String encode(CharSequence rawPassword) {
|
public String encode(CharSequence rawPassword) {
|
||||||
String salt = PREFIX + this.saltGenerator.generateKey() + SUFFIX;
|
String salt = PREFIX + this.saltGenerator.generateKey() + SUFFIX;
|
||||||
return digest(salt, rawPassword);
|
return digest(salt, rawPassword);
|
||||||
@ -160,6 +161,7 @@ public class MessageDigestPasswordEncoder implements PasswordEncoder {
|
|||||||
* @param encodedPassword previously encoded password
|
* @param encodedPassword previously encoded password
|
||||||
* @return true or false
|
* @return true or false
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
String salt = extractSalt(encodedPassword);
|
String salt = extractSalt(encodedPassword);
|
||||||
String rawPasswordEncoded = digest(salt, rawPassword);
|
String rawPasswordEncoded = digest(salt, rawPassword);
|
||||||
|
|||||||
@ -52,10 +52,12 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
|
|
||||||
public final class NoOpPasswordEncoder implements PasswordEncoder {
|
public final class NoOpPasswordEncoder implements PasswordEncoder {
|
||||||
|
|
||||||
|
@Override
|
||||||
public String encode(CharSequence rawPassword) {
|
public String encode(CharSequence rawPassword) {
|
||||||
return rawPassword.toString();
|
return rawPassword.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
return rawPassword.toString().equals(encodedPassword);
|
return rawPassword.toString().equals(encodedPassword);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public class PasswordReciprocal implements PasswordEncoder {
|
|||||||
return plain.substring(salt.substring(PREFFIX_LENGTH).length());
|
return plain.substring(salt.substring(PREFFIX_LENGTH).length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
String salt = encodedPassword.subSequence(0, 29).toString();
|
String salt = encodedPassword.subSequence(0, 29).toString();
|
||||||
String finalPassword = encode(rawPassword,salt);
|
String finalPassword = encode(rawPassword,salt);
|
||||||
|
|||||||
@ -53,10 +53,12 @@ public final class StandardPasswordEncoder implements PasswordEncoder {
|
|||||||
this("SHA-256", secret);
|
this("SHA-256", secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String encode(CharSequence rawPassword) {
|
public String encode(CharSequence rawPassword) {
|
||||||
return encode(rawPassword, saltGenerator.generateKey());
|
return encode(rawPassword, saltGenerator.generateKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
byte[] digested = decode(encodedPassword);
|
byte[] digested = decode(encodedPassword);
|
||||||
byte[] salt = subArray(digested, 0, saltGenerator.getKeyLength());
|
byte[] salt = subArray(digested, 0, saltGenerator.getKeyLength());
|
||||||
|
|||||||
@ -47,6 +47,7 @@ public final class DsaSigner implements ISigner {
|
|||||||
* */
|
* */
|
||||||
public static final String SIGNATURE_ALGORITHM = "SHA1withDSA";
|
public static final String SIGNATURE_ALGORITHM = "SHA1withDSA";
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] sign(byte[] dataBytes, byte[] privateKeyByte) throws Exception {
|
public byte[] sign(byte[] dataBytes, byte[] privateKeyByte) throws Exception {
|
||||||
// ȡ<EFBFBD><EFBFBD>˽Կ
|
// ȡ<EFBFBD><EFBFBD>˽Կ
|
||||||
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(privateKeyByte);
|
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(privateKeyByte);
|
||||||
@ -63,7 +64,7 @@ public final class DsaSigner implements ISigner {
|
|||||||
return signature.sign();
|
return signature.sign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String signB64(String data, String privateKey) throws Exception {
|
public String signB64(String data, String privateKey) throws Exception {
|
||||||
|
|
||||||
byte[] privateKeyByte = Base64Utils.decoder(privateKey);
|
byte[] privateKeyByte = Base64Utils.decoder(privateKey);
|
||||||
@ -74,6 +75,7 @@ public final class DsaSigner implements ISigner {
|
|||||||
return Base64Utils.encoder(signatureBytes);
|
return Base64Utils.encoder(signatureBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean verify(byte[] dataBytes, byte[] publicKeyBytes, byte[] signBytes)throws Exception {
|
public boolean verify(byte[] dataBytes, byte[] publicKeyBytes, byte[] signBytes)throws Exception {
|
||||||
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM.name());
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM.name());
|
||||||
@ -92,6 +94,7 @@ public final class DsaSigner implements ISigner {
|
|||||||
return signature.verify(signBytes);
|
return signature.verify(signBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean verifyB64(String data, String publicKey, String sign)throws Exception {
|
public boolean verifyB64(String data, String publicKey, String sign)throws Exception {
|
||||||
|
|
||||||
byte[] privateKeyByte = Base64Utils.decoder(publicKey);
|
byte[] privateKeyByte = Base64Utils.decoder(publicKey);
|
||||||
|
|||||||
@ -65,6 +65,7 @@ public final class RsaSigner implements ISigner {
|
|||||||
return signature.sign();
|
return signature.sign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] sign(byte[] dataBytes, byte[] privateKeyBytes) throws Exception {
|
public byte[] sign(byte[] dataBytes, byte[] privateKeyBytes) throws Exception {
|
||||||
return sign(dataBytes,privateKeyBytes,SIGNATURE_ALGORITHM);
|
return sign(dataBytes,privateKeyBytes,SIGNATURE_ALGORITHM);
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ public final class RsaSigner implements ISigner {
|
|||||||
/**
|
/**
|
||||||
* sign with BASE64 privateKey use SHA1withRSA Algorithm
|
* sign with BASE64 privateKey use SHA1withRSA Algorithm
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String signB64(String data, String privateKey) throws Exception {
|
public String signB64(String data, String privateKey) throws Exception {
|
||||||
byte[] keyBytes = Base64Utils.decoder(privateKey);
|
byte[] keyBytes = Base64Utils.decoder(privateKey);
|
||||||
byte[] dataBytes = data.getBytes();
|
byte[] dataBytes = data.getBytes();
|
||||||
@ -104,6 +106,7 @@ public final class RsaSigner implements ISigner {
|
|||||||
* @see com.connsec.crypto.signature.Signer#verify(java.lang.String,
|
* @see com.connsec.crypto.signature.Signer#verify(java.lang.String,
|
||||||
* java.lang.String, java.lang.String)
|
* java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean verify(byte[] dataBytes, byte[] publicKeyBytes , byte[] signBytes)throws Exception {
|
public boolean verify(byte[] dataBytes, byte[] publicKeyBytes , byte[] signBytes)throws Exception {
|
||||||
// verify
|
// verify
|
||||||
return verify(dataBytes,publicKeyBytes,signBytes,SIGNATURE_ALGORITHM);
|
return verify(dataBytes,publicKeyBytes,signBytes,SIGNATURE_ALGORITHM);
|
||||||
@ -115,6 +118,7 @@ public final class RsaSigner implements ISigner {
|
|||||||
* @see com.connsec.crypto.signature.Signer#verify(java.lang.String,
|
* @see com.connsec.crypto.signature.Signer#verify(java.lang.String,
|
||||||
* java.lang.String, java.lang.String)
|
* java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean verifyB64(String data, String publicKey, String sign)throws Exception {
|
public boolean verifyB64(String data, String publicKey, String sign)throws Exception {
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>Կ
|
// <EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>Կ
|
||||||
byte[] keyBytes = Base64Utils.decoder(publicKey);
|
byte[] keyBytes = Base64Utils.decoder(publicKey);
|
||||||
|
|||||||
@ -113,6 +113,7 @@ public class JsonPretty implements Pretty{
|
|||||||
* @param JSON String
|
* @param JSON String
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String format(String jsonString){
|
public String format(String jsonString){
|
||||||
return format(JsonParser.parseString(jsonString));
|
return format(JsonParser.parseString(jsonString));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -193,10 +193,12 @@ public class XMLHelper {
|
|||||||
|
|
||||||
serializer.setFilter(new LSSerializerFilter() {
|
serializer.setFilter(new LSSerializerFilter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public short acceptNode(Node arg0) {
|
public short acceptNode(Node arg0) {
|
||||||
return FILTER_ACCEPT;
|
return FILTER_ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getWhatToShow() {
|
public int getWhatToShow() {
|
||||||
return SHOW_ALL;
|
return SHOW_ALL;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,9 @@ public class BeanConvert {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(beanFiledMap==null)return bean;
|
if(beanFiledMap==null) {
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
Iterator<?> fieldit = beanFiledMap.entrySet().iterator();
|
Iterator<?> fieldit = beanFiledMap.entrySet().iterator();
|
||||||
LogFactory.getLog(BeanConvert.class).debug("map2Bean() *******************************************");
|
LogFactory.getLog(BeanConvert.class).debug("map2Bean() *******************************************");
|
||||||
LogFactory.getLog(BeanConvert.class).debug("map2Bean() "+bean.getClass().getName());
|
LogFactory.getLog(BeanConvert.class).debug("map2Bean() "+bean.getClass().getName());
|
||||||
@ -78,7 +80,9 @@ public class BeanConvert {
|
|||||||
String fieldName = entry.getKey().toString();
|
String fieldName = entry.getKey().toString();
|
||||||
Object value = null;
|
Object value = null;
|
||||||
String fieldType=(String)beanFiledMap.get(fieldName);
|
String fieldType=(String)beanFiledMap.get(fieldName);
|
||||||
if(valueMap.get(fieldName)==null)continue;
|
if(valueMap.get(fieldName)==null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String fillValue=valueMap.get(fieldName).toString();
|
String fillValue=valueMap.get(fieldName).toString();
|
||||||
LogFactory.getLog(BeanConvert.class).debug("map2Bean() field "+(i++)+" : "+fieldName+" = "+fillValue+" type : "+fieldType);
|
LogFactory.getLog(BeanConvert.class).debug("map2Bean() field "+(i++)+" : "+fieldName+" = "+fillValue+" type : "+fieldType);
|
||||||
if(fieldType.equals("java.lang.String")){
|
if(fieldType.equals("java.lang.String")){
|
||||||
|
|||||||
@ -30,7 +30,9 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
public class BeanUtil {
|
public class BeanUtil {
|
||||||
|
|
||||||
public static void copyBean(Object origin,Object target) {
|
public static void copyBean(Object origin,Object target) {
|
||||||
if( origin == null || target == null) return;
|
if( origin == null || target == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
BeanUtils.copyProperties( origin, target);
|
BeanUtils.copyProperties( origin, target);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -40,7 +42,9 @@ public class BeanUtil {
|
|||||||
|
|
||||||
public static Object cloneSupper(Object origin) {
|
public static Object cloneSupper(Object origin) {
|
||||||
Object target = null;
|
Object target = null;
|
||||||
if(origin == null) return target;
|
if(origin == null) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
target = origin.getClass().getSuperclass().newInstance();
|
target = origin.getClass().getSuperclass().newInstance();
|
||||||
BeanUtils.copyProperties(target,origin);
|
BeanUtils.copyProperties(target,origin);
|
||||||
@ -51,7 +55,9 @@ public class BeanUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getValue(Object bean,String field ) {
|
public static String getValue(Object bean,String field ) {
|
||||||
if(bean == null) return null;
|
if(bean == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String retVal = "";
|
String retVal = "";
|
||||||
try {
|
try {
|
||||||
retVal = BeanUtils.getProperty(bean, field);
|
retVal = BeanUtils.getProperty(bean, field);
|
||||||
@ -216,8 +222,9 @@ public class BeanUtil {
|
|||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
for (int i = 0; i < flds.length; i++) {
|
for (int i = 0; i < flds.length; i++) {
|
||||||
String fieldName = flds[i].getName();
|
String fieldName = flds[i].getName();
|
||||||
if (isPublicProperty(cls, fieldName))
|
if (isPublicProperty(cls, fieldName)) {
|
||||||
map.put(flds[i].getName(), flds[i].getType().getName());
|
map.put(flds[i].getName(), flds[i].getType().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -245,39 +252,61 @@ public class BeanUtil {
|
|||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
if(fieldType.equals("java.lang.String")){
|
if(fieldType.equals("java.lang.String")){
|
||||||
if(String.valueOf(fillValue)==null)isFieldNotEmpty= false;
|
if(String.valueOf(fillValue)==null) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("int")){
|
}else if(fieldType.equals("int")){
|
||||||
if(Integer.parseInt(fillValue)==0)isFieldNotEmpty= false;
|
if(Integer.parseInt(fillValue)==0) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("long")){
|
}else if(fieldType.equals("long")){
|
||||||
if(Long.parseLong(fillValue)==0)isFieldNotEmpty= false;
|
if(Long.parseLong(fillValue)==0) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("java.lang.Long")){
|
}else if(fieldType.equals("java.lang.Long")){
|
||||||
if(Long.parseLong(fillValue)==0)isFieldNotEmpty= false;
|
if(Long.parseLong(fillValue)==0) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("double")){
|
}else if(fieldType.equals("double")){
|
||||||
if(Double.valueOf(fillValue)==0.0d)isFieldNotEmpty= false;
|
if(Double.valueOf(fillValue)==0.0d) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("float")){
|
}else if(fieldType.equals("float")){
|
||||||
if(Float.parseFloat(fillValue)==0.0f)isFieldNotEmpty= false;
|
if(Float.parseFloat(fillValue)==0.0f) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("java.util.Date")){
|
}else if(fieldType.equals("java.util.Date")){
|
||||||
try {
|
try {
|
||||||
value=BeanUtil.get(entity, field.getName());
|
value=BeanUtil.get(entity, field.getName());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(value==null)isFieldNotEmpty= false;
|
if(value==null) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("java.lang.Object")){
|
}else if(fieldType.equals("java.lang.Object")){
|
||||||
try {
|
try {
|
||||||
value=BeanUtil.get(entity, field.getName());
|
value=BeanUtil.get(entity, field.getName());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(value==null)isFieldNotEmpty= false;
|
if(value==null) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("char")){
|
}else if(fieldType.equals("char")){
|
||||||
if(Character.valueOf(fillValue.charAt(0))=='\u0000')isFieldNotEmpty= false;
|
if(Character.valueOf(fillValue.charAt(0))=='\u0000') {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("boolean")){
|
}else if(fieldType.equals("boolean")){
|
||||||
value=Boolean.parseBoolean(fillValue);
|
value=Boolean.parseBoolean(fillValue);
|
||||||
}else if(fieldType.equals("short")){
|
}else if(fieldType.equals("short")){
|
||||||
if(Short.parseShort(fillValue)==0)isFieldNotEmpty= false;
|
if(Short.parseShort(fillValue)==0) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}else if(fieldType.equals("byte")){
|
}else if(fieldType.equals("byte")){
|
||||||
if(Byte.parseByte(fillValue)==0)isFieldNotEmpty= false;
|
if(Byte.parseByte(fillValue)==0) {
|
||||||
|
isFieldNotEmpty= false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFactory.getLog(BeanUtil.class).debug("isFieldNotEmpty() fieldName : "+field.getName()+", fieldType : "+fieldType+", Value : "+fillValue+", isFieldNotEmpty : "+isFieldNotEmpty);
|
LogFactory.getLog(BeanUtil.class).debug("isFieldNotEmpty() fieldName : "+field.getName()+", fieldType : "+fieldType+", Value : "+fillValue+", isFieldNotEmpty : "+isFieldNotEmpty);
|
||||||
|
|||||||
@ -77,13 +77,13 @@ public class DateUtils {
|
|||||||
public final static int compareDate(String stringValue1, String stringValue2)
|
public final static int compareDate(String stringValue1, String stringValue2)
|
||||||
throws ParseException {
|
throws ParseException {
|
||||||
Date date1 = tryParse(stringValue1);
|
Date date1 = tryParse(stringValue1);
|
||||||
if (date1 == null)
|
if (date1 == null) {
|
||||||
throw new ParseException("Can not parse " + stringValue1
|
throw new ParseException("Can not parse " + stringValue1+ " to Date.", 0);
|
||||||
+ " to Date.", 0);
|
}
|
||||||
Date date2 = tryParse(stringValue2);
|
Date date2 = tryParse(stringValue2);
|
||||||
if (date2 == null)
|
if (date2 == null) {
|
||||||
throw new ParseException("Can not parse " + stringValue1
|
throw new ParseException("Can not parse " + stringValue1+ " to Date.", 0);
|
||||||
+ " to Date.", 0);
|
}
|
||||||
return date1.compareTo(date2);
|
return date1.compareTo(date2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,10 +343,12 @@ public class DateUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static int getDayOfWeek(int SUN_FST_DAY_OF_WEEK) {
|
public static int getDayOfWeek(int SUN_FST_DAY_OF_WEEK) {
|
||||||
if (SUN_FST_DAY_OF_WEEK > 7 || SUN_FST_DAY_OF_WEEK < 1)
|
if (SUN_FST_DAY_OF_WEEK > 7 || SUN_FST_DAY_OF_WEEK < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
if (SUN_FST_DAY_OF_WEEK == 1)
|
}
|
||||||
|
if (SUN_FST_DAY_OF_WEEK == 1) {
|
||||||
return 7;
|
return 7;
|
||||||
|
}
|
||||||
return SUN_FST_DAY_OF_WEEK - 1;
|
return SUN_FST_DAY_OF_WEEK - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -177,6 +177,7 @@ public class EthernetAddress
|
|||||||
/**
|
/**
|
||||||
* Default cloning behaviour (bitwise copy) is just fine...
|
* Default cloning behaviour (bitwise copy) is just fine...
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object clone()
|
public Object clone()
|
||||||
{
|
{
|
||||||
return new EthernetAddress(_address);
|
return new EthernetAddress(_address);
|
||||||
@ -418,9 +419,15 @@ public class EthernetAddress
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
if (o == this) return true;
|
if (o == this) {
|
||||||
if (o == null) return false;
|
return true;
|
||||||
if (o.getClass() != getClass()) return false;
|
}
|
||||||
|
if (o == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (o.getClass() != getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return ((EthernetAddress) o)._address == _address;
|
return ((EthernetAddress) o)._address == _address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,10 +440,13 @@ public class EthernetAddress
|
|||||||
* parameter address if they are equal, os positive non-zero number if this address
|
* parameter address if they are equal, os positive non-zero number if this address
|
||||||
* should be sorted after parameter
|
* should be sorted after parameter
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int compareTo(EthernetAddress other)
|
public int compareTo(EthernetAddress other)
|
||||||
{
|
{
|
||||||
long l = _address - other._address;
|
long l = _address - other._address;
|
||||||
if (l < 0L) return -1;
|
if (l < 0L) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return (l == 0L) ? 0 : 1;
|
return (l == 0L) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ public class HttpsTrusts {
|
|||||||
try {
|
try {
|
||||||
trustAllHttpsCertificates();
|
trustAllHttpsCertificates();
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
|
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
|
||||||
|
@Override
|
||||||
public boolean verify(String urlHostName, SSLSession session) {
|
public boolean verify(String urlHostName, SSLSession session) {
|
||||||
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
|
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
|
||||||
return true;
|
return true;
|
||||||
@ -50,6 +51,7 @@ public class HttpsTrusts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class HttpsTrustsTM implements javax.net.ssl.TrustManager,javax.net.ssl.X509TrustManager {
|
static class HttpsTrustsTM implements javax.net.ssl.TrustManager,javax.net.ssl.X509TrustManager {
|
||||||
|
@Override
|
||||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -62,11 +64,13 @@ public class HttpsTrusts {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
throws java.security.cert.CertificateException {
|
throws java.security.cert.CertificateException {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||||
throws java.security.cert.CertificateException {
|
throws java.security.cert.CertificateException {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -56,20 +56,22 @@ public class JdbcUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void release(Connection conn, Statement stmt, ResultSet rs) {
|
public static void release(Connection conn, Statement stmt, ResultSet rs) {
|
||||||
if (rs != null)
|
if (rs != null) {
|
||||||
try {
|
try {
|
||||||
rs.close();
|
rs.close();
|
||||||
rs = null;
|
rs = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("SQLException");
|
System.out.println("SQLException");
|
||||||
}
|
}
|
||||||
if (stmt != null)
|
}
|
||||||
|
if (stmt != null) {
|
||||||
try {
|
try {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = null;
|
stmt = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("SQLException");
|
System.out.println("SQLException");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
conn.close();
|
conn.close();
|
||||||
@ -81,27 +83,30 @@ public class JdbcUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void release(Connection conn, Statement stmt, PreparedStatement pstmt, ResultSet rs) {
|
public static void release(Connection conn, Statement stmt, PreparedStatement pstmt, ResultSet rs) {
|
||||||
if (rs != null)
|
if (rs != null) {
|
||||||
try {
|
try {
|
||||||
rs.close();
|
rs.close();
|
||||||
rs = null;
|
rs = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("ResultSet Close Exception");
|
System.out.println("ResultSet Close Exception");
|
||||||
}
|
}
|
||||||
if (stmt != null)
|
}
|
||||||
|
if (stmt != null) {
|
||||||
try {
|
try {
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = null;
|
stmt = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("Statement Close Exception");
|
System.out.println("Statement Close Exception");
|
||||||
}
|
}
|
||||||
if (pstmt != null)
|
}
|
||||||
|
if (pstmt != null) {
|
||||||
try {
|
try {
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.out.println("PreparedStatement Close Exception");
|
System.out.println("PreparedStatement Close Exception");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|||||||
@ -45,9 +45,9 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] utf8_bytes = strValue.getBytes("UTF-8");
|
byte[] utf8_bytes = strValue.getBytes("UTF-8");
|
||||||
if (utf8_bytes.length <= bytelen)
|
if (utf8_bytes.length <= bytelen) {
|
||||||
return strValue;
|
return strValue;
|
||||||
|
}
|
||||||
byte[] cutoff_bytes = new byte[real_bytelen];
|
byte[] cutoff_bytes = new byte[real_bytelen];
|
||||||
System.arraycopy(utf8_bytes, 0, cutoff_bytes, 0, real_bytelen);
|
System.arraycopy(utf8_bytes, 0, cutoff_bytes, 0, real_bytelen);
|
||||||
|
|
||||||
@ -56,8 +56,9 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return strResult;
|
return strResult;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (strValue.length() < strlen)
|
if (strValue.length() < strlen) {
|
||||||
return strValue;
|
return strValue;
|
||||||
|
}
|
||||||
return strValue.substring(0, strlen);
|
return strValue.substring(0, strlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +250,9 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
|
|
||||||
public static String list2String(List<String> list, String split) {
|
public static String list2String(List<String> list, String split) {
|
||||||
String string = "";
|
String string = "";
|
||||||
if (list == null)
|
if (list == null) {
|
||||||
return string;
|
return string;
|
||||||
|
}
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (list.get(i) != null && !list.get(i).equals("")) {
|
if (list.get(i) != null && !list.get(i).equals("")) {
|
||||||
string += list.get(i) + split;
|
string += list.get(i) + split;
|
||||||
|
|||||||
@ -100,18 +100,18 @@ public final class UUIDGenerator {
|
|||||||
* @param bytes UUID content
|
* @param bytes UUID content
|
||||||
*/
|
*/
|
||||||
public UUIDGenerator(byte[] bytes) {
|
public UUIDGenerator(byte[] bytes) {
|
||||||
if (bytes.length != 16)
|
if (bytes.length != 16) {
|
||||||
throw new RuntimeException("Attempted to parse malformed UUID: " + Arrays.toString(bytes));
|
throw new RuntimeException("Attempted to parse malformed UUID: " + Arrays.toString(bytes));
|
||||||
|
}
|
||||||
content = Arrays.copyOf(bytes, 16);
|
content = Arrays.copyOf(bytes, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUIDGenerator(String id) {
|
public UUIDGenerator(String id) {
|
||||||
id = id.trim();
|
id = id.trim();
|
||||||
|
|
||||||
if (id.length() != 36)
|
if (id.length() != 36) {
|
||||||
throw new RuntimeException("Attempted to parse malformed UUID: " + id);
|
throw new RuntimeException("Attempted to parse malformed UUID: " + id);
|
||||||
|
}
|
||||||
content = new byte[16];
|
content = new byte[16];
|
||||||
char[] chars = id.toCharArray();
|
char[] chars = id.toCharArray();
|
||||||
|
|
||||||
@ -180,12 +180,15 @@ public final class UUIDGenerator {
|
|||||||
* @return four bit number representing offset from '0'
|
* @return four bit number representing offset from '0'
|
||||||
*/
|
*/
|
||||||
private static int intValue(char x) {
|
private static int intValue(char x) {
|
||||||
if (x >= '0' && x <= '9')
|
if (x >= '0' && x <= '9') {
|
||||||
return x - '0';
|
return x - '0';
|
||||||
if (x >= 'a' && x <= 'f')
|
}
|
||||||
|
if (x >= 'a' && x <= 'f') {
|
||||||
return x - 'a' + 10;
|
return x - 'a' + 10;
|
||||||
if (x >= 'A' && x <= 'F')
|
}
|
||||||
|
if (x >= 'A' && x <= 'F') {
|
||||||
return x - 'A' + 10;
|
return x - 'A' + 10;
|
||||||
|
}
|
||||||
throw new RuntimeException("Error parsing UUID at character: " + x);
|
throw new RuntimeException("Error parsing UUID at character: " + x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,9 +270,9 @@ public final class UUIDGenerator {
|
|||||||
* @return id of process that generated the UUID, or -1 for unrecognized format
|
* @return id of process that generated the UUID, or -1 for unrecognized format
|
||||||
*/
|
*/
|
||||||
public int getProcessId() {
|
public int getProcessId() {
|
||||||
if (getVersion() != VERSION)
|
if (getVersion() != VERSION) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return ((content[4] & 0xFF) << 8) | (content[5] & 0xFF);
|
return ((content[4] & 0xFF) << 8) | (content[5] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,9 +281,9 @@ public final class UUIDGenerator {
|
|||||||
* @return millisecond UTC timestamp from generation of the UUID, or null for unrecognized format
|
* @return millisecond UTC timestamp from generation of the UUID, or null for unrecognized format
|
||||||
*/
|
*/
|
||||||
public Date getTimestamp() {
|
public Date getTimestamp() {
|
||||||
if (getVersion() != VERSION)
|
if (getVersion() != VERSION) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
long time;
|
long time;
|
||||||
time = ((long)content[10] & 0xFF) << 40;
|
time = ((long)content[10] & 0xFF) << 40;
|
||||||
time |= ((long)content[11] & 0xFF) << 32;
|
time |= ((long)content[11] & 0xFF) << 32;
|
||||||
@ -298,9 +301,9 @@ public final class UUIDGenerator {
|
|||||||
* @return byte array of UUID fragment, or null for unrecognized format
|
* @return byte array of UUID fragment, or null for unrecognized format
|
||||||
*/
|
*/
|
||||||
public byte[] getMacFragment() {
|
public byte[] getMacFragment() {
|
||||||
if (getVersion() != 'b')
|
if (getVersion() != 'b') {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
byte[] x = new byte[6];
|
byte[] x = new byte[6];
|
||||||
|
|
||||||
x[0] = 0;
|
x[0] = 0;
|
||||||
@ -315,18 +318,24 @@ public final class UUIDGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
UUIDGenerator that = (UUIDGenerator) o;
|
UUIDGenerator that = (UUIDGenerator) o;
|
||||||
|
|
||||||
if (this.content.length != that.content.length)
|
if (this.content.length != that.content.length) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < this.content.length; i++)
|
for (int i = 0; i < this.content.length; i++) {
|
||||||
if (this.content[i] != that.content[i])
|
if (this.content[i] != that.content[i]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,9 +350,9 @@ public final class UUIDGenerator {
|
|||||||
//byte[] mac = NetworkInterface.getNetworkInterfaces().nextElement().getHardwareAddress();
|
//byte[] mac = NetworkInterface.getNetworkInterfaces().nextElement().getHardwareAddress();
|
||||||
byte[] mac = EthernetAddress.fromInterface().toByteArray();
|
byte[] mac = EthernetAddress.fromInterface().toByteArray();
|
||||||
// if the machine is not connected to a network it has no active MAC address
|
// if the machine is not connected to a network it has no active MAC address
|
||||||
if (mac == null)
|
if (mac == null) {
|
||||||
mac = new byte[] {0, 0, 0, 0, 0, 0};
|
mac = new byte[] {0, 0, 0, 0, 0, 0};
|
||||||
|
}
|
||||||
return mac;
|
return mac;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Could not get MAC address");
|
throw new RuntimeException("Could not get MAC address");
|
||||||
@ -357,9 +366,9 @@ public final class UUIDGenerator {
|
|||||||
final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
|
final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
|
||||||
final int index = jvmName.indexOf('@');
|
final int index = jvmName.indexOf('@');
|
||||||
|
|
||||||
if (index < 1)
|
if (index < 1) {
|
||||||
throw new RuntimeException("Could not get PID");
|
throw new RuntimeException("Could not get PID");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(jvmName.substring(0, index)) % MAX_PID;
|
return Integer.parseInt(jvmName.substring(0, index)) % MAX_PID;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|||||||
@ -62,6 +62,7 @@ public class TimestampUUIDGenerator
|
|||||||
*
|
*
|
||||||
* @throws IllegalStateException if adjustmentOverflow() throws it
|
* @throws IllegalStateException if adjustmentOverflow() throws it
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public UUID nextUUID()
|
public UUID nextUUID()
|
||||||
{
|
{
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
|||||||
@ -111,8 +111,12 @@ public final class UUID implements Serializable
|
|||||||
byte[] node)
|
byte[] node)
|
||||||
throws NullPointerException, IllegalArgumentException
|
throws NullPointerException, IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(node == null) throw new NullPointerException();
|
if(node == null) {
|
||||||
if(node.length != 6) throw new IllegalArgumentException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
if(node.length != 6) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
this.time_low = time_low;
|
this.time_low = time_low;
|
||||||
this.time_mid = time_mid;
|
this.time_mid = time_mid;
|
||||||
@ -135,20 +139,33 @@ public final class UUID implements Serializable
|
|||||||
IllegalArgumentException,
|
IllegalArgumentException,
|
||||||
NumberFormatException
|
NumberFormatException
|
||||||
{
|
{
|
||||||
if(s == null) throw new NullPointerException();
|
if(s == null) {
|
||||||
if(s.length() != 36) throw new IllegalArgumentException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
if(s.length() != 36) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
time_low = parseHex(s.substring(0, 8));
|
time_low = parseHex(s.substring(0, 8));
|
||||||
if(s.charAt(8) != '-') throw new IllegalArgumentException();
|
if(s.charAt(8) != '-') {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
time_mid = (short) parseHex(s.substring(9, 13));
|
time_mid = (short) parseHex(s.substring(9, 13));
|
||||||
if(s.charAt(13) != '-') throw new IllegalArgumentException();
|
if(s.charAt(13) != '-') {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
time_hi_and_version = (short) parseHex(s.substring(14, 18));
|
time_hi_and_version = (short) parseHex(s.substring(14, 18));
|
||||||
if(s.charAt(18) != '-') throw new IllegalArgumentException();
|
if(s.charAt(18) != '-') {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
clock_seq_hi_and_reserved = (byte) parseHex(s.substring(19, 21));
|
clock_seq_hi_and_reserved = (byte) parseHex(s.substring(19, 21));
|
||||||
clock_seq_low = (byte) parseHex(s.substring(21, 23));
|
clock_seq_low = (byte) parseHex(s.substring(21, 23));
|
||||||
if(s.charAt(23) != '-') throw new IllegalArgumentException();
|
if(s.charAt(23) != '-') {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
node = new byte[6];
|
node = new byte[6];
|
||||||
for(int i = 0; i < 6; i++)
|
for(int i = 0; i < 6; i++) {
|
||||||
node[i] = (byte) parseHex(s.substring(2 * i + 24, 2 * i + 26));
|
node[i] = (byte) parseHex(s.substring(2 * i + 24, 2 * i + 26));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,7 +177,9 @@ public final class UUID implements Serializable
|
|||||||
*/
|
*/
|
||||||
public UUID(DataInput in) throws IOException
|
public UUID(DataInput in) throws IOException
|
||||||
{
|
{
|
||||||
if(in == null) throw new NullPointerException();
|
if(in == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
readData(in);
|
readData(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +191,12 @@ public final class UUID implements Serializable
|
|||||||
*/
|
*/
|
||||||
public UUID(byte[] data)
|
public UUID(byte[] data)
|
||||||
{
|
{
|
||||||
if(data == null) throw new NullPointerException();
|
if(data == null) {
|
||||||
if(data.length != 16) throw new IllegalArgumentException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
if(data.length != 16) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
readData(new DataInputStream(new ByteArrayInputStream(data)));
|
readData(new DataInputStream(new ByteArrayInputStream(data)));
|
||||||
} catch(IOException ex) {
|
} catch(IOException ex) {
|
||||||
@ -221,19 +244,22 @@ public final class UUID implements Serializable
|
|||||||
/*
|
/*
|
||||||
* Returns true if two UUIDs are equal by value.
|
* Returns true if two UUIDs are equal by value.
|
||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
@Override
|
||||||
{
|
public boolean equals(Object obj){
|
||||||
if(obj == null || !(obj instanceof UUID))
|
if(obj == null || !(obj instanceof UUID)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
UUID other = (UUID) obj;
|
UUID other = (UUID) obj;
|
||||||
|
|
||||||
if(this == other) return true;
|
if(this == other) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(hash_code != 0 &&
|
if(hash_code != 0 &&
|
||||||
other.hash_code != 0 &&
|
other.hash_code != 0 &&
|
||||||
hash_code != other.hash_code)
|
hash_code != other.hash_code) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
time_low == other.time_low &&
|
time_low == other.time_low &&
|
||||||
@ -247,14 +273,16 @@ public final class UUID implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Returns a hash code for this UUID.
|
* Returns a hash code for this UUID.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
if(hash_code == 0) {
|
if(hash_code == 0) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if(hash_code == 0) {
|
if(hash_code == 0) {
|
||||||
hash_code = toString().hashCode();
|
hash_code = toString().hashCode();
|
||||||
if(hash_code == 0)
|
if(hash_code == 0) {
|
||||||
hash_code = -1;
|
hash_code = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,9 +294,9 @@ public final class UUID implements Serializable
|
|||||||
*/
|
*/
|
||||||
private static void appendHex(StringBuffer sb, long num, int digits)
|
private static void appendHex(StringBuffer sb, long num, int digits)
|
||||||
{
|
{
|
||||||
if(digits > 0 && digits < 16)
|
if(digits > 0 && digits < 16) {
|
||||||
num = num & ((1L << (digits * 4)) - 1);
|
num = num & ((1L << (digits * 4)) - 1);
|
||||||
|
}
|
||||||
String str = Long.toHexString(num);
|
String str = Long.toHexString(num);
|
||||||
int len = str.length();
|
int len = str.length();
|
||||||
while(len < digits) {
|
while(len < digits) {
|
||||||
@ -283,15 +311,16 @@ public final class UUID implements Serializable
|
|||||||
*/
|
*/
|
||||||
private static int parseHex(String s) throws NumberFormatException
|
private static int parseHex(String s) throws NumberFormatException
|
||||||
{
|
{
|
||||||
if(s.charAt(0) == '-')
|
if(s.charAt(0) == '-') {
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
|
}
|
||||||
return Integer.parseInt(s, 16);
|
return Integer.parseInt(s, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string representation of this UUID.
|
* Returns the string representation of this UUID.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if(string_rep == null) {
|
if(string_rep == null) {
|
||||||
@ -307,8 +336,9 @@ public final class UUID implements Serializable
|
|||||||
appendHex(sb, clock_seq_hi_and_reserved, 2);
|
appendHex(sb, clock_seq_hi_and_reserved, 2);
|
||||||
appendHex(sb, clock_seq_low, 2);
|
appendHex(sb, clock_seq_low, 2);
|
||||||
sb.append('-');
|
sb.append('-');
|
||||||
for(int i = 0; i < 6; i++)
|
for(int i = 0; i < 6; i++) {
|
||||||
appendHex(sb, node[i], 2);
|
appendHex(sb, node[i], 2);
|
||||||
|
}
|
||||||
string_rep = sb.toString();
|
string_rep = sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,9 +373,9 @@ public final class UUID implements Serializable
|
|||||||
*/
|
*/
|
||||||
public static UUID generate()
|
public static UUID generate()
|
||||||
{
|
{
|
||||||
if(default_generator == null)
|
if(default_generator == null) {
|
||||||
default_generator = new TimestampUUIDGenerator(UUIDRandomness.randomClockSequence(), NodeIDGetter.getNodeID());
|
default_generator = new TimestampUUIDGenerator(UUIDRandomness.randomClockSequence(), NodeIDGetter.getNodeID());
|
||||||
|
}
|
||||||
return default_generator.nextUUID();
|
return default_generator.nextUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,9 @@ public final class UUIDRandomness
|
|||||||
synchronized(random) {
|
synchronized(random) {
|
||||||
next = random.nextInt(16383);
|
next = random.nextInt(16383);
|
||||||
}
|
}
|
||||||
if(next >= prev) next++;
|
if(next >= prev) {
|
||||||
|
next++;
|
||||||
|
}
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,13 +69,15 @@ public class UnsynchronizedTimestampUUIDGenerator implements UUIDGenerator
|
|||||||
public UnsynchronizedTimestampUUIDGenerator(int clock_sequence,
|
public UnsynchronizedTimestampUUIDGenerator(int clock_sequence,
|
||||||
byte[] node)
|
byte[] node)
|
||||||
{
|
{
|
||||||
if(clock_sequence < 0 || clock_sequence >= 16384)
|
if(clock_sequence < 0 || clock_sequence >= 16384) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
if(node == null)
|
}
|
||||||
|
if(node == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
if(node.length != 6)
|
}
|
||||||
|
if(node.length != 6) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
this.clock_sequence = clock_sequence;
|
this.clock_sequence = clock_sequence;
|
||||||
this.node = (byte[]) node.clone();
|
this.node = (byte[]) node.clone();
|
||||||
checkSystemTime();
|
checkSystemTime();
|
||||||
@ -89,8 +91,9 @@ public class UnsynchronizedTimestampUUIDGenerator implements UUIDGenerator
|
|||||||
long sys_time = System.currentTimeMillis();
|
long sys_time = System.currentTimeMillis();
|
||||||
|
|
||||||
/* If monotonicity is lost, bump clock_sequence. */
|
/* If monotonicity is lost, bump clock_sequence. */
|
||||||
if(sys_time < last_time)
|
if(sys_time < last_time) {
|
||||||
clock_sequence = UUIDRandomness.nextRandomClockSequence(clock_sequence);
|
clock_sequence = UUIDRandomness.nextRandomClockSequence(clock_sequence);
|
||||||
|
}
|
||||||
|
|
||||||
/* If the clock ticked, clear the adjustment. */
|
/* If the clock ticked, clear the adjustment. */
|
||||||
if(sys_time != last_time) {
|
if(sys_time != last_time) {
|
||||||
@ -106,8 +109,9 @@ public class UnsynchronizedTimestampUUIDGenerator implements UUIDGenerator
|
|||||||
protected void adjustmentOverflow() throws IllegalStateException
|
protected void adjustmentOverflow() throws IllegalStateException
|
||||||
{
|
{
|
||||||
checkSystemTime();
|
checkSystemTime();
|
||||||
if(clock_adj >= CLOCK_RES)
|
if(clock_adj >= CLOCK_RES) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,10 +119,13 @@ public class UnsynchronizedTimestampUUIDGenerator implements UUIDGenerator
|
|||||||
*
|
*
|
||||||
* @throws IllegalStateException if adjustmentOverflow() throws it
|
* @throws IllegalStateException if adjustmentOverflow() throws it
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public UUID nextUUID()
|
public UUID nextUUID()
|
||||||
{
|
{
|
||||||
long unique_time = (last_time + EPOCH_OFFSET) * CLOCK_RES + clock_adj;
|
long unique_time = (last_time + EPOCH_OFFSET) * CLOCK_RES + clock_adj;
|
||||||
if(++clock_adj > CLOCK_RES) adjustmentOverflow();
|
if(++clock_adj > CLOCK_RES) {
|
||||||
|
adjustmentOverflow();
|
||||||
|
}
|
||||||
|
|
||||||
return new UUID((int) (unique_time & 0xFFFFFFFF),
|
return new UUID((int) (unique_time & 0xFFFFFFFF),
|
||||||
(short) ((unique_time >> 32) & 0xFFFF),
|
(short) ((unique_time >> 32) & 0xFFFF),
|
||||||
|
|||||||
@ -137,8 +137,9 @@ public class OIDCProviderMetadataDetails implements OIDCProviderMetadata {
|
|||||||
builder.append("[");
|
builder.append("[");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
|
for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
|
||||||
if (i > 0)
|
if (i > 0) {
|
||||||
builder.append(", ");
|
builder.append(", ");
|
||||||
|
}
|
||||||
builder.append(iterator.next());
|
builder.append(iterator.next());
|
||||||
}
|
}
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class AccountsService extends JpaService<Accounts>{
|
|||||||
return (AccountsMapper)super.getMapper();
|
return (AccountsMapper)super.getMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean insert(Accounts account) {
|
public boolean insert(Accounts account) {
|
||||||
if (super.insert(account)) {
|
if (super.insert(account)) {
|
||||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||||
@ -89,7 +89,8 @@ public class AccountsService extends JpaService<Accounts>{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(Accounts account) {
|
@Override
|
||||||
|
public boolean update(Accounts account) {
|
||||||
if (super.update(account)) {
|
if (super.update(account)) {
|
||||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||||
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
|
||||||
@ -112,6 +113,8 @@ public class AccountsService extends JpaService<Accounts>{
|
|||||||
public boolean updateStatus(Accounts accounts) {
|
public boolean updateStatus(Accounts accounts) {
|
||||||
return this.getMapper().updateStatus(accounts) > 0;
|
return this.getMapper().updateStatus(accounts) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean remove(String id) {
|
public boolean remove(String id) {
|
||||||
Accounts account = this.get(id);
|
Accounts account = this.get(id);
|
||||||
if (super.remove(id)) {
|
if (super.remove(id)) {
|
||||||
@ -196,7 +199,9 @@ public class AccountsService extends JpaService<Accounts>{
|
|||||||
for(int i =1 ;i < 100 ;i++) {
|
for(int i =1 ;i < 100 ;i++) {
|
||||||
accountResult = account + i;
|
accountResult = account + i;
|
||||||
AccountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
|
AccountsList =getMapper().queryByAppIdAndAccount(accountsStrategy.getAppId(),accountResult + accountsStrategy.getSuffixes());
|
||||||
if(AccountsList.isEmpty())break;
|
if(AccountsList.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,8 +161,9 @@ public class OrganizationsService extends JpaService<Organizations>{
|
|||||||
rootOrg.setReorgNamePath(true);
|
rootOrg.setReorgNamePath(true);
|
||||||
|
|
||||||
for (Organizations org : orgList) {
|
for (Organizations org : orgList) {
|
||||||
if (org.isReorgNamePath())
|
if (org.isReorgNamePath()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
|
if (org.getParentId().equalsIgnoreCase(rootOrg.getId())) {
|
||||||
reorg(orgMap, orgList, org);
|
reorg(orgMap, orgList, org);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
|||||||
return (UserInfoMapper)super.getMapper();
|
return (UserInfoMapper)super.getMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean insert(UserInfo userInfo) {
|
public boolean insert(UserInfo userInfo) {
|
||||||
this.passwordEncoder(userInfo);
|
this.passwordEncoder(userInfo);
|
||||||
if (super.insert(userInfo)) {
|
if (super.insert(userInfo)) {
|
||||||
@ -108,6 +109,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean update(UserInfo userInfo) {
|
public boolean update(UserInfo userInfo) {
|
||||||
ChangePassword changePassword = this.passwordEncoder(userInfo);
|
ChangePassword changePassword = this.passwordEncoder(userInfo);
|
||||||
if (super.update(userInfo)) {
|
if (super.update(userInfo)) {
|
||||||
@ -127,6 +129,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean delete(UserInfo userInfo) {
|
public boolean delete(UserInfo userInfo) {
|
||||||
UserInfo loadUserInfo = null;
|
UserInfo loadUserInfo = null;
|
||||||
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
if(provisionService.getApplicationConfig().isProvisionSupport()) {
|
||||||
|
|||||||
@ -71,7 +71,9 @@ public class AccountsServiceTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initSpringContext(){
|
public void initSpringContext(){
|
||||||
if(context!=null) return;
|
if(context!=null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_logger.info("init Spring Context...");
|
_logger.info("init Spring Context...");
|
||||||
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String startTime=sdf_ymdhms.format(new Date());
|
String startTime=sdf_ymdhms.format(new Date());
|
||||||
|
|||||||
@ -59,7 +59,9 @@ public class AppsServiceTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initSpringContext(){
|
public void initSpringContext(){
|
||||||
if(context!=null) return;
|
if(context!=null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_logger.info("init Spring Context...");
|
_logger.info("init Spring Context...");
|
||||||
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String startTime=sdf_ymdhms.format(new Date());
|
String startTime=sdf_ymdhms.format(new Date());
|
||||||
|
|||||||
@ -120,7 +120,9 @@ public class FormBasedDetailsServiceTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initSpringContext(){
|
public void initSpringContext(){
|
||||||
if(context!=null) return;
|
if(context!=null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_logger.info("init Spring Context...");
|
_logger.info("init Spring Context...");
|
||||||
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf_ymdhms =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String startTime=sdf_ymdhms.format(new Date());
|
String startTime=sdf_ymdhms.format(new Date());
|
||||||
|
|||||||
@ -55,6 +55,7 @@ public abstract class AbstractWebApplicationService {
|
|||||||
this.artifactId = artifactId;
|
this.artifactId = artifactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
@ -102,6 +103,7 @@ public abstract class AbstractWebApplicationService {
|
|||||||
return this.originalUrl;
|
return this.originalUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(final Object object) {
|
public boolean equals(final Object object) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -116,6 +118,7 @@ public abstract class AbstractWebApplicationService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 41;
|
final int prime = 41;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ public abstract class RandomServiceTicketServices implements TicketServices {
|
|||||||
|
|
||||||
private DefaultUniqueTicketIdGenerator generator=new DefaultUniqueTicketIdGenerator();
|
private DefaultUniqueTicketIdGenerator generator=new DefaultUniqueTicketIdGenerator();
|
||||||
|
|
||||||
|
@Override
|
||||||
public String createTicket(Ticket ticket) {
|
public String createTicket(Ticket ticket) {
|
||||||
//String code = generator.generate();
|
//String code = generator.generate();
|
||||||
/*
|
/*
|
||||||
@ -83,6 +84,7 @@ public abstract class RandomServiceTicketServices implements TicketServices {
|
|||||||
return ticketId;
|
return ticketId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Ticket consumeTicket(String ticketId) throws Exception{
|
public Ticket consumeTicket(String ticketId) throws Exception{
|
||||||
Ticket ticket = this.remove(ticketId);
|
Ticket ticket = this.remove(ticketId);
|
||||||
if (ticket == null) {
|
if (ticket == null) {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class ServiceTicketImpl extends AbstractTicket implements ServiceTicket{
|
|||||||
* policy in that, depending on the policy configuration, the ticket
|
* policy in that, depending on the policy configuration, the ticket
|
||||||
* may be considered expired.
|
* may be considered expired.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isValidFor(final Service serviceToValidate) {
|
public boolean isValidFor(final Service serviceToValidate) {
|
||||||
update();
|
update();
|
||||||
return serviceToValidate.matches(this.service);
|
return serviceToValidate.matches(this.service);
|
||||||
|
|||||||
@ -41,6 +41,7 @@ public class DefaultExpiringOAuth2RefreshToken extends DefaultOAuth2RefreshToken
|
|||||||
*
|
*
|
||||||
* @return The instant the token expires.
|
* @return The instant the token expires.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Date getExpiration() {
|
public Date getExpiration() {
|
||||||
return expiration;
|
return expiration;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,10 +95,12 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return The token value.
|
* @return The token value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getExpiresIn() {
|
public int getExpiresIn() {
|
||||||
return expiration != null ? Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue()
|
return expiration != null ? Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue()
|
||||||
: 0;
|
: 0;
|
||||||
@ -113,6 +115,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return The instant the token expires.
|
* @return The instant the token expires.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Date getExpiration() {
|
public Date getExpiration() {
|
||||||
return expiration;
|
return expiration;
|
||||||
}
|
}
|
||||||
@ -131,6 +134,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return true if the expiration is befor ethe current time
|
* @return true if the expiration is befor ethe current time
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isExpired() {
|
public boolean isExpired() {
|
||||||
return expiration != null && expiration.before(new Date());
|
return expiration != null && expiration.before(new Date());
|
||||||
}
|
}
|
||||||
@ -142,6 +146,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return The token type, as introduced in draft 11 of the OAuth 2 spec.
|
* @return The token type, as introduced in draft 11 of the OAuth 2 spec.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getTokenType() {
|
public String getTokenType() {
|
||||||
return tokenType;
|
return tokenType;
|
||||||
}
|
}
|
||||||
@ -161,6 +166,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return The refresh token associated with the access token, if any.
|
* @return The refresh token associated with the access token, if any.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public OAuth2RefreshToken getRefreshToken() {
|
public OAuth2RefreshToken getRefreshToken() {
|
||||||
return refreshToken;
|
return refreshToken;
|
||||||
}
|
}
|
||||||
@ -180,6 +186,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return The scope of the token.
|
* @return The scope of the token.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Set<String> getScope() {
|
public Set<String> getScope() {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
@ -249,6 +256,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
|||||||
*
|
*
|
||||||
* @return the additional information (default empty)
|
* @return the additional information (default empty)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Map<String, Object> getAdditionalInformation() {
|
public Map<String, Object> getAdditionalInformation() {
|
||||||
return additionalInformation;
|
return additionalInformation;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,14 +108,15 @@ public class ExtractPostBindingAdapter implements ExtractBindingAdapter, Initial
|
|||||||
@Override
|
@Override
|
||||||
public String extractSAMLMessage(HttpServletRequest request) {
|
public String extractSAMLMessage(HttpServletRequest request) {
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(request.getParameter(SAML_REQUEST_POST_PARAM_NAME)))
|
if(StringUtils.isNotBlank(request.getParameter(SAML_REQUEST_POST_PARAM_NAME))) {
|
||||||
return request.getParameter(SAML_REQUEST_POST_PARAM_NAME);
|
return request.getParameter(SAML_REQUEST_POST_PARAM_NAME);
|
||||||
else
|
}else {
|
||||||
return request.getParameter(SAML_RESPONSE_POST_PARAM_NAME);
|
return request.getParameter(SAML_RESPONSE_POST_PARAM_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void buildSecurityPolicyResolver(KeyStore trustKeyStore) {
|
public void buildSecurityPolicyResolver(KeyStore trustKeyStore) {
|
||||||
_logger.debug("EntityName {}, KeystorePassword {}",
|
_logger.debug("EntityName {}, KeystorePassword {}",
|
||||||
keyStoreLoader.getEntityName(),keyStoreLoader.getKeystorePassword());
|
keyStoreLoader.getEntityName(),keyStoreLoader.getKeystorePassword());
|
||||||
@ -133,6 +134,7 @@ public class ExtractPostBindingAdapter implements ExtractBindingAdapter, Initial
|
|||||||
/**
|
/**
|
||||||
* @param securityPolicyResolver the securityPolicyResolver to set
|
* @param securityPolicyResolver the securityPolicyResolver to set
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSecurityPolicyResolver(
|
public void setSecurityPolicyResolver(
|
||||||
SecurityPolicyResolver securityPolicyResolver) {
|
SecurityPolicyResolver securityPolicyResolver) {
|
||||||
this.securityPolicyResolver = securityPolicyResolver;
|
this.securityPolicyResolver = securityPolicyResolver;
|
||||||
@ -148,10 +150,12 @@ public class ExtractPostBindingAdapter implements ExtractBindingAdapter, Initial
|
|||||||
this.saml20Detail=saml20Detail;
|
this.saml20Detail=saml20Detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AppsSAML20Details getSaml20Detail() {
|
public AppsSAML20Details getSaml20Detail() {
|
||||||
return saml20Detail;
|
return saml20Detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public KeyStoreLoader getKeyStoreLoader() {
|
public KeyStoreLoader getKeyStoreLoader() {
|
||||||
return keyStoreLoader;
|
return keyStoreLoader;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public class ExtractRedirectBindingAdapter extends ExtractPostBindingAdapter{
|
|||||||
this.securityPolicyResolver = securityPolicyResolver;
|
this.securityPolicyResolver = securityPolicyResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void buildSecurityPolicyResolver(KeyStore trustKeyStore) {
|
public void buildSecurityPolicyResolver(KeyStore trustKeyStore) {
|
||||||
|
|
||||||
TrustResolver trustResolver = new TrustResolver(trustKeyStore,
|
TrustResolver trustResolver = new TrustResolver(trustKeyStore,
|
||||||
|
|||||||
@ -171,6 +171,7 @@ public class PostBindingAdapter implements BindingAdapter, InitializingBean{
|
|||||||
/**
|
/**
|
||||||
* @param securityPolicyResolver the securityPolicyResolver to set
|
* @param securityPolicyResolver the securityPolicyResolver to set
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSecurityPolicyResolver(
|
public void setSecurityPolicyResolver(
|
||||||
SecurityPolicyResolver securityPolicyResolver) {
|
SecurityPolicyResolver securityPolicyResolver) {
|
||||||
this.securityPolicyResolver = securityPolicyResolver;
|
this.securityPolicyResolver = securityPolicyResolver;
|
||||||
@ -186,6 +187,7 @@ public class PostBindingAdapter implements BindingAdapter, InitializingBean{
|
|||||||
return extractBindingAdapter.getKeyStoreLoader();
|
return extractBindingAdapter.getKeyStoreLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Credential getSigningCredential() {
|
public Credential getSigningCredential() {
|
||||||
return signingCredential;
|
return signingCredential;
|
||||||
}
|
}
|
||||||
@ -194,6 +196,7 @@ public class PostBindingAdapter implements BindingAdapter, InitializingBean{
|
|||||||
this.signingCredential = signingCredential;
|
this.signingCredential = signingCredential;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Credential getSpSigningCredential() {
|
public Credential getSpSigningCredential() {
|
||||||
return spSigningCredential;
|
return spSigningCredential;
|
||||||
}
|
}
|
||||||
@ -202,14 +205,17 @@ public class PostBindingAdapter implements BindingAdapter, InitializingBean{
|
|||||||
this.spSigningCredential = spSigningCredential;
|
this.spSigningCredential = spSigningCredential;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AuthnRequestInfo getAuthnRequestInfo() {
|
public AuthnRequestInfo getAuthnRequestInfo() {
|
||||||
return authnRequestInfo;
|
return authnRequestInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setAuthnRequestInfo(AuthnRequestInfo authnRequestInfo) {
|
public void setAuthnRequestInfo(AuthnRequestInfo authnRequestInfo) {
|
||||||
this.authnRequestInfo = authnRequestInfo;
|
this.authnRequestInfo = authnRequestInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setRelayState(String relayState) {
|
public void setRelayState(String relayState) {
|
||||||
this.relayState = relayState;
|
this.relayState = relayState;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,8 @@ public class SynchronizerAutoConfiguration implements InitializingBean {
|
|||||||
|
|
||||||
public List<Synchronizers> querySynchronizers(JdbcTemplate jdbcTemplate) {
|
public List<Synchronizers> querySynchronizers(JdbcTemplate jdbcTemplate) {
|
||||||
return jdbcTemplate.query(SYNCHRONIZERS_SELECT_STATEMENT, new RowMapper<Synchronizers>() {
|
return jdbcTemplate.query(SYNCHRONIZERS_SELECT_STATEMENT, new RowMapper<Synchronizers>() {
|
||||||
public Synchronizers mapRow(ResultSet rs, int rowNum) throws SQLException {
|
@Override
|
||||||
|
public Synchronizers mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
Synchronizers synchronizer = new Synchronizers();
|
Synchronizers synchronizer = new Synchronizers();
|
||||||
synchronizer.setId( rs.getString("id"));
|
synchronizer.setId( rs.getString("id"));
|
||||||
synchronizer.setName( rs.getString("name"));
|
synchronizer.setName( rs.getString("name"));
|
||||||
|
|||||||
@ -2,10 +2,8 @@
|
|||||||
"typescript.tsdk": "./node_modules/typescript/lib",
|
"typescript.tsdk": "./node_modules/typescript/lib",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
// For ESLint
|
"source.fixAll.eslint": "explicit",
|
||||||
"source.fixAll.eslint": true,
|
"source.fixAll.stylelint": "explicit"
|
||||||
// For Stylelint
|
|
||||||
"source.fixAll.stylelint": true
|
|
||||||
},
|
},
|
||||||
"[markdown]": {
|
"[markdown]": {
|
||||||
"editor.formatOnSave": false
|
"editor.formatOnSave": false
|
||||||
|
|||||||
@ -229,9 +229,10 @@ public class LoginEntryPoint {
|
|||||||
String remeberMe = remeberMeManager.createRemeberMe(authentication, request, response);
|
String remeberMe = remeberMeManager.createRemeberMe(authentication, request, response);
|
||||||
authJwt.setRemeberMe(remeberMe);
|
authJwt.setRemeberMe(remeberMe);
|
||||||
}
|
}
|
||||||
if(WebContext.getAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE)!=null)
|
if(WebContext.getAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE)!=null) {
|
||||||
authJwt.setPasswordSetType(
|
authJwt.setPasswordSetType(
|
||||||
(Integer)WebContext.getAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE));
|
(Integer)WebContext.getAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE));
|
||||||
|
}
|
||||||
authJwtMessage = new Message<AuthJwt>(authJwt);
|
authJwtMessage = new Message<AuthJwt>(authJwt);
|
||||||
|
|
||||||
}else {//fail
|
}else {//fail
|
||||||
|
|||||||
@ -53,7 +53,9 @@ public class LocalizationController {
|
|||||||
@RequestMapping(value={"/forward/{property}"})
|
@RequestMapping(value={"/forward/{property}"})
|
||||||
public ModelAndView forward(@PathVariable("property") String property,@CurrentUser UserInfo currentUser){
|
public ModelAndView forward(@PathVariable("property") String property,@CurrentUser UserInfo currentUser){
|
||||||
Localization localization = localizationRepository.get(property,currentUser.getInstId());
|
Localization localization = localizationRepository.get(property,currentUser.getInstId());
|
||||||
if(localization == null )localization = new Localization();
|
if(localization == null ) {
|
||||||
|
localization = new Localization();
|
||||||
|
}
|
||||||
localization.setProperty(property);
|
localization.setProperty(property);
|
||||||
localization.setInstId(currentUser.getInstId());
|
localization.setInstId(currentUser.getInstId());
|
||||||
return new ModelAndView("localization/updateLocalization","model",localization);
|
return new ModelAndView("localization/updateLocalization","model",localization);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user