Package org.wso2.carbon.user.core.service

Examples of org.wso2.carbon.user.core.service.RealmService


                    }
                }
                String tenantAwareUsername = UserCoreUtil.getTenantLessUsername(userName);
                String tenantDomain;
                try {
                    RealmService realmService = ServerAdminDataHolder.getInstance()
                            .getRealmService();
                    tenantDomain = UserCoreUtil.getTenantDomain(realmService, userName);
                } catch (UserStoreException e) {
                    log.error("Unable to find the tenant domain :" + e.getMessage(), e);
                    throw new AuthenticationException("Unable to find the tenant domain", e);
View Full Code Here


            e.printStackTrace();
        }
    }
   
    public RealmService getRealmService() throws Exception{
        RealmService realmService  = null;
        if(dlgtRealmTracker != null){
            realmService = (RealmService)dlgtRealmTracker.getService();
        }
       
        if(realmService == null){
View Full Code Here

                        remoteAddress, "Data");
                return false;
            }

            RegistryService registryService = CarbonServicesServiceComponent.getRegistryService();
            RealmService realmService = CarbonServicesServiceComponent.getRealmService();

            String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            handleAuthenticationStarted(tenantId);
            String userNameWithDomain = username;
            username = UserCoreUtil.getTenantLessUsername(username);
            UserRealm realm = AnonymousSessionUtil.getRealmByTenantDomain(registryService,
                    realmService, tenantDomain);
View Full Code Here

            if (isLoggedIn) {
                String uuid = UUID.randomUUID().toString();
                data = new RememberMeData();
                data.setMaxAge(CarbonConstants.REMEMBER_ME_COOKIE_TTL);
                data.setValue(username + "-" + uuid);
                RealmService realmService = CarbonServicesServiceComponent.getRealmService();
                String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
                int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
                UserRealm realm = realmService.getTenantUserRealm(tenantId);
                realm.getUserStoreManager().addRememberMe(username, uuid);
                data.setAuthenticated(true);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
View Full Code Here

   
    private boolean createSessionForValidRememberMe(String cookie, HttpSession httpSession) {
        boolean isValid = false;
        try {

            RealmService realmService = CarbonServicesServiceComponent.getRealmService();

            int index = cookie.indexOf("-");
            String userNameWithTenant = cookie.substring(0, index);
            String tenantDomain = UserCoreUtil.getTenantDomain(realmService, userNameWithTenant);
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            handleAuthenticationStarted(tenantId);

            String userName = UserCoreUtil.getTenantLessUsername(userNameWithTenant);
            String uuid = cookie.substring(index + 1);
            UserRealm realm = realmService.getTenantUserRealm(tenantId);
            boolean isAuthenticated = realm.getUserStoreManager().isValidRememberMeToken(userName,
                                                                                         uuid);
            boolean isAuthorized = false;
            if (isAuthenticated) {
                isAuthorized =
View Full Code Here

        boolean isDomainAvailable = CommonUtil.isDomainNameAvailable(tenantDomain);
        if (!isDomainAvailable) {
            throw new Exception("Domain is not available to register");
        }

        RealmService realmService = TenantMgtCoreServiceComponent.getRealmService();
        RealmConfiguration realmConfig = realmService.getBootstrapRealmConfiguration();
        TenantMgtConfiguration tenantMgtConfiguration = realmService.getTenantMgtConfiguration();
        MultiTenantRealmConfigBuilder builder = TenantMgtCoreServiceComponent.
                getRealmService().getMultiTenantRealmConfigBuilder();
        RealmConfiguration realmConfigToPersist =
                builder.getRealmConfigForTenantToPersist(realmConfig, tenantMgtConfiguration,
                                                         tenant, -1);
View Full Code Here

        return tenantId;
    }

    private void doPostTenantCreationActions(Tenant tenant,
                                             String originatedService) throws Exception {
        RealmService realmService = TenantMgtCoreServiceComponent.getRealmService();
        UserRealm userRealm;
        try {
            userRealm = (UserRealm) realmService.getTenantUserRealm(tenant.getId());
        } catch (UserStoreException e) {
            String msg = "Error in creating Realm for tenant: " + tenant.getDomain();
            throw new Exception(msg, e);
        }
View Full Code Here

            String msg = "Error in retrieving the tenant information for the tenant id: " +
                    tenantId + ".";
            log.info(msg, e);
            throw new Exception(msg, e);
        }
        RealmService realmService = Util.getRealmService();
        try {
            Map<String, String> claimsMap = new HashMap<String, String>();
            claimsMap.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME,
                    accountInfoBean.getFirstname());
            claimsMap.put(UserCoreConstants.ClaimTypeURIs.SURNAME, accountInfoBean.getLastname());
            UserStoreManager userStoreManager =
                    (UserStoreManager) realmService.getTenantUserRealm(tenantId)
                            .getUserStoreManager();
            userStoreManager.setUserClaimValues(
                    ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId),
                    claimsMap, UserCoreConstants.DEFAULT_PROFILE);
            log.info("FirstName: " + accountInfoBean.getFirstname() +
View Full Code Here

        String ksName = tenantDomain.trim().replace(".", "-");
        return (ksName + ".jks" );
    }

    private String getTenantDomainName() throws KeyStoreMgtException {
        RealmService realmService = RealmServiceHolder.getRealmService();
        if (realmService == null) {
            String msg = "Error in getting the domain name, realm service is null.";
            log.error(msg);
            throw new KeyStoreMgtException(msg);
        }
        try {
            return realmService.getTenantManager().getDomain(tenantId);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            String msg = "Error in getting the domain name for the tenant id: " + tenantId;
            log.error(msg, e);
            throw new KeyStoreMgtException(msg, e);
        }
View Full Code Here

        isLoggedIn = login(username, password, remoteAddress);
        if (isLoggedIn) {
            String key = UUIDGenerator.getUUID();
            try {
                RegistryService registryService = TokenAuthBEDataHolder.getInstance().getRegistryService();
                RealmService realmService = TokenAuthBEDataHolder.getInstance().getRealmService();
                String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
                int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
                UserRealm realm = registryService.getUserRealm(tenantId);
                int userId = realm.getUserStoreManager().getUserId(username);

                String baseString = "TenantId:=" + tenantId + "&UserId:=" + userId;
                String signature = getHMAC(key,baseString);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.core.service.RealmService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.