Search in sources :

Example 1 with JWTClaimsConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromJWTClaimsConditionToDTO.

/**
 * Converts a JWT Claims Condition model object into a DTO
 *
 * @param condition JWT Claims Condition model object
 * @return DTO object that was derived from JWT Claims Condition model object
 */
public static JWTClaimsConditionDTO fromJWTClaimsConditionToDTO(JWTClaimsCondition condition) {
    JWTClaimsConditionDTO dto = new JWTClaimsConditionDTO();
    dto.setClaimUrl(condition.getClaimUrl());
    dto.setAttribute(condition.getAttribute());
    return dto;
}
Also used : JWTClaimsConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO)

Example 2 with JWTClaimsConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromJWTClaimsConditionToDTO.

/**
 * Converts a JWT Claims Condition model object into a DTO
 *
 * @param condition JWT Claims Condition model object
 * @return DTO object that was derived from JWT Claims Condition model object
 */
public static ThrottleConditionDTO fromJWTClaimsConditionToDTO(JWTClaimsCondition condition) {
    ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
    throttleConditionDTO.setType(PolicyConstants.JWT_CLAIMS_CONDITION_TYPE);
    throttleConditionDTO.setJwtClaimsCondition(new JWTClaimsConditionDTO());
    throttleConditionDTO = updateFieldsFromConditionToDTO(condition, throttleConditionDTO);
    throttleConditionDTO.getJwtClaimsCondition().setClaimUrl(condition.getClaimUrl());
    throttleConditionDTO.getJwtClaimsCondition().setAttribute(condition.getAttribute());
    return throttleConditionDTO;
}
Also used : JWTClaimsConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.JWTClaimsConditionDTO) ThrottleConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)

Example 3 with JWTClaimsConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtilTestCase method fromJWTConditionDtoToJWTConditionModelTest.

@Test(description = "Convert JWT Condition DTO to JWTCondition Model object")
public void fromJWTConditionDtoToJWTConditionModelTest() throws Exception {
    ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
    throttleConditionDTO.setType(PolicyConstants.JWT_CLAIMS_CONDITION_TYPE);
    JWTClaimsConditionDTO jwtClaimsConditionDTO = new JWTClaimsConditionDTO();
    jwtClaimsConditionDTO.setAttribute("testAttribute");
    jwtClaimsConditionDTO.setClaimUrl("http://wso2.org/claims");
    throttleConditionDTO.setJwtClaimsCondition(jwtClaimsConditionDTO);
    JWTClaimsCondition condition = (JWTClaimsCondition) CommonThrottleMappingUtil.fromDTOToCondition(throttleConditionDTO);
    Assert.assertNotNull(condition);
    assertEquals(condition.getAttribute(), "testAttribute");
    assertEquals(condition.getClaimUrl(), "http://wso2.org/claims");
}
Also used : JWTClaimsCondition(org.wso2.carbon.apimgt.core.models.policy.JWTClaimsCondition) Test(org.testng.annotations.Test)

Example 4 with JWTClaimsConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromDTOToJWTClaimsCondition.

/**
 * Converts a JWT Claims Condition DTO object into a model object
 *
 * @param dto             JWT Claims Condition DTO object
 * @param invertCondition Invert condition relevant to the DTO
 * @return JWT Claims Condition model object derived from JWT Claims Condition DTO
 */
public static JWTClaimsCondition fromDTOToJWTClaimsCondition(JWTClaimsConditionDTO dto, boolean invertCondition) {
    JWTClaimsCondition jwtClaimsCondition = new JWTClaimsCondition();
    jwtClaimsCondition.setConditionEnabled(Boolean.TRUE.toString());
    jwtClaimsCondition.setInvertCondition(invertCondition);
    jwtClaimsCondition.setAttribute(dto.getAttribute());
    jwtClaimsCondition.setClaimUrl(dto.getClaimUrl());
    return jwtClaimsCondition;
}
Also used : JWTClaimsCondition(org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)

Aggregations

Test (org.testng.annotations.Test)1 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)1 JWTClaimsCondition (org.wso2.carbon.apimgt.core.models.policy.JWTClaimsCondition)1 JWTClaimsConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.JWTClaimsConditionDTO)1 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)1 JWTClaimsConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.JWTClaimsConditionDTO)1