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

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


                        "Data");
                return false;
            }

            RegistryService registryService = WebSealAuthBEDataHolder.getInstance().getRegistryService();
            RealmService realmService = WebSealAuthBEDataHolder.getInstance().getRealmService();

            String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
            username = UserCoreUtil.getTenantLessUsername(username);

            UserRealm realm = AnonymousSessionUtil.getRealmByTenantDomain(registryService,
                    realmService, tenantDomain);

            boolean isAuthenticated = realm.getUserStoreManager().authenticate(username, password);

            if (!isAuthenticated) {
                CarbonAuthenticationUtil.onFailedAdminLogin(httpSess, username, -1, remoteAddress,
                        "Data");
                return false;
            }

            // If we are to trust the user who delegates identity - he should be
            // in a role having
            // delegate-identity permission.
            boolean isDelegateToAuthorized = realm.getAuthorizationManager().isUserAuthorized(
                    username, "System", "delegate-identity");

            // authenticatedUser user should have the permission to login to the
            // system.
            boolean isLoginToAuthorized = realm.getAuthorizationManager().isUserAuthorized(
                    authenticatedUser, "System", "login");
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            if (isDelegateToAuthorized && isLoginToAuthorized) {
                CarbonAuthenticationUtil.onSuccessAdminLogin(httpSess, username, tenantId,
                        tenantDomain, remoteAddress);
                log.info("Identity delegation by " + username + " on behalf of "
                        + authenticatedUser + " from IP address " + remoteAddress);
View Full Code Here


                        "Data");
                return false;
            }

            RegistryService registryService = SSOAuthBEDataHolder.getInstance().getRegistryService();
            RealmService realmService = SSOAuthBEDataHolder.getInstance().getRealmService();

            String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
            username = UserCoreUtil.getTenantLessUsername(username);

            UserRealm realm = AnonymousSessionUtil.getRealmByTenantDomain(registryService,
                    realmService, tenantDomain);

            boolean isAuthenticated = false;
            AxisConfiguration axisConfig =
                    CarbonConfigurationContextFactory.getConfigurationContext().getAxisConfiguration();

            if (axisConfig.getParameter(SSOConstants.SSO_SERVICE_EPR) != null) {
                String epr = (String) axisConfig.getParameter(SSOConstants.SSO_SERVICE_EPR)
                        .getValue();
                // TODO: the tenantId login should be modified..
                isAuthenticated = new SSOConsumer(epr).isAuthenticated(username, password);
            }

            boolean isAuthorized = realm.getAuthorizationManager().isUserAuthorized(username,
                    "/permission/admin/login", CarbonConstants.UI_PERMISSION_ACTION);
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            if (isAuthenticated && isAuthorized) {
                CarbonAuthenticationUtil.onSuccessAdminLogin(httpSess, username, tenantId,
                        tenantDomain, remoteAddress);
                return true;
            } else {
View Full Code Here

                // tenantId without knowing the username.
                return false;
            }

            RegistryService registryService = SAML2SSOAuthBEDataHolder.getInstance().getRegistryService();
            RealmService realmService = SAML2SSOAuthBEDataHolder.getInstance().getRealmService();
            String tenantDomain = UserCoreUtil.getTenantDomain(realmService, username);
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            handleAuthenticationStarted(tenantId);
            boolean isSignatureValid = validateSignature(response, tenantDomain);
            if(!isSignatureValid){
                CarbonAuthenticationUtil.onFailedAdminLogin(httpSession, username, tenantId,
                        "SAML2 SSO Authentication", "Invalid Signature");
View Full Code Here

    public static X509CredentialImpl getX509CredentialImplForTenant(String domainName)
            throws SAML2SSOAuthenticatorException {

        int tenantID = 0;
        RegistryService registryService = SAML2SSOAuthBEDataHolder.getInstance().getRegistryService();
        RealmService realmService = SAML2SSOAuthBEDataHolder.getInstance().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 SAML2SSOAuthenticatorException(errorMsg, e);
            }
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

            log.error("username or password is seen as null/empty values.");
            return Response.status(Response.Status.UNAUTHORIZED).header("WWW-Authenticate", "Basic").
                    type(MediaType.APPLICATION_JSON).entity(Utils.buildMessage("Username/Password cannot be null")).build();
        }
        try {
            RealmService realmService = ServiceHolder.getRealmService();
            RegistryService registryService = ServiceHolder.getRegistryService();
            String tenantDomain = MultitenantUtils.getTenantDomain(username);
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);

            UserRealm userRealm = AnonymousSessionUtil.getRealmByTenantDomain(registryService, realmService, tenantDomain);
            if (userRealm == null) {
                log .error("Invalid domain or unactivated tenant login");
                // is this the correct HTTP code for this scenario ? (401)
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

     *
     * @param tenant - the tenant
     * @throws Exception - UserStoreException
     */
    private void updateTenantAdminPassword(Tenant tenant) 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);
        }
        try {
View Full Code Here

public class ServiceHolder {
    private static Log log = LogFactory.getLog(ServiceHolder.class);

    public static TenantManager getTenantManager() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService.getTenantManager();
    }
View Full Code Here

        return tenantBillingService;
    }

    public static RealmService getRealmService(){
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        RealmService realmService = (RealmService)carbonContext.getOSGiService(RealmService.class);
        return realmService;
    }
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.