Skip to content

Commit

Permalink
Database changes for new client metadata assets
Browse files Browse the repository at this point in the history
- Added new table definitions for all databases
- Added database access API and implementation

[#109263482] https://www.pivotaltracker.com/story/show/109263482

Signed-off-by: Jonathan Lo <jlo@us.ibm.com>
  • Loading branch information
Paul Warren authored and cf-identity committed Jan 21, 2016
1 parent 92579ad commit ec2bd14
Show file tree
Hide file tree
Showing 12 changed files with 822 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.cloudfoundry.identity.uaa.client;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.net.URL;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ClientMetadata {

private String clientId;
private String identityZoneId;
private boolean showOnHomePage;
private URL appLaunchUrl;
private String appIcon;
private int version;

@JsonIgnore
public String getClientId() {
return clientId;
}

@JsonIgnore
public void setClientId(String clientId) {
this.clientId = clientId;
}

@JsonIgnore
public String getIdentityZoneId() {
return identityZoneId;
}

@JsonIgnore
public void setIdentityZoneId(String identityZoneId) {
this.identityZoneId = identityZoneId;
}

public boolean isShowOnHomePage() {
return showOnHomePage;
}

public void setShowOnHomePage(boolean showOnHomePage) {
this.showOnHomePage = showOnHomePage;
}

public URL getAppLaunchUrl() {
return appLaunchUrl;
}

public void setAppLaunchUrl(URL appLaunchUrl) {
this.appLaunchUrl = appLaunchUrl;
}

public String getAppIcon() {
return appIcon;
}

public void setAppIcon(String appIcon) {
this.appIcon = appIcon;
}

@JsonIgnore
public int getVersion() {
return version;
}

@JsonIgnore
public void setVersion(int version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.cloudfoundry.identity.uaa.client;

import org.springframework.http.HttpStatus;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.NoSuchClientException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
@Controller
public class ClientMetadataAdminEndpoints {

private ClientMetaDetailsProvisioning clientMetaDetailsProvisioning;
private ClientDetailsService clients;

@RequestMapping(value = "/oauth/clients/{client}/meta", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public ClientMetaDetails createClientUIDetails(@RequestBody ClientMetaDetails clientMetaDetails,
@PathVariable("client") String clientId)
throws ClientNotFoundException {

try {
clients.loadClientByClientId(clientId);
} catch (NoSuchClientException nsce) {
throw new ClientNotFoundException(clientId);
}

clientMetaDetails.setClientId(clientId);
return clientMetaDetailsProvisioning.create(clientMetaDetails);
}

// GET
@RequestMapping(value = "/oauth/clients/{client}/meta", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public ClientMetaDetails retrieveClientUIDetails(@PathVariable("client") String clientId) {
return null;
}

// PUT (Update)

// DELETE

// GET (retrieveAll)

public void setClientMetaDetailsProvisioning(ClientMetaDetailsProvisioning clientMetaDetailsProvisioning) {
this.clientMetaDetailsProvisioning = clientMetaDetailsProvisioning;
}

public void setClients(ClientDetailsService clients) {
this.clients = clients;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2014] Pivotal Software, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
package org.cloudfoundry.identity.uaa.client;

import org.springframework.http.HttpStatus;

import java.util.Map;

/**
* @author Luke Taylor
* @author Dave Syer
*/
public class ClientMetadataException extends RuntimeException {

private final HttpStatus status;
protected Map<String, Object> extraInfo;

public ClientMetadataException(String message, Throwable cause, HttpStatus status) {
super(message, cause);
this.status = status;
}

public ClientMetadataException(String message, HttpStatus status) {
super(message);
this.status = status;
}

public ClientMetadataException(String message, HttpStatus status, Map<String,Object> extraInformation) {
super(message);
this.status = status;
this.extraInfo = extraInformation;
}

public HttpStatus getStatus() {
return status;
}

public Map<String, Object> getExtraInfo() {
return extraInfo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.cloudfoundry.identity.uaa.client;

import org.cloudfoundry.identity.uaa.error.UaaException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Client not found")
public class ClientMetadataNotFoundException extends UaaException {

// private String clientId;

// public ClientNotFoundException(String clientId) {
// this.clientId = clientId;
// }

public ClientMetadataNotFoundException(String msg) {
super("client_not_found", msg, HttpStatus.NOT_FOUND.value());
}


// public String getClientId() {
// return this.clientId;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.cloudfoundry.identity.uaa.client;

import org.cloudfoundry.identity.uaa.resources.ResourceManager;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
public interface ClientMetadataProvisioning extends ResourceManager<ClientMetaDetails> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.cloudfoundry.identity.uaa.client;

/*******************************************************************************
* Cloud Foundry
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved.
* <p>
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
* <p>
* This product includes a number of subcomponents with
* separate copyright notices and license terms. Your use of these
* subcomponents is subject to the terms and conditions of the
* subcomponent's license, as noted in the LICENSE file.
*******************************************************************************/
public class ClientNotFoundException {
}

0 comments on commit ec2bd14

Please sign in to comment.