Class CommonUtil
- java.lang.Object
-
- org.wso2.carbon.stratos.common.util.CommonUtil
-
public class CommonUtil extends Object
Common Utility methods for Stratos. Now this class has been growing with several util methods - Should refactor accordingly.
-
-
Constructor Summary
Constructors Constructor Description CommonUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.axiom.om.OMElementbuildOMElement(InputStream inputStream)builds the OMElement from the given inputStreamstatic voiddenyAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm)static StringgetAdminPassword()static StringgetAdminUserName()static StringgetCurrentMonthString()static DategetDateFromMonthString(String yearMonth)static StringgetEula()static StringgetMonthString(int relativeMonth)static StringgetMonthString(Calendar calendar)static StringgetNotificationEmailAddress()Gets the notification email address of the admin upon the tenant creation.static StratosConfigurationgetStratosConfig()static StringgetSuperAdminEmail()static StringgetTenantDomainRegexPattern()static booleanisChargedOnRegistration()static booleanisDomainNameAvailable(String tenantDomain)method to check whether a domain name is available to register given a domain namestatic booleanisEmailValidationMandatory()Checks whether the email validation is mandatory from the configuration file.static booleanisPublicCloudSetup()Checks whether it is for the public cloud setup or Mars.static booleanisTenantActivationModerated()static booleanisTenantManagementEmailsDisabled()Checks whether the email sending is enabled from the configuration file.static StratosConfigurationloadStratosConfiguration()Returns the configurations from the stratos configuration file.static StringloadTermsOfUsage()Loading the EULA.static voidsetAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm)static voidsetEula(String eula)static voidsetStratosConfig(StratosConfiguration stratosConfig)static booleanvalidateDomainFromSuccessKey(org.wso2.carbon.registry.core.session.UserRegistry governanceSystemRegistry, String domain, String successKey)validates domain from the successkeystatic voidvalidateEmail(String email)validates the email.static voidvalidateName(String name, String variable)
-
-
-
Method Detail
-
getStratosConfig
public static StratosConfiguration getStratosConfig()
-
setStratosConfig
public static void setStratosConfig(StratosConfiguration stratosConfig)
-
getEula
public static String getEula()
-
setEula
public static void setEula(String eula)
-
isEmailValidationMandatory
public static boolean isEmailValidationMandatory()
Checks whether the email validation is mandatory from the configuration file.- Returns:
- true, if the email validation is mandatory to login. Default is false.
-
isTenantManagementEmailsDisabled
public static boolean isTenantManagementEmailsDisabled()
Checks whether the email sending is enabled from the configuration file.- Returns:
- true, if the email sending is disabled. By default, this is disabled, and tenant activation is done without any email sending.
-
getSuperAdminEmail
public static String getSuperAdminEmail()
-
getAdminUserName
public static String getAdminUserName()
-
getAdminPassword
public static String getAdminPassword()
-
isTenantActivationModerated
public static boolean isTenantActivationModerated()
-
isChargedOnRegistration
public static boolean isChargedOnRegistration()
-
isPublicCloudSetup
public static boolean isPublicCloudSetup()
Checks whether it is for the public cloud setup or Mars.- Returns:
- true, if it is not for the private cloud setups. Default is true.
-
getTenantDomainRegexPattern
public static String getTenantDomainRegexPattern()
-
getNotificationEmailAddress
public static String getNotificationEmailAddress()
Gets the notification email address of the admin upon the tenant creation.- Returns:
- notification email address for the tenant creations.
-
getMonthString
public static String getMonthString(int relativeMonth)
-
getDateFromMonthString
public static Date getDateFromMonthString(String yearMonth) throws ParseException
- Throws:
ParseException
-
getCurrentMonthString
public static String getCurrentMonthString()
-
setAnonAuthorization
public static void setAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm) throws org.wso2.carbon.registry.core.exceptions.RegistryException
- Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException
-
denyAnonAuthorization
public static void denyAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm) throws org.wso2.carbon.registry.core.exceptions.RegistryException
- Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException
-
buildOMElement
public static org.apache.axiom.om.OMElement buildOMElement(InputStream inputStream) throws Exception
builds the OMElement from the given inputStream- Parameters:
inputStream- , given input - inputStream- Returns:
- OMElement
- Throws:
Exception
-
validateEmail
public static void validateEmail(String email) throws Exception
validates the email.- Parameters:
email- email address- Throws:
Exception- if validation failed.
-
validateName
public static void validateName(String name, String variable) throws Exception
- Parameters:
name- validate the name.variable- entry name.- Throws:
Exception- if empty
-
validateDomainFromSuccessKey
public static boolean validateDomainFromSuccessKey(org.wso2.carbon.registry.core.session.UserRegistry governanceSystemRegistry, String domain, String successKey) throws org.wso2.carbon.registry.core.exceptions.RegistryExceptionvalidates domain from the successkey- Parameters:
governanceSystemRegistry- - The governance system registrydomain- - tenant domainsuccessKey- - successkey- Returns:
- true, if successfully validated
- Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException
-
loadStratosConfiguration
public static StratosConfiguration loadStratosConfiguration()
Returns the configurations from the stratos configuration file.- Returns:
- stratos configurations
-
loadTermsOfUsage
public static String loadTermsOfUsage()
Loading the EULA. ultimately we shall be loading the eula from the web page itself. But loading from file should be there to customize the EULA based on the private deployments, etc.- Returns:
- eula
-
isDomainNameAvailable
public static boolean isDomainNameAvailable(String tenantDomain) throws Exception
method to check whether a domain name is available to register given a domain name- Parameters:
tenantDomain- , domain name- Returns:
- true, if the domain is available to register
- Throws:
Exception
-
-