-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix hugegraph-api code checkstyle #1845
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,35 +43,33 @@ | |
|
||
public interface HugeAuthenticator extends Authenticator { | ||
|
||
public static final String KEY_USERNAME = | ||
CredentialGraphTokens.PROPERTY_USERNAME; | ||
public static final String KEY_PASSWORD = | ||
CredentialGraphTokens.PROPERTY_PASSWORD; | ||
public static final String KEY_TOKEN = "token"; | ||
public static final String KEY_ROLE = "role"; | ||
public static final String KEY_ADDRESS = "address"; | ||
public static final String KEY_PATH = "path"; | ||
String KEY_USERNAME = CredentialGraphTokens.PROPERTY_USERNAME; | ||
String KEY_PASSWORD = CredentialGraphTokens.PROPERTY_PASSWORD; | ||
String KEY_TOKEN = "token"; | ||
String KEY_ROLE = "role"; | ||
String KEY_ADDRESS = "address"; | ||
String KEY_PATH = "path"; | ||
|
||
public static final String USER_SYSTEM = "system"; | ||
public static final String USER_ADMIN = "admin"; | ||
public static final String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME; | ||
String USER_SYSTEM = "system"; | ||
String USER_ADMIN = "admin"; | ||
String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME; | ||
|
||
public static final RolePermission ROLE_NONE = RolePermission.none(); | ||
public static final RolePermission ROLE_ADMIN = RolePermission.admin(); | ||
RolePermission ROLE_NONE = RolePermission.none(); | ||
RolePermission ROLE_ADMIN = RolePermission.admin(); | ||
|
||
public static final String VAR_PREFIX = "$"; | ||
public static final String KEY_OWNER = VAR_PREFIX + "owner"; | ||
public static final String KEY_DYNAMIC = VAR_PREFIX + "dynamic"; | ||
public static final String KEY_ACTION = VAR_PREFIX + "action"; | ||
String VAR_PREFIX = "$"; | ||
String KEY_OWNER = VAR_PREFIX + "owner"; | ||
String KEY_DYNAMIC = VAR_PREFIX + "dynamic"; | ||
String KEY_ACTION = VAR_PREFIX + "action"; | ||
|
||
public void setup(HugeConfig config); | ||
void setup(HugeConfig config); | ||
|
||
public UserWithRole authenticate(String username, String password, | ||
String token); | ||
public AuthManager authManager(); | ||
UserWithRole authenticate(String username, String password, String token); | ||
|
||
AuthManager authManager(); | ||
|
||
@Override | ||
public default void setup(final Map<String, Object> config) { | ||
default void setup(final Map<String, Object> config) { | ||
E.checkState(config != null, | ||
"Must provide a 'config' in the 'authentication'"); | ||
String path = (String) config.get("tokens"); | ||
|
@@ -82,7 +80,7 @@ public default void setup(final Map<String, Object> config) { | |
} | ||
|
||
@Override | ||
public default User authenticate(final Map<String, String> credentials) | ||
default User authenticate(final Map<String, String> credentials) | ||
throws AuthenticationException { | ||
HugeGraphAuthProxy.resetContext(); | ||
|
||
|
@@ -114,21 +112,17 @@ public default User authenticate(final Map<String, String> credentials) | |
} | ||
|
||
@Override | ||
public default boolean requireAuthentication() { | ||
default boolean requireAuthentication() { | ||
return true; | ||
} | ||
|
||
public default boolean verifyRole(RolePermission role) { | ||
if (role == ROLE_NONE || role == null) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
default boolean verifyRole(RolePermission role) { | ||
return role != ROLE_NONE && role != null; | ||
} | ||
|
||
public void initAdminUser(String password) throws Exception; | ||
void initAdminUser(String password) throws Exception; | ||
|
||
public static HugeAuthenticator loadAuthenticator(HugeConfig conf) { | ||
static HugeAuthenticator loadAuthenticator(HugeConfig conf) { | ||
String authClass = conf.get(ServerOptions.AUTHENTICATOR); | ||
if (authClass.isEmpty()) { | ||
return null; | ||
|
@@ -149,7 +143,7 @@ public static HugeAuthenticator loadAuthenticator(HugeConfig conf) { | |
return authenticator; | ||
} | ||
|
||
public static class User extends AuthenticatedUser { | ||
class User extends AuthenticatedUser { | ||
|
||
public static final User ADMIN = new User(USER_ADMIN, ROLE_ADMIN); | ||
public static final User ANONYMOUS = new User(USER_ANONY, ROLE_ADMIN); | ||
|
@@ -254,7 +248,7 @@ public static class UserJson { | |
} | ||
} | ||
|
||
public static class RolePerm { | ||
class RolePerm { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer to keep |
||
|
||
@JsonProperty("roles") // graph -> action -> resource | ||
private Map<String, Map<HugePermission, Object>> roles; | ||
|
@@ -394,7 +388,7 @@ public static boolean match(Object role, RolePermission grant, | |
} | ||
} | ||
|
||
public static class RequiredPerm { | ||
class RequiredPerm { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer to keep |
||
|
||
@JsonProperty("owner") | ||
private String owner; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with RestServer