use of org.wso2.carbon.user.core.UserStoreManager in project carbon-apimgt by wso2.
the class StandaloneAuthorizationManagerClientTestCase method testGetRoleNames.
@Test
public void testGetRoleNames() throws Exception {
StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
standaloneAuthorizationManagerClient.getRoleNames();
Mockito.verify(userStoreManager, Mockito.times(1)).getRoleNames();
}
use of org.wso2.carbon.user.core.UserStoreManager in project carbon-apimgt by wso2.
the class UserSignUpWSWorkflowExecutorTest method init.
@Before
public void init() throws Exception {
ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
ConfigurationContext configurationContext = Mockito.mock(ConfigurationContext.class);
RealmService realmService = Mockito.mock(RealmService.class);
UserRealm userRealm = Mockito.mock(UserRealm.class);
userStoreManager = Mockito.mock(UserStoreManager.class);
TenantManager tenantManager = Mockito.mock(TenantManager.class);
apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class);
serviceClient = Mockito.mock(ServiceClient.class);
APIManagerConfigurationService apiManagerConfigurationService = new APIManagerConfigurationServiceImpl(apiManagerConfiguration);
PowerMockito.mockStatic(SelfSignUpUtil.class);
PowerMockito.mockStatic(CarbonUtils.class);
PowerMockito.mockStatic(APIUtil.class);
PowerMockito.when(APIUtil.isAnalyticsEnabled()).thenReturn(true);
PowerMockito.doNothing().when(CarbonUtils.class, "setBasicAccessSecurityHeaders", Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any());
PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
PowerMockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(apiManagerConfigurationService);
PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
Mockito.when(realmService.getTenantManager()).thenReturn(tenantManager);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(realmService.getTenantUserRealm(tenantID)).thenReturn(userRealm);
Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
apiMgtDAO = TestUtils.getApiMgtDAO();
userSignUpWSWorkflowExecutor = new UserSignUpWSWorkflowExecutor();
workflowDTO = new WorkflowDTO();
workflowDTO.setCallbackUrl(callBackURL);
workflowDTO.setTenantDomain(tenantDomain);
workflowDTO.setExternalWorkflowReference(externalWFReference);
workflowDTO.setWorkflowReference(testUsername + "@carbon.super");
}
use of org.wso2.carbon.user.core.UserStoreManager in project carbon-apimgt by wso2.
the class SelfSignUpUtil method isUserNameWithAllowedDomainName.
/**
* Check whether user can signup to the tenant domain
*
* @param userName - The user name
* @param realm - The realm
* @return - A boolean value
* @throws APIManagementException
*/
public static boolean isUserNameWithAllowedDomainName(String userName, UserRealm realm) throws APIManagementException {
int index;
index = userName.indexOf('/');
// Check whether we have a secondary UserStoreManager setup.
if (index > 0) {
// Using the short-circuit. User name comes with the domain name.
try {
return !realm.getRealmConfiguration().isRestrictedDomainForSlefSignUp(userName.substring(0, index));
} catch (UserStoreException e) {
throw new APIManagementException(e.getMessage(), e);
}
}
return true;
}
use of org.wso2.carbon.user.core.UserStoreManager in project carbon-apimgt by wso2.
the class UserSignUpWorkflowExecutor method deleteUser.
/**
* Method to delete a user
*
* @param tenantDomain
* @param userName
* @throws Exception
*/
protected static void deleteUser(String tenantDomain, String userName) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Remove the rejected user :" + userName);
}
RealmService realmService = ServiceReferenceHolder.getInstance().getRealmService();
int tenantId = ServiceReferenceHolder.getInstance().getRealmService().getTenantManager().getTenantId(tenantDomain);
UserRealm realm = (UserRealm) realmService.getTenantUserRealm(tenantId);
UserStoreManager manager = realm.getUserStoreManager();
manager.deleteUser(userName);
}
use of org.wso2.carbon.user.core.UserStoreManager in project carbon-apimgt by wso2.
the class RemoteUserManagerClient method getUserList.
/**
* Return userlist based on a claim
*
* @param claim - The claim
* @param claimValue - The Claim Value
* @return - A user list
* @throws APIManagementException
*/
public String[] getUserList(String claim, String claimValue) throws APIManagementException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
UserRealm tenantUserRealm = (UserRealm) ServiceReferenceHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
UserStoreManager userStoreManager = tenantUserRealm.getUserStoreManager();
return userStoreManager.getUserList(claim, claimValue, null);
} catch (Exception e) {
throw new APIManagementException("Error when retrieving user list", e);
}
}
Aggregations