-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from assimbly/develop
Release 5.0.0
- Loading branch information
Showing
12 changed files
with
203 additions
and
143 deletions.
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
49 changes: 49 additions & 0 deletions
49
oauth2token/src/main/java/org/assimbly/oauth2token/tenant/TenantVariableManager.java
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.assimbly.oauth2token.tenant; | ||
|
||
import org.assimbly.tenantvariables.domain.TenantVariable; | ||
import org.assimbly.tenantvariables.mongo.MongoDao; | ||
|
||
public class TenantVariableManager { | ||
|
||
private static final String STATIC_TENANT_VARIABLE_SUFFIX = "_"+ TenantVariable.TenantVarType.StaticTenantVariable.name(); | ||
|
||
public static String getTenantVariableValue(String tokenName, String tenant, String environment) { | ||
return MongoDao.getTenantVariableValue(tokenName, tenant, environment); | ||
} | ||
|
||
public static String discoverAndGetTenantVariableValue(String tokenName, String tenant, String environment) { | ||
TenantVariable.TenantVarType tenantVarType = TenantVariable.TenantVarType.TenantVariable; | ||
|
||
if(isStaticTenantVariable(tokenName)) { | ||
tokenName = getStaticTenantVariableName(tokenName); | ||
tenantVarType = TenantVariable.TenantVarType.StaticTenantVariable; | ||
} | ||
|
||
return MongoDao.getTenantVariableValue(tokenName, tenant, environment, tenantVarType); | ||
} | ||
|
||
public static void saveTenantVariable(String tokenName, String accessToken, String tenant, String environment) { | ||
MongoDao.saveTenantVariable(tokenName, accessToken, tenant, environment); | ||
} | ||
|
||
public static void discoverAndSaveTenantVariable(String tokenName, String accessToken, String tenant, String environment) { | ||
TenantVariable.TenantVarType tenantVarType = TenantVariable.TenantVarType.TenantVariable; | ||
|
||
if(TenantVariableManager.isStaticTenantVariable(tokenName)) { | ||
tokenName = getStaticTenantVariableName(tokenName); | ||
tenantVarType = TenantVariable.TenantVarType.StaticTenantVariable; | ||
} | ||
|
||
MongoDao.saveTenantVariable(tokenName, accessToken, tenant, environment, tenantVarType); | ||
} | ||
|
||
public static boolean isStaticTenantVariable(String tokenName) { | ||
return tokenName.endsWith(STATIC_TENANT_VARIABLE_SUFFIX); | ||
} | ||
|
||
private static String getStaticTenantVariableName(String tokenName) { | ||
int index = tokenName.indexOf(STATIC_TENANT_VARIABLE_SUFFIX); | ||
return tokenName.substring(0, index); | ||
} | ||
|
||
} |
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
Oops, something went wrong.