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 API layer to manage authorization details types #728

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-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
Expand All @@ -20,6 +20,7 @@

import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager;
import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager;
import org.wso2.carbon.identity.api.resource.mgt.AuthorizationDetailsTypeManager;
import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;

/**
Expand All @@ -30,6 +31,7 @@ public class APIResourceManagementServiceHolder {
private static APIResourceManager apiResourceManager;
private static APIResourceCollectionManager apiResourceCollectionManager;
private static OAuthAdminServiceImpl oAuthAdminServiceImpl;
private static AuthorizationDetailsTypeManager authorizationDetailsTypeManager;

/**
* Get APIResourceManager osgi service.
Expand Down Expand Up @@ -90,4 +92,25 @@ public static void setOAuthAdminServiceImpl(OAuthAdminServiceImpl oAuthAdminServ

APIResourceManagementServiceHolder.oAuthAdminServiceImpl = oAuthAdminServiceImpl;
}

/**
* Set {@link AuthorizationDetailsTypeManager} instance.
*
* @return AuthorizationDetailsTypeManager instance.
*/
public static AuthorizationDetailsTypeManager getAuthorizationDetailsTypeManager() {

return authorizationDetailsTypeManager;
}

/**
* Set {@link AuthorizationDetailsTypeManager} instance.
*
* @param authorizationDetailsTypeManager AuthorizationDetailsTypeManager instance.
*/
public static void setAuthorizationDetailsTypeManager(
AuthorizationDetailsTypeManager authorizationDetailsTypeManager) {

APIResourceManagementServiceHolder.authorizationDetailsTypeManager = authorizationDetailsTypeManager;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.api.resource.common.factory;

import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.api.resource.mgt.AuthorizationDetailsTypeManager;

/**
* Factory class for {@link AuthorizationDetailsTypeManager}.
*/
public class AuthorizationDetailsTypeMgtOSGiServiceFactory extends
AbstractFactoryBean<AuthorizationDetailsTypeManager> {

private AuthorizationDetailsTypeManager authorizationDetailsTypeManager;

@Override
public Class<?> getObjectType() {

return Object.class;
}

@Override
protected AuthorizationDetailsTypeManager createInstance() throws Exception {

if (this.authorizationDetailsTypeManager == null) {
this.authorizationDetailsTypeManager = (AuthorizationDetailsTypeManager) PrivilegedCarbonContext.
getThreadLocalCarbonContext().getOSGiService(AuthorizationDetailsTypeManager.class, null);
if (this.authorizationDetailsTypeManager == null) {
throw new Exception("Unable to retrieve AuthorizationDetailsTypeManager service.");
}
}
return this.authorizationDetailsTypeManager;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* 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
Expand All @@ -24,6 +24,7 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.AuthorizationDetailsTypesCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel;
import javax.validation.constraints.*;

Expand All @@ -41,6 +42,8 @@ public class APIResourceCreationModel {
private Boolean requiresAuthorization;
private List<ScopeCreationModel> scopes = null;

private List<AuthorizationDetailsTypesCreationModel> authorizationDetailsTypes = null;


/**
**/
Expand Down Expand Up @@ -144,6 +147,32 @@ public APIResourceCreationModel addScopesItem(ScopeCreationModel scopesItem) {
return this;
}

/**
**/
public APIResourceCreationModel authorizationDetailsTypes(List<AuthorizationDetailsTypesCreationModel> authorizationDetailsTypes) {

this.authorizationDetailsTypes = authorizationDetailsTypes;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("authorizationDetailsTypes")
@Valid
public List<AuthorizationDetailsTypesCreationModel> getAuthorizationDetailsTypes() {
return authorizationDetailsTypes;
}
public void setAuthorizationDetailsTypes(List<AuthorizationDetailsTypesCreationModel> authorizationDetailsTypes) {
this.authorizationDetailsTypes = authorizationDetailsTypes;
}

public APIResourceCreationModel addAuthorizationDetailsTypesItem(AuthorizationDetailsTypesCreationModel authorizationDetailsTypesItem) {
if (this.authorizationDetailsTypes == null) {
this.authorizationDetailsTypes = new ArrayList<AuthorizationDetailsTypesCreationModel>();
}
this.authorizationDetailsTypes.add(authorizationDetailsTypesItem);
return this;
}



@Override
Expand All @@ -160,12 +189,13 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.identifier, apIResourceCreationModel.identifier) &&
Objects.equals(this.description, apIResourceCreationModel.description) &&
Objects.equals(this.requiresAuthorization, apIResourceCreationModel.requiresAuthorization) &&
Objects.equals(this.scopes, apIResourceCreationModel.scopes);
Objects.equals(this.scopes, apIResourceCreationModel.scopes) &&
Objects.equals(this.authorizationDetailsTypes, apIResourceCreationModel.authorizationDetailsTypes);
}

@Override
public int hashCode() {
return Objects.hash(name, identifier, description, requiresAuthorization, scopes);
return Objects.hash(name, identifier, description, requiresAuthorization, scopes, authorizationDetailsTypes);
}

@Override
Expand All @@ -179,6 +209,7 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n");
sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n");
sb.append(" authorizationDetailsTypes: ").append(toIndentedString(authorizationDetailsTypes)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* 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
Expand All @@ -24,6 +24,7 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.AuthorizationDetailsTypesCreationModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel;
import javax.validation.constraints.*;

Expand All @@ -41,6 +42,10 @@ public class APIResourcePatchModel {

private List<String> removedScopes = null;

private List<AuthorizationDetailsTypesCreationModel> addedAuthorizationDetailsTypes = null;

private List<String> removedAuthorizationDetailsTypes = null;


/**
**/
Expand Down Expand Up @@ -131,6 +136,58 @@ public APIResourcePatchModel addRemovedScopesItem(String removedScopesItem) {
return this;
}

/**
**/
public APIResourcePatchModel addedAuthorizationDetailsTypes(List<AuthorizationDetailsTypesCreationModel> addedAuthorizationDetailsTypes) {

this.addedAuthorizationDetailsTypes = addedAuthorizationDetailsTypes;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("addedAuthorizationDetailsTypes")
@Valid
public List<AuthorizationDetailsTypesCreationModel> getAddedAuthorizationDetailsTypes() {
return addedAuthorizationDetailsTypes;
}
public void setAddedAuthorizationDetailsTypes(List<AuthorizationDetailsTypesCreationModel> addedAuthorizationDetailsTypes) {
this.addedAuthorizationDetailsTypes = addedAuthorizationDetailsTypes;
}

public APIResourcePatchModel addAddedAuthorizationDetailsTypesItem(AuthorizationDetailsTypesCreationModel addedAuthorizationDetailsTypesItem) {
if (this.addedAuthorizationDetailsTypes == null) {
this.addedAuthorizationDetailsTypes = new ArrayList<AuthorizationDetailsTypesCreationModel>();
}
this.addedAuthorizationDetailsTypes.add(addedAuthorizationDetailsTypesItem);
return this;
}

/**
**/
public APIResourcePatchModel removedAuthorizationDetailsTypes(List<String> removedAuthorizationDetailsTypes) {

this.removedAuthorizationDetailsTypes = removedAuthorizationDetailsTypes;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("removedAuthorizationDetailsTypes")
@Valid
public List<String> getRemovedAuthorizationDetailsTypes() {
return removedAuthorizationDetailsTypes;
}
public void setRemovedAuthorizationDetailsTypes(List<String> removedAuthorizationDetailsTypes) {
this.removedAuthorizationDetailsTypes = removedAuthorizationDetailsTypes;
}

public APIResourcePatchModel addRemovedAuthorizationDetailsTypesItem(String removedAuthorizationDetailsTypesItem) {
if (this.removedAuthorizationDetailsTypes == null) {
this.removedAuthorizationDetailsTypes = new ArrayList<String>();
}
this.removedAuthorizationDetailsTypes.add(removedAuthorizationDetailsTypesItem);
return this;
}



@Override
Expand All @@ -146,12 +203,14 @@ public boolean equals(java.lang.Object o) {
return Objects.equals(this.name, apIResourcePatchModel.name) &&
Objects.equals(this.description, apIResourcePatchModel.description) &&
Objects.equals(this.addedScopes, apIResourcePatchModel.addedScopes) &&
Objects.equals(this.removedScopes, apIResourcePatchModel.removedScopes);
Objects.equals(this.removedScopes, apIResourcePatchModel.removedScopes) &&
Objects.equals(this.addedAuthorizationDetailsTypes, apIResourcePatchModel.addedAuthorizationDetailsTypes) &&
Objects.equals(this.removedAuthorizationDetailsTypes, apIResourcePatchModel.removedAuthorizationDetailsTypes);
}

@Override
public int hashCode() {
return Objects.hash(name, description, addedScopes, removedScopes);
return Objects.hash(name, description, addedScopes, removedScopes, addedAuthorizationDetailsTypes, removedAuthorizationDetailsTypes);
}

@Override
Expand All @@ -164,6 +223,8 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" addedScopes: ").append(toIndentedString(addedScopes)).append("\n");
sb.append(" removedScopes: ").append(toIndentedString(removedScopes)).append("\n");
sb.append(" addedAuthorizationDetailsTypes: ").append(toIndentedString(addedAuthorizationDetailsTypes)).append("\n");
sb.append(" removedAuthorizationDetailsTypes: ").append(toIndentedString(removedAuthorizationDetailsTypes)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* 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
Expand All @@ -24,6 +24,7 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.api.resource.v1.AuthorizationDetailsTypesGetModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.Property;
import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel;
import org.wso2.carbon.identity.api.server.api.resource.v1.SubscribedApplicationGetModel;
Expand All @@ -45,6 +46,8 @@ public class APIResourceResponse {
private Boolean requiresAuthorization;
private List<ScopeGetModel> scopes = null;

private List<AuthorizationDetailsTypesGetModel> authorizationDetailsTypes = null;

private List<SubscribedApplicationGetModel> subscribedApplications = null;

private List<Property> properties = null;
Expand Down Expand Up @@ -193,6 +196,32 @@ public APIResourceResponse addScopesItem(ScopeGetModel scopesItem) {

/**
**/
public APIResourceResponse authorizationDetailsTypes(List<AuthorizationDetailsTypesGetModel> authorizationDetailsTypes) {

this.authorizationDetailsTypes = authorizationDetailsTypes;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("authorizationDetailsTypes")
@Valid
public List<AuthorizationDetailsTypesGetModel> getAuthorizationDetailsTypes() {
return authorizationDetailsTypes;
}
public void setAuthorizationDetailsTypes(List<AuthorizationDetailsTypesGetModel> authorizationDetailsTypes) {
this.authorizationDetailsTypes = authorizationDetailsTypes;
}

public APIResourceResponse addAuthorizationDetailsTypesItem(AuthorizationDetailsTypesGetModel authorizationDetailsTypesItem) {
if (this.authorizationDetailsTypes == null) {
this.authorizationDetailsTypes = new ArrayList<AuthorizationDetailsTypesGetModel>();
}
this.authorizationDetailsTypes.add(authorizationDetailsTypesItem);
return this;
}

/**
**/
public APIResourceResponse subscribedApplications(List<SubscribedApplicationGetModel> subscribedApplications) {

this.subscribedApplications = subscribedApplications;
Expand Down Expand Up @@ -282,14 +311,15 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.type, apIResourceResponse.type) &&
Objects.equals(this.requiresAuthorization, apIResourceResponse.requiresAuthorization) &&
Objects.equals(this.scopes, apIResourceResponse.scopes) &&
Objects.equals(this.authorizationDetailsTypes, apIResourceResponse.authorizationDetailsTypes) &&
Objects.equals(this.subscribedApplications, apIResourceResponse.subscribedApplications) &&
Objects.equals(this.properties, apIResourceResponse.properties) &&
Objects.equals(this.self, apIResourceResponse.self);
}

@Override
public int hashCode() {
return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, subscribedApplications, properties, self);
return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, authorizationDetailsTypes, subscribedApplications, properties, self);
}

@Override
Expand All @@ -305,6 +335,7 @@ public String toString() {
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n");
sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n");
sb.append(" authorizationDetailsTypes: ").append(toIndentedString(authorizationDetailsTypes)).append("\n");
sb.append(" subscribedApplications: ").append(toIndentedString(subscribedApplications)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).append("\n");
sb.append(" self: ").append(toIndentedString(self)).append("\n");
Expand Down
Loading
Loading