Java Code Examples for org.wso2.carbon.base.MultitenantConstants#SUPER_TENANT_DOMAIN_NAME

The following examples show how to use org.wso2.carbon.base.MultitenantConstants#SUPER_TENANT_DOMAIN_NAME . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UtilsTest.java    From carbon-device-mgt with Apache License 2.0 6 votes vote down vote up
@Test(description = "This testcase tests the functionality of the DeviceSchemaInitializer")
public void testDeviceSchemaInitializer()
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    String deviceType = "sample2";
    String expectedDBLocation =
            System.getProperty("carbon.home") + File.separator + "dbscripts" + File.separator + "cdm"
                    + File.separator + "plugins" + File.separator + deviceType + File.separator + "h2.sql";
    DeviceSchemaInitializer deviceSchemaInitializer = new DeviceSchemaInitializer(null, deviceType,
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Method getDbScriptLocation = DeviceSchemaInitializer.class
            .getDeclaredMethod("getDbScriptLocation", String.class);
    getDbScriptLocation.setAccessible(true);

    String dbLocation = (String) getDbScriptLocation.invoke(deviceSchemaInitializer, "h2");
    Assert.assertEquals(dbLocation, expectedDBLocation,
            "Expected DB location for the device type is not retrieved");
}
 
Example 2
Source File: DeviceTypeManagerNegativeTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Test(description = "This test case tests the behaviour of the DeviceTypeManager creation when having a "
        + "defective platform configuration ", expectedExceptions = {DeviceTypeDeployerPayloadException.class},
        expectedExceptionsMessageRegExp = "Error occurred while getting default platform configuration for the "
                + "device type wrong *")
public void testWithDefectivePlatformConfiguration() {
    DeviceTypeConfigIdentifier wrongDeviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier("wrong",
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    new DeviceTypeManager(wrongDeviceTypeConfigIdentifier, androidDeviceTypeConfiguration);
}
 
Example 3
Source File: ReCaptchaApi.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Return the reCaptchaGet details in the headers for the given tenant.
 *
 * @param tenantDomain          Tenant domain. Default `carbon.super` (optional).
 * @param isEndpointTenantAware Is tenant aware endpoint.
 * @param captchaType           Captcha type.
 * @param recoveryType          Recovery type.
 * @return Return captcha details as ReCaptchaProperties.
 * @throws ApiException if fails to make API call.
 */
public ReCaptchaProperties getReCaptcha(String tenantDomain, boolean isEndpointTenantAware, String captchaType,
                                        String recoveryType) throws ApiException {

    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH, isEndpointTenantAware);
    apiClient.setBasePath(basePath);

    String localVarPath = "/captcha";

    // Query params
    List<Pair> localVarQueryParams = new ArrayList<>();
    Map<String, String> localVarHeaderParams = new HashMap<>();
    Map<String, Object> localVarFormParams = new HashMap<>();

    localVarQueryParams.addAll(apiClient.parameterToPairs(StringUtils.EMPTY, TENANTDOMAIN, tenantDomain));
    localVarQueryParams.addAll(apiClient.parameterToPairs(StringUtils.EMPTY, CAPTCHA_TYPE, captchaType));
    localVarQueryParams.addAll(apiClient.parameterToPairs(StringUtils.EMPTY, RECOVERY_TYPE, recoveryType));

    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<ReCaptchaProperties> localVarReturnType = new GenericType<ReCaptchaProperties>() {
    };

    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, null, localVarHeaderParams,
            localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 4
Source File: ConfigurationUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves loaded tenant domain from carbon context.
 *
 * @return tenant domain of the request is being served.
 */
public static String getTenantDomainFromContext() {

    String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    if (IdentityUtil.threadLocalProperties.get().get(TENANT_NAME_FROM_CONTEXT) != null) {
        tenantDomain = (String) IdentityUtil.threadLocalProperties.get().get(TENANT_NAME_FROM_CONTEXT);
    }
    return tenantDomain;
}
 
Example 5
Source File: UsernameRecoveryApi.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Return the user name recovery supported claims in the given tenant.
 *
 * @param tenantDomain          tenant domain. Default &#x60;carbon.super&#x60; (optional).
 * @param isEndpointTenantAware Is tenant aware endpoint.
 * @return List<Claim>
 * @throws ApiException if fails to make API call.
 */
public List<Claim> getClaimsForUsernameRecovery(String tenantDomain, boolean isEndpointTenantAware)
        throws ApiException {

  if (StringUtils.isBlank(tenantDomain)) {
    tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
  }

  basePath = IdentityManagementEndpointUtil
          .getBasePath(tenantDomain, IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
                  isEndpointTenantAware);
  apiClient.setBasePath(basePath);

  // Create path and map variables
  String localVarPath = "/claims".replaceAll("\\{format\\}", "json");

  // Query params
  List<Pair> localVarQueryParams = new ArrayList<Pair>();
  Map<String, String> localVarHeaderParams = new HashMap<String, String>();
  Map<String, Object> localVarFormParams = new HashMap<String, Object>();

  localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));
  localVarQueryParams.addAll(apiClient.parameterToPairs("", "isUsernameRecovery", true));

  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

  String[] localVarAuthNames = new String[] {};

  GenericType<List<Claim>> localVarReturnType = new GenericType<List<Claim>>() {
  };
  return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, null, localVarHeaderParams, localVarFormParams,
          localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 6
Source File: JWTTokenGenerator.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private Certificate getCertificate(String tenantDomain, int tenantId) throws Exception {

        if (tenantDomain == null) {
            tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
        }

        if (tenantId == 0) {
            tenantId = OAuth2Util.getTenantId(tenantDomain);
        }

        Certificate publicCert = null;

        if (!(publicCerts.containsKey(tenantId))) {
            // get tenant's key store manager
            KeyStoreManager tenantKSM = KeyStoreManager.getInstance(tenantId);

            KeyStore keyStore = null;
            if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
                // derive key store name
                String ksName = tenantDomain.trim().replace(".", "-");
                String jksName = ksName + ".jks";
                keyStore = tenantKSM.getKeyStore(jksName);
                publicCert = keyStore.getCertificate(tenantDomain);
            } else {
                publicCert = tenantKSM.getDefaultPrimaryCertificate();
            }
            if (publicCert != null) {
                publicCerts.put(tenantId, publicCert);
            }
        } else {
            publicCert = publicCerts.get(tenantId);
        }
        return publicCert;
    }
 
Example 7
Source File: DefaultRequestCoordinator.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private String getTenantDomain(HttpServletRequest request) throws FrameworkException {

        String tenantDomain = getTenantDomainFromContext();
        if (StringUtils.isNotBlank(tenantDomain)) {
            if (log.isDebugEnabled()) {
                log.debug("Tenant domain resolved from the thread local context: " + tenantDomain);
            }
        } else {
            // Fall back to the tenant domain in the request param.
            tenantDomain = request.getParameter(FrameworkConstants.RequestParams.TENANT_DOMAIN);
            if (log.isDebugEnabled()) {
                log.debug("Tenant domain resolved from request parameter: " + tenantDomain);
            }
        }

        if (tenantDomain == null || tenantDomain.isEmpty() || "null".equals(tenantDomain)) {

            String tenantId = request.getParameter(FrameworkConstants.RequestParams.TENANT_ID);

            if (tenantId != null && !"-1234".equals(tenantId)) {
                try {
                    Tenant tenant = FrameworkServiceComponent.getRealmService().getTenantManager()
                            .getTenant(Integer.parseInt(tenantId));
                    if (tenant != null) {
                        tenantDomain = tenant.getDomain();
                    }
                } catch (Exception e) {
                    throw new FrameworkException(e.getMessage(), e);
                }
            } else {
                tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
            }
        }
        return tenantDomain;
    }
 
Example 8
Source File: UtilsTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Test(description = "This test case tests the DeviceTypeConfigIdentifier equals method")
public void testDeviceTypeConfigIdentifier() {
    DeviceTypeConfigIdentifier deviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier("sample",
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    DeviceTypeConfigIdentifier clonedDeviceTypeConfigIdentifier = new DeviceTypeConfigIdentifier("sample",
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    Assert.assertTrue(deviceTypeConfigIdentifier.equals(clonedDeviceTypeConfigIdentifier),
            "Clone device type config identifier gives wrong results for equals check.");
    Assert.assertFalse(deviceTypeConfigIdentifier.equals(null),
            "Device Type config identifier object comparison gives wrong results.");
}
 
Example 9
Source File: TenantManager.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private TenantManager() {
    this.tenantIdTenantMap = new HashMap<Integer, Tenant>();
    this.tenantDomainTenantMap = new HashMap<String, Tenant>();
    Tenant superTenant = new Tenant(MultitenantConstants.SUPER_TENANT_ID,
            MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    this.tenantIdTenantMap.put(MultitenantConstants.SUPER_TENANT_ID, superTenant);
    this.tenantDomainTenantMap.put(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, superTenant);
}
 
Example 10
Source File: ConnectedCupManagerService.java    From product-iots with Apache License 2.0 4 votes vote down vote up
@Override
public ProvisioningConfig getProvisioningConfig() {
    return new ProvisioningConfig(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, false);
}
 
Example 11
Source File: SecurityQuestionApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to initiate password recovery using user challenge questions at once. Response will be a
 * random challenge questions with a confirmation key.
 *
 * @param username     username of the user (required)
 * @param realm        &#x60;User Store Domain&#x60; which user belongs. If not specified,
 *                     it will be &#x60;PRIMARY&#x60; domain.  (optional)
 * @param tenantDomain &#x60;Tenant Domain&#x60; which user belongs. If not specified,
 *                     it will be &#x60;carbon.super&#x60; domain.  (optional)
 * @param headers      Adding headers for request recover password api. (optional)
 * @return InitiateAllQuestionResponse
 * @throws ApiException if fails to make API call
 */
public InitiateAllQuestionResponse securityQuestionsGet(String username, String realm, String tenantDomain,
                                                        Map<String, String> headers) throws ApiException {

    Object localVarPostBody = null;

    // verify the required parameter 'username' is set
    if (username == null) {
        throw new ApiException(400, "Missing the required parameter 'username' when calling securityQuestionsGet");
    }

    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/security-questions".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    if (MapUtils.isNotEmpty(headers)) {
        localVarHeaderParams.putAll(headers);
    }

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "realm", realm));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));


    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<InitiateAllQuestionResponse> localVarReturnType = new GenericType<InitiateAllQuestionResponse>() {
    };
    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 12
Source File: NotificationApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API can be used to recover forgot username.
 *
 * @param claim        User answers for recovery claims. (required)
 * @param tenantDomain Tenant Domain which user belongs. Default &#x60;carbon.super&#x60; (optional)
 * @param notify       If notify&#x3D;true then, notifications will be internally managed. (optional)
 * @throws ApiException if fails to make API call
 */
public void recoverUsernamePost(List<UserClaim> claim, String tenantDomain, Boolean notify) throws ApiException {

    Object localVarPostBody = claim;

    // verify the required parameter 'claim' is set
    if (claim == null) {
        throw new ApiException(400, "Missing the required parameter 'claim' when calling recoverUsernamePost");
    }

    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/recover-username/".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "notify", notify));

    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
}
 
Example 13
Source File: IdentityManagementEndpointUtilTest.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
@DataProvider(name = "getBasePathTestData")
public Object[][] getBasePathTestData() {

    return new Object[][] {
            // isTenantQualifiedUrlsEnabled
            // contextUrl
            // tenantDomain
            // context
            // expected value
            { true,
              "https://foo.com",
              "test.com",
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://foo.com/api/identity/recovery/v0.9"
            },
            { false,
              "https://foo.com",
              "test.com",
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://foo.com/api/identity/recovery/v0.9"
            },
            { false,
              null,
              "test.com",
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://wso2.org:9443/t/test.com/api/identity/recovery/v0.9"
            },
            { false,
              "https://foo.com",
              null,
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://foo.com/api/identity/recovery/v0.9"
            },
            { false,
              null,
              null,
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://wso2.org:9443/api/identity/recovery/v0.9"
            },
            { false,
              null,
              MultitenantConstants.SUPER_TENANT_DOMAIN_NAME,
              IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH,
              "https://wso2.org:9443/api/identity/recovery/v0.9"
            }
    };
}
 
Example 14
Source File: TestTenantManager.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
public String getDomain(int i) throws UserStoreException {
    return MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
 
Example 15
Source File: PasswordRecoveryApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to send password recovery confirmation over defined channels like email/sms
 *
 * @param recoveryInitiatingRequest It can be sent optional property parameters over email based on email template. (required)
 * @param type                      Notification Type (optional)
 * @param notify                    If notify&#x3D;true then, notifications will be internally managed. (optional)
 * @return String
 * @throws ApiException if fails to make API call
 */
public String recoverPasswordPost(RecoveryInitiatingRequest recoveryInitiatingRequest, String type, Boolean notify) throws ApiException {
    Object localVarPostBody = recoveryInitiatingRequest;

    // verify the required parameter 'recoveryInitiatingRequest' is set
    if (recoveryInitiatingRequest == null) {
        throw new ApiException(400, "Missing the required parameter 'recoveryInitiatingRequest' when calling recoverPasswordPost");
    }

    String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    if (StringUtils.isNotBlank(recoveryInitiatingRequest.getUser().getTenantDomain())) {
        tenantDomain = recoveryInitiatingRequest.getUser().getTenantDomain();
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/recover-password".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "type", type));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "notify", notify));


    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<String> localVarReturnType = new GenericType<String>() {
    };
    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 16
Source File: PasswordRecoveryApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to initiate password recovery using user challenge questions. Response will be a random challenge question with a confirmation key.
 *
 * @param username     username of the user (required)
 * @param realm        &#x60;User Store Domain&#x60; which user belongs. If not specified, it will be &#x60;PRIMARY&#x60; domain.  (optional)
 * @param tenantDomain &#x60;Tenant Domain&#x60; which user belongs. If not specified, it will be &#x60;carbon.super&#x60; domain.  (optional)
 * @return InitiateQuestionResponse
 * @throws ApiException if fails to make API call
 */
public InitiateQuestionResponse securityQuestionGet(String username, String realm, String tenantDomain) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'username' is set
    if (username == null) {
        throw new ApiException(400, "Missing the required parameter 'username' when calling securityQuestionGet");
    }


    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/security-question".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "realm", realm));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));


    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<InitiateQuestionResponse> localVarReturnType = new GenericType<InitiateQuestionResponse>() {
    };
    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 17
Source File: PasswordRecoveryApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to initiate password recovery using user challenge questions at once. Response will be a random challenge questions with a confirmation key.
 *
 * @param username     username of the user (required)
 * @param realm        &#x60;User Store Domain&#x60; which user belongs. If not specified, it will be &#x60;PRIMARY&#x60; domain.  (optional)
 * @param tenantDomain &#x60;Tenant Domain&#x60; which user belongs. If not specified, it will be &#x60;carbon.super&#x60; domain.  (optional)
 * @return InitiateAllQuestionResponse
 * @throws ApiException if fails to make API call
 */
public InitiateAllQuestionResponse securityQuestionsGet(String username, String realm, String tenantDomain) throws ApiException {
    Object localVarPostBody = null;

    // verify the required parameter 'username' is set
    if (username == null) {
        throw new ApiException(400, "Missing the required parameter 'username' when calling securityQuestionsGet");
    }


    if (StringUtils.isBlank(tenantDomain)) {
        tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    basePath = IdentityManagementEndpointUtil.getBasePath(tenantDomain,
            IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/security-questions".replaceAll("\\{format\\}", "json");

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "realm", realm));
    localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));


    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[]{};

    GenericType<InitiateAllQuestionResponse> localVarReturnType = new GenericType<InitiateAllQuestionResponse>() {
    };
    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 18
Source File: SelfRegisterApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to user self registration.
 *
 * @param user It can be sent optional property parameters over email based on email template. (required)
 * @return String
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public String mePostCall(SelfUserRegistrationRequest user, Map<String, String> headers) throws ApiException {
    Object localVarPostBody = user;

    // verify the required parameter 'user' is set
    if (user == null) {
        throw new ApiException(400, "Missing the required parameter 'user' when calling mePost");
    }

    String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    if (StringUtils.isNotBlank(user.getUser().getTenantDomain())) {
        tenantDomain = user.getUser().getTenantDomain();
    }

    basePath = IdentityManagementEndpointUtil
            .getBasePath(tenantDomain, IdentityManagementEndpointConstants.UserInfoRecovery.USER_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/me".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<>();

    if (headers != null) {
        localVarHeaderParams.putAll(headers);
    }

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    String[] localVarAuthNames = new String[]{};

    GenericType<String> localVarReturnType = new GenericType<String>() {
    };

    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);

}
 
Example 19
Source File: SelfRegisterApi.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * This API is used to resend confirmation code, if it is missing.
 *
 * @param user It can be sent optional property parameters over email based on email template. (required)
 * @return String
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public String resendCodePostCall(ResendCodeRequest user) throws ApiException {
    Object localVarPostBody = user;

    // verify the required parameter 'user' is set
    if (user == null) {
        throw new ApiException(400, "Missing the required parameter 'user' when calling resendCodePost(Async)");
    }

    String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    if (StringUtils.isNotBlank(user.getUser().getTenantDomain())) {
        tenantDomain = user.getUser().getTenantDomain();
    }

    basePath = IdentityManagementEndpointUtil
            .getBasePath(tenantDomain, IdentityManagementEndpointConstants.UserInfoRecovery.USER_API_RELATIVE_PATH);
    apiClient.setBasePath(basePath);

    // create path and map variables
    String localVarPath = "/resend-code".replaceAll("\\{format\\}", "json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = {
            "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {
            "application/json"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);


    String[] localVarAuthNames = new String[]{};

    GenericType<String> localVarReturnType = new GenericType<String>() {
    };
    return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
Example 20
Source File: UsernameRecoveryApi.java    From carbon-identity-framework with Apache License 2.0 2 votes vote down vote up
/**
 * This API can be used to recover forgot username.
 *
 * @param claim        User answers for recovery claims. (required)
 * @param tenantDomain Tenant Domain which user belongs. Default &#x60;carbon.super&#x60; (optional)
 * @param notify       If notify&#x3D;true then, notifications will be internally managed. (optional)
 * @param headers      If reCaptcha respond is found, embedded in request header. (optional)
 * @throws ApiException if fails to make API call
 */
public void recoverUsernamePost(List<UserClaim> claim, String tenantDomain, Boolean notify,
                                Map<String, String> headers) throws ApiException {

  Object localVarPostBody = claim;
  
  // verify the required parameter 'claim' is set
  if (claim == null) {
    throw new ApiException(400, "Missing the required parameter 'claim' when calling recoverUsernamePost");
  }


  if (StringUtils.isBlank(tenantDomain)) {
    tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
  }

  basePath = IdentityManagementEndpointUtil
          .getBasePath(tenantDomain, IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_API_RELATIVE_PATH);
  apiClient.setBasePath(basePath);

  // create path and map variables
  String localVarPath = "/recover-username/".replaceAll("\\{format\\}","json");

  // query params
  List<Pair> localVarQueryParams = new ArrayList<Pair>();
  Map<String, String> localVarHeaderParams = new HashMap<String, String>();

  if (MapUtils.isNotEmpty(headers)) {
    localVarHeaderParams.putAll(headers);
  }

  Map<String, Object> localVarFormParams = new HashMap<String, Object>();

  localVarQueryParams.addAll(apiClient.parameterToPairs("", "tenant-domain", tenantDomain));
  localVarQueryParams.addAll(apiClient.parameterToPairs("", "notify", notify));

  

  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

  String[] localVarAuthNames = new String[] {  };


  apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
}