=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java 2015-06-24 05:47:58 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java 2015-06-25 06:26:15 +0000 @@ -36,6 +36,9 @@ import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.MergeStrategy; +import org.hisp.dhis.schema.PropertyType; +import org.hisp.dhis.schema.annotation.Property; +import org.hisp.dhis.schema.annotation.PropertyRange; import java.util.ArrayList; import java.util.List; @@ -74,6 +77,7 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @Property( PropertyType.IDENTIFIER ) public String getCid() { return cid; @@ -86,6 +90,7 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @PropertyRange( min = 36, max = 36 ) public String getSecret() { return secret; === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/GetOAuth2ClientAction.java 2015-06-25 06:26:15 +0000 @@ -0,0 +1,86 @@ +package org.hisp.dhis.settings.action.system; + +/* + * Copyright (c) 2004-2015, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.opensymphony.xwork2.Action; +import org.hisp.dhis.oauth2.OAuth2Client; +import org.hisp.dhis.oauth2.OAuth2ClientService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; + +/** + * @author Morten Olav Hansen + */ +public class GetOAuth2ClientAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private OAuth2ClientService clientService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String id; + + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + + private OAuth2Client client; + + public OAuth2Client getClient() + { + return client; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + if ( !StringUtils.isEmpty( id ) ) + { + client = clientService.getOAuth2Client( id ); + } + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2015-06-25 03:36:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/META-INF/dhis/beans.xml 2015-06-25 06:26:15 +0000 @@ -127,6 +127,9 @@ + class="org.hisp.dhis.settings.action.system.GetOAuth2ClientsAction" scope="prototype" /> + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2015-06-25 03:36:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/org/hisp/dhis/settings/i18n_module.properties 2015-06-25 06:26:15 +0000 @@ -131,4 +131,9 @@ for_example=For example allow_assigning_object_to_related_objects_during_add_or_update=Allow assigning object to related objects during add or update delete_oauth2_client=Are you sure you want to remove this OAuth2 client? -oauth2_client_management=OAuth2 Management \ No newline at end of file +oauth2_client_management=OAuth2 Management +create_new_oauth2_client=Create new OAuth2 Client +edit_oauth2_client=Edit OAuth2 Client +name=Name +client_id=Client ID +client_secret=Client Secret \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2015-06-25 03:36:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/resources/struts.xml 2015-06-25 06:26:15 +0000 @@ -186,5 +186,12 @@ F_OAUTH2_CLIENT_MANAGE + + /main.vm + /dhis-web-maintenance-settings/oAuth2Client.vm + /dhis-web-maintenance-settings/settingsMenu.vm + F_OAUTH2_CLIENT_MANAGE + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js 2015-06-25 04:16:58 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/javascripts/oauth2Clients.js 2015-06-25 06:26:15 +0000 @@ -1,5 +1,56 @@ +var OAuth2Service = { + save: function(o, id) { + if( !id ) { + return $.ajax({ + url: '../api/oAuth2Clients/' + id, + type: 'PUT', + contentType: 'application/json', + data: JSON.stringify(o) + }); + } else { + return $.ajax({ + url: '../api/oAuth2Clients', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(o) + }); + } + }, + load: function(id) { + return $.ajax({ + url: '../api/oAuth2Clients/' + id + }) + }, + fromJson: function(o) { + $('#name').val(o.name); + $('#clientId').val(o.cid); + $('#clientSecret').val(o.secret); + }, + toJson: function() { + var o = {}; + + o.name = $('#name').val(); + o.cid = $('#clientId').val(); + o.secret = $('#clientSecret').val(); + + return o; + }, + getUuid: function() { + var def = $.Deferred(); + + $.ajax({ + url: '../api/system/uuid', + dataType: 'json' + }).done(function(o) { + def.resolve(o.codes[0]); + }); + + return def.promise(); + } +}; + function updateO2Client(context) { - console.log(context); + location.href = 'getOAuth2Client.action?id=' + context.uid; } function deleteO2Client(context) { @@ -11,4 +62,4 @@ location.reload(); }); } -} \ No newline at end of file +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/oAuth2client.vm 2015-06-25 06:26:15 +0000 @@ -0,0 +1,70 @@ + + + + +#if( $id ) +

$i18n.getString( "edit_oauth2_client" )

+#else +

$i18n.getString( "create_new_oauth2_client" )

+#end + +
+ + + + + + + + + + + + + + + + +
$i18n.getString( "details" )
+ + #if( $id ) + + #else + + #end + +
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm 2015-06-25 03:36:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/webapp/dhis-web-maintenance-settings/systemOAuth2Clients.vm 2015-06-25 06:26:15 +0000 @@ -23,6 +23,11 @@ + + +
+ +