Skip to content

Commit

Permalink
Some small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Mar 18, 2020
1 parent d9aec47 commit c255ac9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public class AuthSDKConfig {
/**
* The constant HTTP_ACCESS_TOKEN.
*/
public static final String HTTP_ACCESS_TOKEN = "X-Access-Token";
public static final String HTTP_ACCESS_TOKEN = "Dew-Access-Token";
/**
* The constant HTTP_USER_TOKEN.
*/
public static final String HTTP_USER_TOKEN = "X-User-Token";
public static final String HTTP_USER_TOKEN = "Dew-User-Token";
/**
* The constant HTTP_URI.
*/
public static final String HTTP_URI = "X-Uri";
public static final String HTTP_URI = "Dew-Uri";

private String serverUrl = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static DewContext context() {
* @throws ClassNotFoundException the class not found exception
*/
@PostConstruct
private void init() throws IOException, ClassNotFoundException {
private void init() {
logger.info("Load Auto Configuration : {}", this.getClass().getName());

logger.info("Load Dew basic info...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ public static class Security {

private SecurityCORS cors = new SecurityCORS();

private String tokenFlag = "X-Dew-Token";
private String tokenFlag = "Dew-Token";

private String tokenKindFlag = "X-Dew-Token-Kind";
private String tokenKindFlag = "Dew-Token-Kind";

private boolean tokenInHeader = true;

Expand Down Expand Up @@ -873,7 +873,7 @@ public void setTokenKinds(Map<String, TokenKind> tokenKinds) {
public static class SecurityCORS {

private String allowOrigin = "*";
private String allowMethods = "POST,GET,OPTIONS,PUT,DELETE,HEAD";
private String allowMethods = "POST,GET,OPTIONS,PUT,PATCH,DELETE,HEAD";
private String allowHeaders = "x-requested-with,content-type";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,22 @@ public static InetAddress getLocalAddress() {
}
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
if (interfaces != null) {
while (interfaces.hasMoreElements()) {
try {
NetworkInterface network = interfaces.nextElement();
Enumeration<InetAddress> addresses = network.getInetAddresses();
while (addresses.hasMoreElements()) {
try {
InetAddress address = addresses.nextElement();
if (isValidAddress(address)) {
return address;
}
} catch (Exception e) {
logger.warn("Failed to retrieving ip address, " + e.getMessage(), e);
while (interfaces.hasMoreElements()) {
try {
NetworkInterface network = interfaces.nextElement();
Enumeration<InetAddress> addresses = network.getInetAddresses();
while (addresses.hasMoreElements()) {
try {
InetAddress address = addresses.nextElement();
if (isValidAddress(address)) {
return address;
}
} catch (Exception e) {
logger.warn("Failed to retrieving ip address, " + e.getMessage(), e);
}
} catch (Exception e) {
logger.warn("Failed to retrieving ip address, " + e.getMessage(), e);
}
} catch (Exception e) {
logger.warn("Failed to retrieving ip address, " + e.getMessage(), e);
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public class BasicHandlerInterceptor extends HandlerInterceptorAdapter {
/**
* 填充认证信息.
*
* @param blackUris 接口访问黑名单 http method -> uris
* @param roleAuth 接口授权角色 roleName -> http method -> uris
* @param blackUris 接口访问黑名单 http method - uris
* @param roleAuth 接口授权角色 roleName - http method - uris
*/
public static void fillAuthInfo(Map<String, List<String>> blackUris,
Map<String, Map<String, List<String>>> roleAuth) {
Expand Down

0 comments on commit c255ac9

Please sign in to comment.