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

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


            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

            String tenantDomain = UserCoreUtil.getTenantDomain(OAuthServiceComponent
                    .getRealmService(), oauthConsumer.getOauthConsumerKey());
            RegistryService registryService = OAuthServiceComponent.getRegistryService();
            String username = UserCoreUtil.getTenantLessUsername(oauthConsumer
                    .getOauthConsumerKey());
            RealmService realmService = OAuthServiceComponent.getRealmService();
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            UserRealm realm = registryService.getUserRealm(tenantId);
            int userId = realm.getUserStoreManager().getUserId(username);

            String baseString = "TenantId:=" + tenantId + "&UserId:=" + userId;
            Registry registry = registryService.getConfigSystemRegistry(tenantId);
View Full Code Here

    public static int getTenantID(String tenantDomain) throws BAMException {

        int tenantID = CarbonConstants.SUPER_TENANT_ID;
        if (tenantDomain != null) {
            RealmService realmService = BAMUtil.getRealmService();
            try {
                tenantID = realmService.getTenantManager().getTenantId(tenantDomain);
            } catch (org.wso2.carbon.user.api.UserStoreException e) {
                throw new BAMException("Can not tenant manager");
            }
        }
        return tenantID;
View Full Code Here

                .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);

        HttpSession httpSession = request.getSession(false);
        String userName = DBUtils.getUsername(msgContext);
       
        RealmService realmService = DataServicesDSComponent.getRealmService();
        RegistryService registryService = DataServicesDSComponent.getRegistryService();

        /* if session does not exist, return empty array of roles */
        if (httpSession == null) {
          return new String[0];
        }

        /* first return the tenant id from the tenant domain */
        SuperTenantCarbonContext carbonContext = SuperTenantCarbonContext.getCurrentContext(httpSession);
    String tenantDomain = carbonContext.getTenantDomain();
        int tenantId = carbonContext.getTenantId();
        if (tenantId < 0) {
            tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
        }
        if (tenantId < 0) {
            /* the tenant doesn't exist. */
            log.error("The tenant doesn't exist. Tenant domain:" + tenantDomain);
            throw new DataServiceFault("Access Denied. You are not authorized.");
        }
        if (!realmService.getTenantManager().isTenantActive(tenantId)) {
            /* the tenant is not active. */
            log.error("The tenant is not active. Tenant domain:" + tenantDomain);
            throw new DataServiceFault("The tenant is not active. Tenant domain:" + tenantDomain);
        }
        UserRealm realm;
View Full Code Here

            }
        }
    }
   
    private void doEventRealmInitiliased() {
      RealmService realmService = DataServicesDSComponent.getRealmService();
      try {
            SuperTenantCarbonContext.getCurrentContext().setUserRealm(realmService.getBootstrapRealm());
            SuperTenantCarbonContext.getCurrentContext().setUsername(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
      } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
      this.notifyEventServiceListeners();
View Full Code Here

      throws DeploymentException {
    /* set the thread local variable to hold the tenant id */
    try {
            int tenantId = SuperTenantCarbonContext.getCurrentContext(this.configCtx).getTenantId();
            SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
            RealmService realmService = DataServicesDSComponent.getRealmService();
            if (realmService != null) {
                try {
          SuperTenantCarbonContext.getCurrentContext().setUserRealm(realmService.getBootstrapRealm());
        } catch (UserStoreException e) {
          throw new DeploymentException(e);
        }
            }
            SuperTenantCarbonContext.getCurrentContext().setUsername(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
View Full Code Here

    public static X509CredentialImpl getX509CredentialImplForTenant(String domainName, String alias)
            throws IdentitySAML2SSOException {

        int tenantID = 0;
        RegistryService registryService = SAMLSSOUtil.getRegistryService();
        RealmService realmService = SAMLSSOUtil.getRealmService();

        // get the tenantID
        if (domainName != null) {
            try {
                tenantID = realmService.getTenantManager().getTenantId(domainName);
            } catch (org.wso2.carbon.user.api.UserStoreException e) {
                String errorMsg = "Error getting the TenantID for the domain name";
                log.error(errorMsg, e);
                throw new IdentitySAML2SSOException(errorMsg, e);
            }
View Full Code Here

     *
     * @return tenant manager.
     */
    private TenantManager getTenantManager() {
        try {
            RealmService realmService = dataHolder.getRealmService();
            if (realmService != null) {
                return realmService.getTenantManager();
            }
        } catch (Exception ignored) {
            // We don't mind any exception occurring here. Our intention is provide a tenant manager
            // here. It is perfectly valid to not have a tenant manager in some situations.
        }
View Full Code Here

            HttpService httpService = dataHolder.getHttpService();
            HttpContext defaultHttpContext = httpService.createDefaultHttpContext();

            registerCarbonServlet(httpService, defaultHttpContext);

            RealmService realmService = dataHolder.getRealmService();
            UserRealm teannt0Realm = realmService.getBootstrapRealm();
            CarbonJMXAuthenticator.setUserRealm(teannt0Realm);

            log.info("Repository       : " + axis2RepoLocation);

            //Registering the configuration contexts as an OSGi service.
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.