Skip to content

Commit ac4a622

Browse files
committed
Rename verification methods to use 'verifySecretCodeAndFetchEmail' for consistency
1 parent 3b3288c commit ac4a622

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

api/src/main/java/org/apache/cloudstack/auth/UserOAuth2Authenticator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public interface UserOAuth2Authenticator extends Adapter {
4242
* Verifies the code provided by provider and fetches email
4343
* @return returns email
4444
*/
45-
String verifyCodeAndFetchEmail(String secretCode);
45+
String verifySecretCodeAndFetchEmail(String secretCode);
4646

4747
/**
4848
* Verifies if the logged in user is valid for a specific domain
@@ -54,7 +54,7 @@ public interface UserOAuth2Authenticator extends Adapter {
5454
* Verifies the secret code provided by provider and fetches email for a specific domain
5555
* @return email for the specified domain
5656
*/
57-
String verifyCodeAndFetchEmail(String secretCode, Long domainId);
57+
String verifySecretCodeAndFetchEmail(String secretCode, Long domainId);
5858

5959
/**
6060
* Fetches email using the accessToken

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface OAuth2AuthManager extends PluggableAPIAuthenticator, PluggableS
5353
*/
5454
UserOAuth2Authenticator getUserOAuth2AuthenticationProvider(final String providerName);
5555

56-
String verifyCodeAndFetchEmail(String code, String provider, Long domainId);
56+
String verifySecretCodeAndFetchEmail(String code, String provider, Long domainId);
5757

5858
OauthProviderVO registerOauthProvider(RegisterOAuthProviderCmd cmd);
5959

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ protected void initializeUserOAuth2AuthenticationProvidersMap() {
133133
}
134134

135135
@Override
136-
public String verifyCodeAndFetchEmail(String code, String provider, Long domainId) {
136+
public String verifySecretCodeAndFetchEmail(String code, String provider, Long domainId) {
137137
UserOAuth2Authenticator authenticator = getUserOAuth2AuthenticationProvider(provider);
138-
String email = authenticator.verifyCodeAndFetchEmail(code, domainId);
138+
String email = authenticator.verifySecretCodeAndFetchEmail(code, domainId);
139139

140140
return email;
141141
}

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/VerifyOAuthCodeAndGetUserCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public String authenticate(String command, Map<String, Object[]> params, HttpSes
112112
}
113113
domainId = _oauth2mgr.resolveDomainId(params);
114114

115-
String email = _oauth2mgr.verifyCodeAndFetchEmail(secretCode, provider, domainId);
115+
String email = _oauth2mgr.verifySecretCodeAndFetchEmail(secretCode, provider, domainId);
116116
if (email != null) {
117117
UserResponse response = new UserResponse();
118118
response.setEmail(email);

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/github/GithubOAuth2Provider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public boolean verifyUser(String email, String secretCode) {
5959
}
6060

6161
@Override
62-
public String verifyCodeAndFetchEmail(String secretCode) {
63-
return verifyCodeAndFetchEmail(secretCode, null);
62+
public String verifySecretCodeAndFetchEmail(String secretCode) {
63+
return verifySecretCodeAndFetchEmail(secretCode, null);
6464
}
6565

6666
@Override
@@ -74,7 +74,7 @@ public boolean verifyUser(String email, String secretCode, Long domainId) {
7474
throw new CloudRuntimeException("Github provider is not registered, so user cannot be verified");
7575
}
7676

77-
String verifiedEmail = verifyCodeAndFetchEmail(secretCode, domainId);
77+
String verifiedEmail = verifySecretCodeAndFetchEmail(secretCode, domainId);
7878
if (StringUtils.isEmpty(verifiedEmail) || !email.equals(verifiedEmail)) {
7979
throw new CloudRuntimeException("Unable to verify the email address with the provided secret");
8080
}
@@ -85,7 +85,7 @@ public boolean verifyUser(String email, String secretCode, Long domainId) {
8585
}
8686

8787
@Override
88-
public String verifyCodeAndFetchEmail(String secretCode, Long domainId) {
88+
public String verifySecretCodeAndFetchEmail(String secretCode, Long domainId) {
8989
String accessToken = getAccessToken(secretCode, domainId);
9090
if (StringUtils.isEmpty(accessToken)) {
9191
return null;

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/google/GoogleOAuth2Provider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public boolean verifyUser(String email, String secretCode) {
6262
}
6363

6464
@Override
65-
public String verifyCodeAndFetchEmail(String secretCode) {
66-
return verifyCodeAndFetchEmail(secretCode, null);
65+
public String verifySecretCodeAndFetchEmail(String secretCode) {
66+
return verifySecretCodeAndFetchEmail(secretCode, null);
6767
}
6868

6969
protected void clearAccessAndRefreshTokens() {
@@ -87,7 +87,7 @@ public boolean verifyUser(String email, String secretCode, Long domainId) {
8787
throw new CloudAuthenticationException("Google provider is not registered, so user cannot be verified");
8888
}
8989

90-
String verifiedEmail = verifyCodeAndFetchEmail(secretCode, domainId);
90+
String verifiedEmail = verifySecretCodeAndFetchEmail(secretCode, domainId);
9191
if (verifiedEmail == null || !email.equals(verifiedEmail)) {
9292
throw new CloudRuntimeException("Unable to verify the email address with the provided secret");
9393
}
@@ -97,7 +97,7 @@ public boolean verifyUser(String email, String secretCode, Long domainId) {
9797
}
9898

9999
@Override
100-
public String verifyCodeAndFetchEmail(String secretCode, Long domainId) {
100+
public String verifySecretCodeAndFetchEmail(String secretCode, Long domainId) {
101101
OauthProviderVO provider = _oauthProviderDao.findByProviderAndDomainWithGlobalFallback(getName(), domainId);
102102
String clientId = provider.getClientId();
103103
String secret = provider.getSecretKey();

plugins/user-authenticators/oauth2/src/test/java/org/apache/cloudstack/oauth2/api/command/VerifyOAuthCodeAndGetUserCmdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testAuthenticate() {
7474
params.put("provider", providerArray);
7575

7676
when(oauth2mgr.resolveDomainId(any())).thenReturn(null);
77-
when(oauth2mgr.verifyCodeAndFetchEmail(eq("secretcode"), eq("provider"), any())).thenReturn("test@example.com");
77+
when(oauth2mgr.verifySecretCodeAndFetchEmail(eq("secretcode"), eq("provider"), any())).thenReturn("test@example.com");
7878

7979
String response = cmd.authenticate("command", params, session, remoteAddress, responseType, auditTrailSb, req, resp);
8080

@@ -93,7 +93,7 @@ public void testAuthenticateWithInvalidCode() throws Exception {
9393
params.put("provider", providerArray);
9494

9595
when(oauth2mgr.resolveDomainId(any())).thenReturn(null);
96-
when(oauth2mgr.verifyCodeAndFetchEmail(eq("invalidcode"), eq("provider"), any())).thenReturn(null);
96+
when(oauth2mgr.verifySecretCodeAndFetchEmail(eq("invalidcode"), eq("provider"), any())).thenReturn(null);
9797

9898
cmd.authenticate("command", params, session, remoteAddress, responseType, auditTrailSb, req, resp);
9999
}

0 commit comments

Comments
 (0)