Search in sources :

Example 16 with Claim

use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project core-util by WSO2Telco.

the class UserClaimProsser method getClaimValue.

private void getClaimValue(Claim[] claims, ClaimName claimName) {
    for (int i = 0; i < claims.length; i++) {
        Claim claim = claims[i];
        if (claim.getClaimUri().equalsIgnoreCase(claimName.getClaimURL())) {
            String claimValue = claim.getValue();
            userClaimDetails.put(claimName, claimValue);
        }
    }
}
Also used : Claim(org.wso2.carbon.user.core.claim.Claim)

Example 17 with Claim

use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-business-process by wso2.

the class BPSUserIdentityManager method transformQueryToClaim.

private List<Claim> transformQueryToClaim(UserQueryImpl userQuery) {
    List<Claim> claimList = new ArrayList<Claim>();
    if (userQuery.getEmail() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(EMAIL_CLAIM_URI);
        claim.setValue(userQuery.getEmail());
        claimList.add(claim);
    }
    if (userQuery.getEmailLike() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(EMAIL_CLAIM_URI);
        claim.setValue("*" + userQuery.getEmailLike() + "*");
        claimList.add(claim);
    }
    if (userQuery.getFirstName() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(FIRST_NAME_CLAIM_URI);
        claim.setValue(userQuery.getFirstName());
        claimList.add(claim);
    }
    if (userQuery.getFirstNameLike() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(FIRST_NAME_CLAIM_URI);
        claim.setValue("*" + userQuery.getFirstNameLike() + "*");
        claimList.add(claim);
    }
    if (userQuery.getFullNameLike() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(FULL_NAME_CLAIM_URI);
        claim.setValue("*" + userQuery.getFullNameLike() + "*");
        claimList.add(claim);
    }
    if (userQuery.getGroupId() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(ROLE_CLAIM_URI);
        claim.setValue(userQuery.getGroupId());
        claimList.add(claim);
    }
    if (userQuery.getId() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(ID_CLAIM_URI);
        claim.setValue(userQuery.getId());
        claimList.add(claim);
    }
    if (userQuery.getLastName() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(LAST_NAME_CLAIM_URI);
        claim.setValue(userQuery.getLastName());
        claimList.add(claim);
    }
    if (userQuery.getLastNameLike() != null) {
        Claim claim = new Claim();
        claim.setClaimUri(LAST_NAME_CLAIM_URI);
        claim.setValue("*" + userQuery.getLastNameLike() + "*");
        claimList.add(claim);
    }
    return claimList;
}
Also used : ArrayList(java.util.ArrayList) Claim(org.wso2.carbon.user.core.claim.Claim)

Example 18 with Claim

use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-business-process by wso2.

the class TaskOperationsImpl method claim.

/**
 * Claim responsibility for a task, i.e. set the task to status Reserved
 * @param taskIdURI : task identifier
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public void claim(final URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                HumanTaskCommand claim = new Claim(getCaller(), taskId);
                claim.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : HumanTaskCommand(org.wso2.carbon.humantask.core.engine.HumanTaskCommand) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) RecipientNotAllowedException(org.wso2.carbon.humantask.client.api.RecipientNotAllowedException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) Claim(org.wso2.carbon.humantask.core.engine.commands.Claim)

Example 19 with Claim

use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-business-process by wso2.

the class UserSubstitutionUtils method handleScheduledEventByTenant.

public static synchronized boolean handleScheduledEventByTenant(int tenantId) {
    boolean result = true;
    TransitivityResolver resolver = SubstitutionDataHolder.getInstance().getTransitivityResolver();
    ActivitiDAO activitiDAO = SubstitutionDataHolder.getInstance().getActivitiDAO();
    if (SubstitutionDataHolder.getInstance().isTransitivityEnabled()) {
        // update transitives, only the map is updated here
        result = resolver.resolveTransitiveSubs(true, tenantId);
    } else {
        resolver.subsMap = activitiDAO.selectActiveSubstitutesByTenant(tenantId, new Date(System.currentTimeMillis()));
    }
    // flush into db
    for (Map.Entry<String, SubstitutesDataModel> entry : resolver.subsMap.entrySet()) {
        // go through the updated map
        SubstitutesDataModel model = entry.getValue();
        try {
            // set carbon context
            PrivilegedCarbonContext.startTenantFlow();
            PrivilegedCarbonContext context = PrivilegedCarbonContext.getThreadLocalCarbonContext();
            context.setUsername(model.getUser());
            context.setTenantId(tenantId, true);
            if (SubstitutionDataHolder.getInstance().isTransitivityEnabled()) {
                activitiDAO.updateSubstituteInfo(model);
            }
            if (!BPMNConstants.BULK_REASSIGN_PROCESSED.equals(model.getTaskList())) {
                // active substitution, not yet bulk reassigned
                String sub = getActualSubstitute(model);
                if (model.getTaskList() == null) {
                    // reassign all
                    if (sub != null) {
                        bulkReassign(model.getUser(), sub, null);
                    } else {
                        // transitivity undefined, assign to task owner or un-claim
                        assignToTaskOwner(model.getUser(), null);
                    }
                } else {
                    List<String> taskList = getTaskListFromString(model.getTaskList());
                    if (sub != null) {
                        bulkReassign(model.getUser(), sub, taskList);
                    } else {
                        // transitivity undefined, assign to task owner or un-claim
                        assignToTaskOwner(model.getUser(), taskList);
                    }
                }
                model.setTaskList(BPMNConstants.BULK_REASSIGN_PROCESSED);
                activitiDAO.updateSubstituteInfo(model);
            }
        } finally {
            PrivilegedCarbonContext.endTenantFlow();
            PrivilegedCarbonContext.destroyCurrentContext();
        }
    }
    // disable expired records
    disableExpiredRecords(tenantId);
    return result;
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel) SubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel) ActivitiDAO(org.wso2.carbon.bpmn.core.mgt.dao.ActivitiDAO) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext)

Example 20 with Claim

use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project product-microgateway by wso2.

the class MGWJWTGeneratorInvoker method getRetrievedClaims.

public static BMap<String, Object> getRetrievedClaims(BMap<String, Object> authContext) {
    try {
        List<ClaimDTO> claimList = abstractMGWClaimRetriever.retrieveClaims(convertBMapToMap(authContext));
        if (claimList == null) {
            return null;
        }
        BPackage packageId = new BPackage("wso2", "gateway", "3.2.1");
        BMap<String, Object> bMap = BValueCreator.createRecordValue(packageId, "RetrievedUserClaimsListDTO");
        bMap.put("count", claimList.size());
        BArray bArray = (BArray) bMap.get("list");
        for (Object claimDTO : claimList) {
            bArray.append(BValueCreator.createRecordValue(packageId, "ClaimDTO", (Map<String, Object>) claimDTO));
        }
        return bMap;
    // Not to break the flow if an exception occured during claim retrieval
    } catch (Exception e) {
        log.error("Error while retrieving user claims from remote url.", e);
        return null;
    }
}
Also used : ClaimDTO(org.wso2.micro.gateway.jwt.generator.ClaimDTO) HashMap(java.util.HashMap) Map(java.util.Map) BMap(org.ballerinalang.jvm.values.api.BMap) BArray(org.ballerinalang.jvm.values.api.BArray) InvocationTargetException(java.lang.reflect.InvocationTargetException) BPackage(org.ballerinalang.jvm.types.BPackage)

Aggregations

HashMap (java.util.HashMap)112 ArrayList (java.util.ArrayList)89 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)66 UserStoreException (org.wso2.carbon.user.api.UserStoreException)65 Test (org.testng.annotations.Test)63 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)55 Map (java.util.Map)49 PreparedStatement (java.sql.PreparedStatement)48 SQLException (java.sql.SQLException)43 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)34 RealmService (org.wso2.carbon.user.core.service.RealmService)30 UserRealm (org.wso2.carbon.user.core.UserRealm)29 Claim (org.wso2.carbon.user.api.Claim)28 UserStoreException (org.wso2.carbon.user.core.UserStoreException)28 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)28 ResultSet (java.sql.ResultSet)27 Connection (java.sql.Connection)25 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)25 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)24 Claim (org.wso2.carbon.identity.application.common.model.Claim)24