use of org.wso2.carbon.identity.workflow.mgt.bean.RequestParameter in project carbon-apimgt by wso2.
the class SystemScopesIssuer method getSignedJWT.
/**
* Method to parse the assertion and retrieve the signed JWT
*
* @param tokReqMsgCtx request
* @return SignedJWT object
* @throws IdentityOAuth2Exception exception thrown due to a parsing error
*/
private SignedJWT getSignedJWT(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
RequestParameter[] params = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters();
String assertion = null;
SignedJWT signedJWT;
for (RequestParameter param : params) {
if (param.getKey().equals(APIConstants.SystemScopeConstants.OAUTH_JWT_ASSERTION)) {
assertion = param.getValue()[0];
break;
}
}
if (StringUtils.isEmpty(assertion)) {
String errorMessage = "Error while retrieving assertion";
throw new IdentityOAuth2Exception(errorMessage);
}
try {
signedJWT = SignedJWT.parse(assertion);
if (log.isDebugEnabled()) {
log.debug(signedJWT);
}
} catch (ParseException e) {
String errorMessage = "Error while parsing the JWT.";
throw new IdentityOAuth2Exception(errorMessage, e);
}
return signedJWT;
}
use of org.wso2.carbon.identity.workflow.mgt.bean.RequestParameter in project carbon-identity-framework by wso2.
the class AbstractWorkflowRequestHandler method getParameter.
/**
* Wraps the parameters to the WorkflowParameter
*
* @param name Name of the parameter
* @param value Value of the parameter
* @param required Whether it is required to sent to the workflow executor
* @return
*/
protected RequestParameter getParameter(String name, Object value, boolean required) throws WorkflowRuntimeException {
RequestParameter parameter = new RequestParameter();
parameter.setName(name);
parameter.setValue(value);
parameter.setRequiredInWorkflow(required);
String valueType = getParamDefinitions().get(name);
if (valueType == null || value == null) {
// null value as param, or undefined param
parameter.setValueType(WorkflowDataType.OTHER_TYPE);
} else {
if (isValueValid(name, value, valueType)) {
parameter.setValueType(valueType);
} else {
throw new WorkflowRuntimeException("Invalid value for '" + name + "', Expected: '" + valueType + "', " + "but was of " + value.getClass().getName());
}
}
return parameter;
}
use of org.wso2.carbon.identity.workflow.mgt.bean.RequestParameter in project carbon-identity-framework by wso2.
the class WorkflowRequestBuilder method buildXMLRequest.
/**
* Create OM Element from workflow request parameters.
*
* @param workFlowRequest Workflow parameters
* @param initParams Non workflow parameters
* @return
* @throws WorkflowRuntimeException
*/
public static OMElement buildXMLRequest(WorkflowRequest workFlowRequest, Map<String, Object> initParams) throws WorkflowRuntimeException {
WorkflowRequestBuilder requestBuilder = new WorkflowRequestBuilder(workFlowRequest.getUuid(), workFlowRequest.getEventType());
for (RequestParameter parameter : workFlowRequest.getRequestParameters()) {
if (parameter.isRequiredInWorkflow()) {
switch(parameter.getValueType()) {
case WorkflowDataType.BOOLEAN_TYPE:
case WorkflowDataType.STRING_TYPE:
case WorkflowDataType.INTEGER_TYPE:
case WorkflowDataType.DOUBLE_TYPE:
requestBuilder.addSingleValuedParam(parameter.getName(), parameter.getValue());
break;
case WorkflowDataType.STRING_LIST_TYPE:
case WorkflowDataType.DOUBLE_LIST_TYPE:
case WorkflowDataType.INTEGER_LIST_TYPE:
case WorkflowDataType.BOOLEAN_LIST_TYPE:
requestBuilder.addListTypeParam(parameter.getName(), (List<Object>) parameter.getValue());
break;
case WorkflowDataType.STRING_STRING_MAP_TYPE:
requestBuilder.addMapTypeParam(parameter.getName(), (Map<String, Object>) parameter.getValue());
break;
}
}
}
requestBuilder.setInitParams(initParams);
return requestBuilder.buildRequest();
}
use of org.wso2.carbon.identity.workflow.mgt.bean.RequestParameter in project carbon-identity-framework by wso2.
the class AbstractWorkflowRequestHandler method startWorkFlow.
/**
* Start a new workflow.
*
* @param wfParams Parameters related to workflow
* @param nonWfParams Other parameters
* @param uuid Unique ID of request
* @return
* @throws WorkflowException
*/
public WorkflowExecutorResult startWorkFlow(Map<String, Object> wfParams, Map<String, Object> nonWfParams, String uuid) throws WorkflowException {
if (isWorkflowCompleted()) {
return new WorkflowExecutorResult(ExecutorResultState.COMPLETED);
}
if (!isAssociated()) {
return new WorkflowExecutorResult(ExecutorResultState.NO_ASSOCIATION);
}
WorkflowRequest workFlowRequest = new WorkflowRequest();
List<RequestParameter> parameters = new ArrayList<RequestParameter>(wfParams.size() + nonWfParams.size() + 1);
for (Map.Entry<String, Object> paramEntry : wfParams.entrySet()) {
parameters.add(getParameter(paramEntry.getKey(), paramEntry.getValue(), true));
}
for (Map.Entry<String, Object> paramEntry : nonWfParams.entrySet()) {
parameters.add(getParameter(paramEntry.getKey(), paramEntry.getValue(), false));
}
RequestParameter uuidParameter = new RequestParameter();
uuidParameter.setName(WFConstant.REQUEST_ID);
uuidParameter.setValue(uuid);
uuidParameter.setRequiredInWorkflow(true);
uuidParameter.setValueType(WorkflowDataType.STRING_TYPE);
parameters.add(uuidParameter);
workFlowRequest.setRequestParameters(parameters);
workFlowRequest.setTenantId(CarbonContext.getThreadLocalCarbonContext().getTenantId());
workFlowRequest.setUuid(uuid);
engageWorkflow(workFlowRequest);
WorkflowExecutorResult workflowExecutorResult = WorkFlowExecutorManager.getInstance().executeWorkflow(workFlowRequest);
if (workflowExecutorResult.getExecutorResultState() == ExecutorResultState.FAILED) {
throw new WorkflowException(workflowExecutorResult.getMessage());
}
return workflowExecutorResult;
}
use of org.wso2.carbon.identity.workflow.mgt.bean.RequestParameter in project identity-inbound-auth-oauth by wso2-extensions.
the class CibaGrantHandler method getAuthReqId.
/**
* Checks whether ciba authentication request identifier exists and .
*
* @param tokReqMsgCtx Authentication Request Identifier as JSON.
* @return String Authentication Request Identifier from the request.
* @throws IdentityOAuth2Exception Exception thrown regarding IdentityOAuth
*/
protected String getAuthReqId(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
// Initiating auth_req_id.
String authReqId = null;
RequestParameter[] parameters = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getRequestParameters();
// Obtaining auth_req_id from request.
for (RequestParameter parameter : parameters) {
if (AUTH_REQ_ID.equals(parameter.getKey())) {
if (parameter.getValue() != null && parameter.getValue().length > 0) {
authReqId = parameter.getValue()[0];
}
}
}
if (authReqId == null) {
if (log.isDebugEnabled()) {
log.debug("token request misses mandated parameter (auth_req_id).");
}
throw new IdentityOAuth2Exception(MISSING_AUTH_REQ_ID);
}
return authReqId;
}
Aggregations