-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
698 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Eclipse | ||
.project | ||
oxauth-config-api-access.log | ||
oxauth-config-api-access*.log | ||
.classpath | ||
.settings/ | ||
bin/ | ||
|
152 changes: 152 additions & 0 deletions
152
src/main/java/org/gluu/oxauthconfigapi/rest/model/CIBAConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package org.gluu.oxauthconfigapi.rest.model; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.validation.constraints.Size; | ||
import javax.validation.constraints.NotBlank; | ||
|
||
public class CIBAConfiguration implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String apiKey; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String authDomain; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String databaseURL; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String projectId; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String storageBucket; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String messagingSenderId; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String appId; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String notificationUrl; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String notificationKey; | ||
|
||
@NotBlank | ||
@Size(min=1) | ||
private String publicVapidKey; | ||
|
||
private int cibaGrantLifeExtraTimeSec; | ||
|
||
private int cibaMaxExpirationTimeAllowedSec; | ||
|
||
public String getApiKey() { | ||
return apiKey; | ||
} | ||
|
||
public void setApiKey(String apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
|
||
public String getAuthDomain() { | ||
return authDomain; | ||
} | ||
|
||
public void setAuthDomain(String authDomain) { | ||
this.authDomain = authDomain; | ||
} | ||
|
||
public String getDatabaseURL() { | ||
return databaseURL; | ||
} | ||
|
||
public void setDatabaseURL(String databaseURL) { | ||
this.databaseURL = databaseURL; | ||
} | ||
|
||
public String getProjectId() { | ||
return projectId; | ||
} | ||
|
||
public void setProjectId(String projectId) { | ||
this.projectId = projectId; | ||
} | ||
|
||
public String getStorageBucket() { | ||
return storageBucket; | ||
} | ||
|
||
public void setStorageBucket(String storageBucket) { | ||
this.storageBucket = storageBucket; | ||
} | ||
|
||
public String getMessagingSenderId() { | ||
return messagingSenderId; | ||
} | ||
|
||
public void setMessagingSenderId(String messagingSenderId) { | ||
this.messagingSenderId = messagingSenderId; | ||
} | ||
|
||
public String getAppId() { | ||
return appId; | ||
} | ||
|
||
public void setAppId(String appId) { | ||
this.appId = appId; | ||
} | ||
|
||
public String getNotificationUrl() { | ||
return notificationUrl; | ||
} | ||
|
||
public void setNotificationUrl(String notificationUrl) { | ||
this.notificationUrl = notificationUrl; | ||
} | ||
|
||
public String getNotificationKey() { | ||
return notificationKey; | ||
} | ||
|
||
public void setNotificationKey(String notificationKey) { | ||
this.notificationKey = notificationKey; | ||
} | ||
|
||
public String getPublicVapidKey() { | ||
return publicVapidKey; | ||
} | ||
|
||
public void setPublicVapidKey(String publicVapidKey) { | ||
this.publicVapidKey = publicVapidKey; | ||
} | ||
|
||
public int getCibaGrantLifeExtraTimeSec() { | ||
return cibaGrantLifeExtraTimeSec; | ||
} | ||
|
||
public void setCibaGrantLifeExtraTimeSec(int cibaGrantLifeExtraTimeSec) { | ||
this.cibaGrantLifeExtraTimeSec = cibaGrantLifeExtraTimeSec; | ||
} | ||
|
||
public int getCibaMaxExpirationTimeAllowedSec() { | ||
return cibaMaxExpirationTimeAllowedSec; | ||
} | ||
|
||
public void setCibaMaxExpirationTimeAllowedSec(int cibaMaxExpirationTimeAllowedSec) { | ||
this.cibaMaxExpirationTimeAllowedSec = cibaMaxExpirationTimeAllowedSec; | ||
} | ||
|
||
} |
110 changes: 110 additions & 0 deletions
110
src/main/java/org/gluu/oxauthconfigapi/rest/ressource/CIBAConfigurationResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package org.gluu.oxauthconfigapi.rest.ressource; | ||
|
||
import javax.inject.Inject; | ||
import javax.validation.Valid; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import com.couchbase.client.core.message.ResponseStatus; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.Operation; | ||
import org.eclipse.microprofile.openapi.annotations.media.Content; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses; | ||
|
||
import org.gluu.oxauth.model.configuration.AppConfiguration; | ||
import org.gluu.oxtrust.service.JsonConfigurationService; | ||
import org.gluu.oxauthconfigapi.filters.ProtectedApi; | ||
import org.gluu.oxauthconfigapi.rest.model.ApiError; | ||
import org.gluu.oxauthconfigapi.rest.model.CIBAConfiguration; | ||
import org.gluu.oxauthconfigapi.util.ApiConstants; | ||
|
||
@Path(ApiConstants.BASE_API_URL + ApiConstants.CIBA) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public class CIBAConfigurationResource extends BaseResource { | ||
|
||
@Inject | ||
Logger log; | ||
|
||
@Inject | ||
JsonConfigurationService jsonConfigurationService; | ||
|
||
|
||
@GET | ||
@Operation(summary = "Gets oxAuth CIBA configuration properties.") | ||
@APIResponses( value = { | ||
@APIResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = CIBAConfiguration.class, required = true, description = "Success"))), | ||
@APIResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ApiError.class)), description = "Server error") }) | ||
@ProtectedApi(scopes = { READ_ACCESS }) | ||
public Response getCIBAConfiguration() { | ||
|
||
log.debug("CIBAConfigurationResource::getCIBAConfiguration() - Gets oxAuth CIBA configuration properties."); | ||
try { | ||
AppConfiguration appConfiguration = this.jsonConfigurationService.getOxauthAppConfiguration(); | ||
CIBAConfiguration cibaConfiguration = new CIBAConfiguration(); | ||
cibaConfiguration.setApiKey(appConfiguration.getCibaEndUserNotificationConfig().getApiKey()); | ||
cibaConfiguration.setAuthDomain(appConfiguration.getCibaEndUserNotificationConfig().getAuthDomain()); | ||
cibaConfiguration.setDatabaseURL(appConfiguration.getCibaEndUserNotificationConfig().getDatabaseURL()); | ||
cibaConfiguration.setProjectId(appConfiguration.getCibaEndUserNotificationConfig().getProjectId()); | ||
cibaConfiguration.setStorageBucket(appConfiguration.getCibaEndUserNotificationConfig().getStorageBucket()); | ||
cibaConfiguration.setMessagingSenderId(appConfiguration.getCibaEndUserNotificationConfig().getMessagingSenderId()); | ||
cibaConfiguration.setAppId(appConfiguration.getCibaEndUserNotificationConfig().getAppId()); | ||
cibaConfiguration.setNotificationUrl(appConfiguration.getCibaEndUserNotificationConfig().getNotificationUrl()); | ||
cibaConfiguration.setNotificationKey(appConfiguration.getCibaEndUserNotificationConfig().getNotificationKey()); | ||
cibaConfiguration.setPublicVapidKey(appConfiguration.getCibaEndUserNotificationConfig().getPublicVapidKey()); | ||
cibaConfiguration.setCibaGrantLifeExtraTimeSec(appConfiguration.getCibaGrantLifeExtraTimeSec()); | ||
cibaConfiguration.setCibaMaxExpirationTimeAllowedSec(appConfiguration.getCibaMaxExpirationTimeAllowedSec()); | ||
|
||
return Response.ok(cibaConfiguration).build(); | ||
|
||
}catch(Exception ex) { | ||
log.error("Failed to retrieve oxAuth CIBA configuration", ex); | ||
return getInternalServerError(ex); | ||
} | ||
} | ||
|
||
|
||
@PUT | ||
@Operation(summary = "Updates oxAuth CIBA configuration properties.") | ||
@APIResponses(value = { | ||
@APIResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Response.class, required = true, description = "Success"))), | ||
@APIResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ApiError.class, required = false)) , description = "Unauthorized"), | ||
@APIResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ApiError.class)), description = "Server error") }) | ||
@ProtectedApi(scopes = { WRITE_ACCESS }) | ||
public Response updateCIBAConfiguration(@Valid CIBAConfiguration cibaConfiguration) { | ||
log.debug("CIBAConfigurationResource::updateCIBAConfiguration() - Updates oxAuth CIBA configuration properties."); | ||
try { | ||
AppConfiguration appConfiguration = this.jsonConfigurationService.getOxauthAppConfiguration(); | ||
|
||
appConfiguration.getCibaEndUserNotificationConfig().setApiKey(cibaConfiguration.getApiKey()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setAuthDomain(cibaConfiguration.getAuthDomain()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setDatabaseURL(cibaConfiguration.getDatabaseURL()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setProjectId(cibaConfiguration.getProjectId()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setStorageBucket(cibaConfiguration.getStorageBucket()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setMessagingSenderId(cibaConfiguration.getMessagingSenderId()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setAppId(cibaConfiguration.getAppId()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setNotificationUrl(cibaConfiguration.getNotificationUrl()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setNotificationKey(cibaConfiguration.getNotificationKey()); | ||
appConfiguration.getCibaEndUserNotificationConfig().setPublicVapidKey(cibaConfiguration.getPublicVapidKey()); | ||
appConfiguration.setCibaGrantLifeExtraTimeSec(cibaConfiguration.getCibaGrantLifeExtraTimeSec()); | ||
appConfiguration.setCibaMaxExpirationTimeAllowedSec(cibaConfiguration.getCibaMaxExpirationTimeAllowedSec()); | ||
|
||
this.jsonConfigurationService.saveOxAuthAppConfiguration(appConfiguration); | ||
|
||
return Response.ok(ResponseStatus.SUCCESS).build(); | ||
|
||
}catch(Exception ex) { | ||
log.error("Failed to update oxAuth CIBA configuration", ex); | ||
return getInternalServerError(ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.