Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Push Sender related components for Push notification based authentication #807

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -28,4 +28,5 @@ public class NotificationSenderManagementConstants {
public static final String URL_ENCODED_SPACE = "%20";
public static final String EMAIL_PUBLISHER_TYPE = "email";
public static final String SMS_PUBLISHER_TYPE = "sms";
public static final String PUSH_PUBLISHER_TYPE = "push";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# Uncomment this line if you want to override the impl classes.
**/impl/*

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Error;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest;
Expand Down Expand Up @@ -77,6 +80,32 @@ public Response createEmailSender(@ApiParam(value = "" ) @Valid EmailSenderAdd e
return delegate.createEmailSender(emailSenderAdd );
}

@Valid
@POST
@Path("/push")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Create a push notification sender", notes = "This API provides the capability to create a push notification sender.\\n\\nIf the 'name' is not defined, 'PushPublisher' is taken as the default name. <br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/add <br> <b>Scope required:</b> <br> * internal_config_mgt_add ", response = PushSender.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Push Notification Senders", })
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Successful Response", response = PushSender.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class),
@ApiResponse(code = 409, message = "Conflict", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response createPushSender(@ApiParam(value = "" ) @Valid PushSenderAdd pushSenderAdd) {

return delegate.createPushSender(pushSenderAdd );
}

@Valid
@POST
@Path("/sms")
Expand Down Expand Up @@ -128,6 +157,31 @@ public Response deleteEmailSender(@ApiParam(value = "name of the email sender",r
return delegate.deleteEmailSender(senderName );
}

@Valid
@DELETE
@Path("/push/{sender-name}")

@Produces({ "application/json" })
@ApiOperation(value = "Delete a push notification sender by name", notes = "This API provides the capability to delete a push notification sender by name. The URL encoded push notification sender name is used as sender-name.<br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/delete <br> <b>Scope required:</b> <br> * internal_config_mgt_delete ", response = Void.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Push Notification Senders", })
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content", response = Void.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response deletePushSender(@ApiParam(value = "name of the email sender",required=true) @PathParam("sender-name") String senderName) {

return delegate.deletePushSender(senderName );
}

@Valid
@DELETE
@Path("/sms/{sender-name}")
Expand Down Expand Up @@ -203,6 +257,56 @@ public Response getEmailSenders() {
return delegate.getEmailSenders();
}

@Valid
@GET
@Path("/push/{sender-name}")

@Produces({ "application/json" })
@ApiOperation(value = "Retrieve a push notification sender by name", notes = "This API provides the capability to retrieve a push notification sender by name. The URL encoded push notification sender name is used as sender-name.<br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/view <br> <b>Scope required:</b> <br> * internal_config_mgt_view ", response = PushSender.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Push Notification Senders", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful Response", response = PushSender.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response getPushSender(@ApiParam(value = "name of the push notification sender",required=true) @PathParam("sender-name") String senderName) {

return delegate.getPushSender(senderName );
}

@Valid
@GET
@Path("/push")

@Produces({ "application/json" })
@ApiOperation(value = "Get a list of push notification senders", notes = "This API provides the capability to retrieve the list of push notification senders. <br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/view <br> <b>Scope required:</b> <br> * internal_config_mgt_view ", response = PushSender.class, responseContainer = "List", authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Push Notification Senders", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful response", response = PushSender.class, responseContainer = "List"),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response getPushSenders() {

return delegate.getPushSenders();
}

@Valid
@GET
@Path("/sms/{sender-name}")
Expand Down Expand Up @@ -278,6 +382,31 @@ public Response updateEmailSender(@ApiParam(value = "name of the email sender",r
return delegate.updateEmailSender(senderName, emailSenderUpdateRequest );
}

@Valid
@PUT
@Path("/push/{sender-name}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Update a push notification sender", notes = "This API provides the capability to update a push notification sender by name. The URL encoded push notification sender name is used as sender-name.<br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/configmgt/update <br> <b>Scope required:</b> <br> * internal_config_mgt_update ", response = PushSender.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Push Notification Senders", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful Response", response = PushSender.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response updatePushSender(@ApiParam(value = "name of the push notification sender",required=true) @PathParam("sender-name") String senderName, @ApiParam(value = "" ,required=true) @Valid PushSenderUpdateRequest pushSenderUpdateRequest) {

return delegate.updatePushSender(senderName, pushSenderUpdateRequest );
}

@Valid
@PUT
@Path("/sms/{sender-name}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Error;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest;
Expand All @@ -36,21 +39,31 @@ public interface NotificationSendersApiService {

public Response createEmailSender(EmailSenderAdd emailSenderAdd);

public Response createPushSender(PushSenderAdd pushSenderAdd);

public Response createSMSSender(SMSSenderAdd smSSenderAdd);

public Response deleteEmailSender(String senderName);

public Response deletePushSender(String senderName);

public Response deleteSMSSender(String senderName);

public Response getEmailSender(String senderName);

public Response getEmailSenders();

public Response getPushSender(String senderName);

public Response getPushSenders();

public Response getSMSSender(String senderName);

public Response getSMSSenders();

public Response updateEmailSender(String senderName, EmailSenderUpdateRequest emailSenderUpdateRequest);

public Response updatePushSender(String senderName, PushSenderUpdateRequest pushSenderUpdateRequest);

public Response updateSMSSender(String senderName, SMSSenderUpdateRequest smSSenderUpdateRequest);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
* Copyright (c) 2023, 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.notification.sender.v1.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Properties;
import javax.validation.constraints.*;


import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;

public class PushSender {

private String name;
private String provider;
private List<Properties> properties = null;


/**
**/
public PushSender name(String name) {

this.name = name;
return this;
}

@ApiModelProperty(example = "PushPublisher", required = true, value = "")
@JsonProperty("name")
@Valid
@NotNull(message = "Property name cannot be null.")

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

/**
**/
public PushSender provider(String provider) {

this.provider = provider;
return this;
}

@ApiModelProperty(example = "fcm", required = true, value = "")
@JsonProperty("provider")
@Valid
@NotNull(message = "Property provider cannot be null.")

public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}

/**
**/
public PushSender properties(List<Properties> properties) {

this.properties = properties;
return this;
}

@ApiModelProperty(example = "[{\"key\":\"fcm.serviceAccount\",\"value\":\"jsonString\"},{\"key\":\"aws.keyId\",\"value\":\"sampleKeyId\"}]", value = "")
@JsonProperty("properties")
@Valid
public List<Properties> getProperties() {
return properties;
}
public void setProperties(List<Properties> properties) {
this.properties = properties;
}

public PushSender addPropertiesItem(Properties propertiesItem) {
if (this.properties == null) {
this.properties = new ArrayList<>();
}
this.properties.add(propertiesItem);
return this;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PushSender pushSender = (PushSender) o;
return Objects.equals(this.name, pushSender.name) &&
Objects.equals(this.provider, pushSender.provider) &&
Objects.equals(this.properties, pushSender.properties);
}

@Override
public int hashCode() {
return Objects.hash(name, provider, properties);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class PushSender {\n");

sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" provider: ").append(toIndentedString(provider)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {

if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n");
}
}

Loading
Loading