Skip to content

Commit

Permalink
Add Authentication action type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Aug 20, 2024
1 parent 578f728 commit 1d08944
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionType;
import javax.validation.constraints.*;


Expand All @@ -33,40 +34,7 @@
public class ActionBasicResponse {

private String id;

@XmlType(name="TypeEnum")
@XmlEnum(String.class)
public enum TypeEnum {

@XmlEnumValue("PRE_ISSUE_ACCESS_TOKEN") PRE_ISSUE_ACCESS_TOKEN(String.valueOf("PRE_ISSUE_ACCESS_TOKEN")), @XmlEnumValue("PRE_UPDATE_PASSWORD") PRE_UPDATE_PASSWORD(String.valueOf("PRE_UPDATE_PASSWORD")), @XmlEnumValue("PRE_UPDATE_PROFILE") PRE_UPDATE_PROFILE(String.valueOf("PRE_UPDATE_PROFILE")), @XmlEnumValue("PRE_REGISTRATION") PRE_REGISTRATION(String.valueOf("PRE_REGISTRATION"));


private String value;

TypeEnum(String v) {
value = v;
}

public String value() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

private TypeEnum type;
private ActionType type;
private String name;
private String description;

Expand Down Expand Up @@ -124,7 +92,7 @@ public void setId(String id) {

/**
**/
public ActionBasicResponse type(TypeEnum type) {
public ActionBasicResponse type(ActionType type) {

this.type = type;
return this;
Expand All @@ -133,10 +101,10 @@ public ActionBasicResponse type(TypeEnum type) {
@ApiModelProperty(value = "")
@JsonProperty("type")
@Valid
public TypeEnum getType() {
public ActionType getType() {
return type;
}
public void setType(TypeEnum type) {
public void setType(ActionType type) {
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionType;
import org.wso2.carbon.identity.api.server.action.management.v1.EndpointResponse;
import javax.validation.constraints.*;

Expand All @@ -34,40 +35,7 @@
public class ActionResponse {

private String id;

@XmlType(name="TypeEnum")
@XmlEnum(String.class)
public enum TypeEnum {

@XmlEnumValue("PRE_ISSUE_ACCESS_TOKEN") PRE_ISSUE_ACCESS_TOKEN(String.valueOf("PRE_ISSUE_ACCESS_TOKEN")), @XmlEnumValue("PRE_UPDATE_PASSWORD") PRE_UPDATE_PASSWORD(String.valueOf("PRE_UPDATE_PASSWORD")), @XmlEnumValue("PRE_UPDATE_PROFILE") PRE_UPDATE_PROFILE(String.valueOf("PRE_UPDATE_PROFILE")), @XmlEnumValue("PRE_REGISTRATION") PRE_REGISTRATION(String.valueOf("PRE_REGISTRATION"));


private String value;

TypeEnum(String v) {
value = v;
}

public String value() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

private TypeEnum type;
private ActionType type;
private String name;
private String description;

Expand Down Expand Up @@ -126,7 +94,7 @@ public void setId(String id) {

/**
**/
public ActionResponse type(TypeEnum type) {
public ActionResponse type(ActionType type) {

this.type = type;
return this;
Expand All @@ -135,10 +103,10 @@ public ActionResponse type(TypeEnum type) {
@ApiModelProperty(value = "")
@JsonProperty("type")
@Valid
public TypeEnum getType() {
public ActionType getType() {
return type;
}
public void setType(TypeEnum type) {
public void setType(ActionType type) {
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2024, 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.api.server.action.management.v1;

import javax.validation.constraints.*;

import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;

@XmlType(name="")
@XmlEnum(String.class)
public enum ActionType {

@XmlEnumValue("PRE_ISSUE_ACCESS_TOKEN") PRE_ISSUE_ACCESS_TOKEN(String.valueOf("PRE_ISSUE_ACCESS_TOKEN")), @XmlEnumValue("PRE_UPDATE_PASSWORD") PRE_UPDATE_PASSWORD(String.valueOf("PRE_UPDATE_PASSWORD")), @XmlEnumValue("PRE_UPDATE_PROFILE") PRE_UPDATE_PROFILE(String.valueOf("PRE_UPDATE_PROFILE")), @XmlEnumValue("PRE_REGISTRATION") PRE_REGISTRATION(String.valueOf("PRE_REGISTRATION")), @XmlEnumValue("AUTHENTICATION") AUTHENTICATION(String.valueOf("AUTHENTICATION"));


private String value;

ActionType(String v) {
value = v;
}

public String value() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static ActionType fromValue(String value) {
for (ActionType b : ActionType.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionType;
import javax.validation.constraints.*;


Expand All @@ -32,48 +33,15 @@

public class ActionTypesResponseItem {


@XmlType(name="TypeEnum")
@XmlEnum(String.class)
public enum TypeEnum {

@XmlEnumValue("PRE_ISSUE_ACCESS_TOKEN") PRE_ISSUE_ACCESS_TOKEN(String.valueOf("PRE_ISSUE_ACCESS_TOKEN")), @XmlEnumValue("PRE_UPDATE_PASSWORD") PRE_UPDATE_PASSWORD(String.valueOf("PRE_UPDATE_PASSWORD")), @XmlEnumValue("PRE_UPDATE_PROFILE") PRE_UPDATE_PROFILE(String.valueOf("PRE_UPDATE_PROFILE")), @XmlEnumValue("PRE_REGISTRATION") PRE_REGISTRATION(String.valueOf("PRE_REGISTRATION"));


private String value;

TypeEnum(String v) {
value = v;
}

public String value() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

private TypeEnum type;
private ActionType type;
private String displayName;
private String description;
private Integer count;
private String self;

/**
**/
public ActionTypesResponseItem type(TypeEnum type) {
public ActionTypesResponseItem type(ActionType type) {

this.type = type;
return this;
Expand All @@ -82,10 +50,10 @@ public ActionTypesResponseItem type(TypeEnum type) {
@ApiModelProperty(value = "")
@JsonProperty("type")
@Valid
public TypeEnum getType() {
public ActionType getType() {
return type;
}
public void setType(TypeEnum type) {
public void setType(ActionType type) {
this.type = type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ActionsApi {
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response activateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {
public Response activateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {

return delegate.activateAction(actionType, actionId );
}
Expand All @@ -92,7 +92,7 @@ public Response activateAction(@ApiParam(value = "Name of the Action Type.",requ
@ApiResponse(code = 500, message = "Server Error", response = Error.class),
@ApiResponse(code = 501, message = "Not Implemented", response = Error.class)
})
public Response createAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "This represents the action to be created." ,required=true) @Valid ActionModel actionModel) {
public Response createAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "This represents the action to be created." ,required=true) @Valid ActionModel actionModel) {

return delegate.createAction(actionType, actionModel );
}
Expand All @@ -116,7 +116,7 @@ public Response createAction(@ApiParam(value = "Name of the Action Type.",requir
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {
public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {

return delegate.deactivateAction(actionType, actionId );
}
Expand All @@ -140,7 +140,7 @@ public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",re
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response deleteAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {
public Response deleteAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) {

return delegate.deleteAction(actionType, actionId );
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public Response getActionTypes() {
@ApiResponse(code = 500, message = "Server Error", response = Error.class),
@ApiResponse(code = 501, message = "Not Implemented", response = Error.class)
})
public Response getActionsByActionType(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType) {
public Response getActionsByActionType(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType) {

return delegate.getActionsByActionType(actionType );
}
Expand All @@ -214,7 +214,7 @@ public Response getActionsByActionType(@ApiParam(value = "Name of the Action Typ
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response updateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "This represents the action information to be updated." ,required=true) @Valid ActionUpdateModel actionUpdateModel) {
public Response updateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "This represents the action information to be updated." ,required=true) @Valid ActionUpdateModel actionUpdateModel) {

return delegate.updateAction(actionType, actionId, actionUpdateModel );
}
Expand All @@ -238,7 +238,7 @@ public Response updateAction(@ApiParam(value = "Name of the Action Type.",requir
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response updateActionEndpointAuthentication(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "Authentication Type of the Action Endpoint.",required=true, allowableValues="none, basic, apiKey, bearer") @PathParam("authType") String authType, @ApiParam(value = "This represents the action endpoint authentication to be updated." ,required=true) @Valid AuthenticationTypeProperties authenticationTypeProperties) {
public Response updateActionEndpointAuthentication(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="preIssueAccessToken, preUpdatePassword, preUpdateProfile, preRegistration, authentication") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "Authentication Type of the Action Endpoint.",required=true, allowableValues="none, basic, apiKey, bearer") @PathParam("authType") String authType, @ApiParam(value = "This represents the action endpoint authentication to be updated." ,required=true) @Valid AuthenticationTypeProperties authenticationTypeProperties) {

return delegate.updateActionEndpointAuthentication(actionType, actionId, authType, authenticationTypeProperties );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@
import org.wso2.carbon.identity.action.management.model.AuthType;
import org.wso2.carbon.identity.action.management.model.EndpointConfig;
import org.wso2.carbon.identity.api.server.action.management.common.ActionManagementServiceHolder;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionBasicResponse;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionTypesResponseItem;
import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel;
import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeProperties;
import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeResponse;
import org.wso2.carbon.identity.api.server.action.management.v1.EndpointResponse;
import org.wso2.carbon.identity.api.server.action.management.v1.*;
import org.wso2.carbon.identity.api.server.action.management.v1.util.ActionMgtEndpointUtil;

import java.util.ArrayList;
Expand Down Expand Up @@ -181,7 +174,7 @@ private ActionResponse buildActionResponse(Action action) {

return new ActionResponse()
.id(action.getId())
.type(ActionResponse.TypeEnum.valueOf(action.getType().toString()))
.type(ActionType.valueOf(action.getType().toString()))
.name(action.getName())
.description(action.getDescription())
.status(ActionResponse.StatusEnum.valueOf(action.getStatus().toString()))
Expand All @@ -202,7 +195,7 @@ private ActionBasicResponse buildActionBasicResponse(Action activatedAction) {

return new ActionBasicResponse()
.id(activatedAction.getId())
.type(ActionBasicResponse.TypeEnum.valueOf(activatedAction.getType().toString()))
.type(ActionType.valueOf(activatedAction.getType().toString()))
.name(activatedAction.getName())
.description(activatedAction.getDescription())
.status(ActionBasicResponse.StatusEnum.valueOf(activatedAction.getStatus().toString()));
Expand Down
Loading

0 comments on commit 1d08944

Please sign in to comment.