Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.oauth.action.constant;

/**
* Constants related to Pre Issue Access Token Action.
*/
public class PreIssueAccessTokenActionConstants {

public static final String ACTION_VERSION_V1 = "v1";

private PreIssueAccessTokenActionConstants() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.oauth.action.execution;

import org.wso2.carbon.identity.action.execution.api.exception.ActionExecutionException;
import org.wso2.carbon.identity.action.execution.api.model.ActionExecutionRequestContext;
import org.wso2.carbon.identity.action.execution.api.model.ActionType;
import org.wso2.carbon.identity.action.execution.api.model.FlowContext;
import org.wso2.carbon.identity.action.execution.api.service.impl.DefaultActionVersioningHandler;
import org.wso2.carbon.identity.action.management.api.model.Action;
import org.wso2.carbon.identity.oauth.action.versioning.ActionTriggerEvaluatorFactory;
import org.wso2.carbon.identity.oauth.action.versioning.ActionTriggerEvaluatorForVersion;

/**
* Implementation of the Version handler for pre issue access token action.
*/
public class PreIssueAccessTokenActionVersioningHandler extends DefaultActionVersioningHandler {

ActionTriggerEvaluatorFactory factory = ActionTriggerEvaluatorFactory.getInstance();

@Override
public ActionType getSupportedActionType() {

return ActionType.PRE_ISSUE_ACCESS_TOKEN;
}

@Override
public boolean canExecute(ActionExecutionRequestContext actionExecutionRequestContext, FlowContext flowContext)
throws ActionExecutionException {

Action action = actionExecutionRequestContext.getAction();
ActionTriggerEvaluatorForVersion versionTriggerEvaluator = factory.getVersionTriggerEvaluator(action);

if (!versionTriggerEvaluator.isTriggerableForTokenExchangeGrant(
actionExecutionRequestContext.getActionType(), action, flowContext)) {
return false;
}

return true;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public enum ClaimNames {
CLIENT_ID("client_id"),
AUTHORIZED_USER_TYPE("aut"),
EXPIRES_IN("expires_in"),
ACT("act"),

TOKEN_BINDING_REF("binding_ref"),
TOKEN_BINDING_TYPE("binding_type"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.oauth.action.versioning;

import org.wso2.carbon.identity.action.execution.api.exception.ActionExecutionException;
import org.wso2.carbon.identity.action.management.api.model.Action;
import org.wso2.carbon.identity.oauth.action.constant.PreIssueAccessTokenActionConstants;

/**
* Factory class for getting the ActionVersioningHandler by Action version.
*/
public class ActionTriggerEvaluatorFactory {

private static final ActionTriggerEvaluatorFactory instance = new ActionTriggerEvaluatorFactory();

public static ActionTriggerEvaluatorFactory getInstance() {

return instance;
}

public ActionTriggerEvaluatorForVersion getVersionTriggerEvaluator(Action action)
throws ActionExecutionException {

switch (action.getActionVersion()) {
case PreIssueAccessTokenActionConstants.ACTION_VERSION_V1:
return ActionTriggerEvaluatorForVersion.getInstance();
default:
throw new ActionExecutionException("Unsupported action version: " + action.getActionVersion());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.oauth.action.versioning;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.action.execution.api.exception.ActionExecutionException;
import org.wso2.carbon.identity.action.execution.api.model.ActionType;
import org.wso2.carbon.identity.action.execution.api.model.FlowContext;
import org.wso2.carbon.identity.action.management.api.model.Action;
import org.wso2.carbon.identity.oauth.common.OAuthConstants;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;

/**
* Default implementation of the ActionVersioningHandler for PRE_ISSUE_ACCESS_TOKEN (V1 behavior).
* This class determines whether the action can be triggered based on the flow context for the action version.
*/
public class ActionTriggerEvaluatorForVersion {

private static final ActionTriggerEvaluatorForVersion instance = new ActionTriggerEvaluatorForVersion();

private static final Log LOG = LogFactory.getLog(ActionTriggerEvaluatorForVersion.class);

public static ActionTriggerEvaluatorForVersion getInstance() {

return instance;
}

/**
* Evaluate whether action can be triggered based on flow context for the given action version.
*
* @param actionType Action type.
* @param action Action.
* @param flowContext Flow context.
* @return True if action can be triggered based on the flow context.
*/
public boolean isTriggerableForTokenExchangeGrant(ActionType actionType, Action action, FlowContext flowContext)
throws ActionExecutionException {

OAuthTokenReqMessageContext tokenMessageContext =
flowContext.getValue("tokenMessageContext", OAuthTokenReqMessageContext.class);
if (OAuthConstants.GrantTypes.TOKEN_EXCHANGE.equals(
tokenMessageContext.getOauth2AccessTokenReqDTO().getGrantType())) {
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024-2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.oauth.action.versioning;

import org.wso2.carbon.identity.action.execution.api.exception.ActionExecutionRequestBuilderException;
import org.wso2.carbon.identity.action.execution.api.service.ActionExecutionRequestBuilder;
import org.wso2.carbon.identity.oauth.action.constant.PreIssueAccessTokenActionConstants;
import org.wso2.carbon.identity.oauth.action.versioning.v1.PreIssueAccessTokenRequestBuilderV1;

/**
* Factory class for getting the PreIssueAccessRequestBuilder by Action version.
*/
public class PreIssueAccessTokenRequestBuilderFactory {

private static final PreIssueAccessTokenRequestBuilderFactory instance =
new PreIssueAccessTokenRequestBuilderFactory();

public static PreIssueAccessTokenRequestBuilderFactory getInstance() {

return instance;
}

public ActionExecutionRequestBuilder getActionExecutionRequestBuilder(String actionVersion)
throws ActionExecutionRequestBuilderException {

switch (actionVersion) {
case PreIssueAccessTokenActionConstants.ACTION_VERSION_V1:
return new PreIssueAccessTokenRequestBuilderV1();
default:
throw new ActionExecutionRequestBuilderException(
"Unsupported pre-issue-access token action version: " + actionVersion);
}
}
}
Loading
Loading