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;
}
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;
}
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");
}
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;
}
Aggregations