当前位置: 首页>>代码示例>>Java>>正文


Java CarbonContext类代码示例

本文整理汇总了Java中org.wso2.carbon.context.CarbonContext的典型用法代码示例。如果您正苦于以下问题:Java CarbonContext类的具体用法?Java CarbonContext怎么用?Java CarbonContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CarbonContext类属于org.wso2.carbon.context包,在下文中一共展示了CarbonContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAppRole

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Create a internal role in workflow domain with same name as workflow.
 *
 * @param workflowName Workflow name
 * @throws WorkflowException
 */
public static void createAppRole(String workflowName) throws WorkflowException {
    String roleName = createWorkflowRoleName(workflowName);
    String qualifiedUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
    String[] user = {qualifiedUsername};

    try {
        if (log.isDebugEnabled()) {
            log.debug("Creating workflow role : " + roleName + " and assign the user : "
                    + Arrays.toString(user) + " to that role");
        }
        CarbonContext.getThreadLocalCarbonContext().getUserRealm().getUserStoreManager()
                .addRole(roleName, user, null);
    } catch (UserStoreException e) {
        throw new WorkflowException("Error while creating role", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:WorkflowManagementUtil.java

示例2: findDescendantResources

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
    Set<String> resourceSet = new HashSet<String>();
    registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
            getThreadLocalCarbonContext().getTenantId());
    if (registry.resourceExists(parentResourceId)) {
        Resource resource = registry.get(parentResourceId);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] resources = collection.getChildren();
            for (String res : resources) {
                resourceSet.add(res);
                getChildResources(res, resourceSet);
            }
        } else {
            return null;
        }
    }
    return resourceSet;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultResourceFinder.java

示例3: listAllAssociations

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * List all associations
 *
 * @return
 * @throws WorkflowException
 */
public Association[] listAllAssociations() throws WorkflowException {

    List<Association> associations;
    try {
        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        associations = WorkflowServiceDataHolder.getInstance().getWorkflowService().listAllAssociations(tenantId);
    } catch (InternalWorkflowException e) {
        log.error("Server error when listing all associations", e);
        throw new WorkflowException("Server error when listing associations");
    }
    if (CollectionUtils.isEmpty(associations)) {
        return new Association[0];
    }
    return associations.toArray(new Association[associations.size()]);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:WorkflowManagementAdminService.java

示例4: publishPolicy

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * publish policy
 *
 * @param policyIds        policy ids to publish,
 * @param version
 * @param action
 * @param enabled
 * @param order
 * @param subscriberIds    subscriber ids to publish,
 * @param verificationCode verificationCode as String
 * @throws EntitlementException throws if can not be created PolicyPublishExecutor instant
 */
public void publishPolicy(String[] policyIds, String version, String action, boolean enabled, int order,
                          String[] subscriberIds, String verificationCode) throws EntitlementException {

    boolean toPDP = false;

    if (subscriberIds == null) {
        toPDP = true;
    }

    PolicyPublishExecutor executor = new PolicyPublishExecutor(policyIds, version, action, enabled, order,
            subscriberIds, this, toPDP, verificationCode);
    executor.setTenantDomain(CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
    executor.setTenantId(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    executor.setUserName(CarbonContext.getThreadLocalCarbonContext().getUsername());

    threadPool.execute(executor);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:PolicyPublisher.java

示例5: persistVerificationCode

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Helper method
 *
 * @param verificationCode verificationCode as String
 * @param subscriberIds    Array of subscriberIds
 */
private void persistVerificationCode(String verificationCode, String[] subscriberIds) {

    Registry registry = EntitlementServiceComponent.
            getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    try {
        org.wso2.carbon.registry.api.Resource resource = registry.newResource();
        resource.setProperty("subscriberIds", Arrays.asList(subscriberIds));
        resource.setProperty("policyIds", Arrays.asList(policyIds));
        resource.setProperty("action", action);
        resource.setProperty("version", version);
        resource.setProperty("order", Integer.toString(order));
        registry.put(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode,
                resource);
    } catch (org.wso2.carbon.registry.api.RegistryException e) {
        log.error("Error while persisting verification code", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:PolicyPublishExecutor.java

示例6: getAllLocalClaimUris

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * @return
 * @throws IdentityProviderManagementException
 */
public String[] getAllLocalClaimUris() throws IdentityProviderManagementException {

    try {
        String claimDialect = LOCAL_DEFAULT_CLAIM_DIALECT;
        ClaimMapping[] claimMappings = CarbonContext.getThreadLocalCarbonContext()
                .getUserRealm().getClaimManager().getAllClaimMappings(claimDialect);
        List<String> claimUris = new ArrayList<String>();
        for (ClaimMapping claimMap : claimMappings) {
            claimUris.add(claimMap.getClaim().getClaimUri());
        }
        String[] allLocalClaimUris = claimUris.toArray(new String[claimUris.size()]);
        if (ArrayUtils.isNotEmpty(allLocalClaimUris)) {
            Arrays.sort(allLocalClaimUris);
        }
        return allLocalClaimUris;
    } catch (UserStoreException e) {
        String message = "Error while reading system claims";
        log.error(message, e);
        throw new IdentityProviderManagementException(message, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:IdentityProviderManagementService.java

示例7: updateWorkflowRoleName

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Update name of workflow role
 *
 * @param oldWorkflowName Previous role name
 * @param newWorkflowName New role name
 * @throws WorkflowException
 */
public static void updateWorkflowRoleName(String oldWorkflowName, String newWorkflowName) throws
        WorkflowException {
    String oldRoleName = createWorkflowRoleName(oldWorkflowName);
    String newRoleName = createWorkflowRoleName(newWorkflowName);
    try {
        if (log.isDebugEnabled()) {
            log.debug("Updating workflow role : " + oldRoleName);
        }
        CarbonContext.getThreadLocalCarbonContext().getUserRealm().getUserStoreManager()
                .updateRoleName(oldRoleName, newRoleName);
    } catch (UserStoreException e) {
        throw new WorkflowException("Error while updating workflow role name.", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:WorkflowManagementUtil.java

示例8: clear

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Remove everything in the cache.
 */
public void clear() {
    Cache<K, V> cache = getEntitlementCache();
    if (cache != null) {
        try {
            cache.removeAll();
            if (log.isDebugEnabled()) {
                String tenantDomain = CarbonContext
                        .getThreadLocalCarbonContext().getTenantDomain();
                log.debug("Cache : " + Entitlement_CACHE_NAME + " is cleared " + "in tenant domain : " +
                          tenantDomain);
            }
        } catch (Exception e) {
            //TODO - Handle the IdentityCacheKey exception in cluster env.
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:EntitlementBaseCache.java

示例9: terminatingConfigurationContext

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
public void terminatingConfigurationContext(ConfigurationContext context) {
    try {
        org.wso2.carbon.user.api.UserRealm tenantRealm = CarbonContext
                .getThreadLocalCarbonContext().getUserRealm();
        RealmConfiguration realmConfig = tenantRealm.getRealmConfiguration();
        AbstractUserStoreManager userStoreManager = (AbstractUserStoreManager) tenantRealm
                .getUserStoreManager();
        userStoreManager.clearAllSecondaryUserStores();
        realmConfig.setSecondaryRealmConfig(null);
        userStoreManager.setSecondaryUserStoreManager(null);
        log.info("Unloaded all secondary user stores for tenant "
                + CarbonContext.getThreadLocalCarbonContext().getTenantId());
    } catch (Exception ex) {
        log.error(ex.getMessage());
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:UserStoreConfgurationContextObserver.java

示例10: isAdminProfileSpoof

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Checks whether the given user name is admin user name and the currently logged in user also admin.
 * Only admin user is allowed for admin user profile related operations.
 *
 * @param username Username to be checked.
 * @return True only if admin user.
 * @throws UserStoreException Error occurred while retrieving realm configuration.
 */
private boolean isAdminProfileSpoof(String username) throws UserStoreException {

    if (StringUtils.isEmpty(username)) {
        return false;
    }

    RealmConfiguration realmConfiguration = getUserRealm().getRealmConfiguration();
    String adminUsername = IdentityUtil.addDomainToName(realmConfiguration.getAdminUserName(),
            IdentityUtil.getPrimaryDomainName());
    String targetUsername = IdentityUtil.addDomainToName(username, IdentityUtil.getPrimaryDomainName());

    // If the given user name is not the admin username, simply we can allow and return false. Our intention is to
    // check whether a non admin user is trying to do operations on an admin profile.
    if (!StringUtils.equalsIgnoreCase(targetUsername, adminUsername)) {
        return false;
    }

    String loggedInUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (loggedInUsername != null) {
        loggedInUsername = IdentityUtil.addDomainToName(loggedInUsername, IdentityUtil.getPrimaryDomainName());
    }

    // If the currently logged in user is also the admin user this isn't a spoof attempt. Hence returning false.
    return !StringUtils.equalsIgnoreCase(loggedInUsername, adminUsername);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:UserProfileAdmin.java

示例11: getClaimDialects

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
@SuppressWarnings("unused")
public ClaimDialectDTO[] getClaimDialects() throws ClaimMetadataException {

    try {
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();

        List<ClaimDialect> claimDialectList = IdentityClaimManagementServiceDataHolder.getInstance()
                .getClaimManagementService().getClaimDialects(tenantDomain);

        ClaimDialect[] claimDialects = claimDialectList.toArray(new ClaimDialect[0]);
        return ClaimMetadataUtils.convertClaimDialectsToClaimDialectDTOs(claimDialects);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:ClaimMetadataManagementAdminService.java

示例12: renameClaimDialect

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
@SuppressWarnings("unused")
public void renameClaimDialect(ClaimDialectDTO oldClaimDialect, ClaimDialectDTO newClaimDialect) throws
        ClaimMetadataException {

    try {
        ClaimDialect oldDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(oldClaimDialect);
        ClaimDialect newDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(newClaimDialect);
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();

        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService()
                .renameClaimDialect(oldDialect, newDialect, tenantDomain);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:ClaimMetadataManagementAdminService.java

示例13: getLocalClaims

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
@SuppressWarnings("unused")
public LocalClaimDTO[] getLocalClaims() throws ClaimMetadataException {

    try {
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();

        List<LocalClaim> localClaimList = IdentityClaimManagementServiceDataHolder.getInstance()
                .getClaimManagementService().getLocalClaims(tenantDomain);


        LocalClaim[] localClaims = localClaimList.toArray(new LocalClaim[0]);
        return ClaimMetadataUtils.convertLocalClaimsToLocalClaimDTOs(localClaims);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:ClaimMetadataManagementAdminService.java

示例14: getExternalClaims

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
@SuppressWarnings("unused")
public ExternalClaimDTO[] getExternalClaims(String externalClaimDialectURI) throws ClaimMetadataException {

    try {
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();

        List<ExternalClaim> externalClaimList = IdentityClaimManagementServiceDataHolder.getInstance()
                .getClaimManagementService().getExternalClaims(externalClaimDialectURI, tenantDomain);


        ExternalClaim[] externalClaims = externalClaimList.toArray(new ExternalClaim[0]);
        return ClaimMetadataUtils.convertExternalClaimsToExternalClaimDTOs(externalClaims);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:ClaimMetadataManagementAdminService.java

示例15: addIdP

import org.wso2.carbon.context.CarbonContext; //导入依赖的package包/类
/**
 * Adds an Identity Provider to the logged-in tenant
 *
 * @param identityProvider <code>IdentityProvider</code> new Identity Provider information
 * @throws IdentityProviderManagementException Error when adding Identity Provider
 */
public void addIdP(IdentityProvider identityProvider) throws IdentityProviderManagementException {
    // The following check is applicable only for the IdPs added from UI/Service call and should not be
    // applicable for IdPs added from file. hence the check is moved from listener to the service
    if (identityProvider != null && identityProvider.getIdentityProviderName() != null &&
            identityProvider.getIdentityProviderName().startsWith(IdPManagementConstants.SHARED_IDP_PREFIX)) {
        throw new IdentityProviderManagementException("Identity provider name cannot have " +
                IdPManagementConstants.SHARED_IDP_PREFIX + " as prefix.");
    }
    String tenantDomain = "";
    try {
        tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
        IdentityProviderManager.getInstance().addIdP(identityProvider, tenantDomain);
    } catch (IdentityProviderManagementException idpException) {
        log.error("Error while adding Identity provider in tenantDomain : " + tenantDomain, idpException);
        throw idpException;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:IdentityProviderManagementService.java


注:本文中的org.wso2.carbon.context.CarbonContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。