dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37862
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19331: Add domain class OAuth2Client (+ store/service/test), used to store oauth2 client information
------------------------------------------------------------
revno: 19331
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-06-10 15:13:05 +0700
message:
Add domain class OAuth2Client (+ store/service/test), used to store oauth2 client information
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/
dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/DefaultOAuth2ClientService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate/
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate/HibernateOAuth2ClientStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientStoreTest.java
modified:
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2'
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2Client.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,105 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "client", namespace = DxfNamespaces.DXF_2_0 )
+public class OAuth2Client extends BaseIdentifiableObject
+{
+ private String cid;
+
+ private String secret = UUID.randomUUID().toString();
+
+ public OAuth2Client()
+ {
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getCid()
+ {
+ return cid;
+ }
+
+ public void setCid( String cid )
+ {
+ this.cid = cid;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getSecret()
+ {
+ return secret;
+ }
+
+ public void setSecret( String secret )
+ {
+ this.secret = secret;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return 31 * super.hashCode() + Objects.hash( cid, secret );
+ }
+
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( obj == null || getClass() != obj.getClass() )
+ {
+ return false;
+ }
+ if ( !super.equals( obj ) )
+ {
+ return false;
+ }
+
+ final OAuth2Client other = (OAuth2Client) obj;
+
+ return Objects.equals( this.cid, other.cid )
+ && Objects.equals( this.secret, other.secret );
+ }
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientService.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,51 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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 java.util.Collection;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface OAuth2ClientService
+{
+ void saveOAuth2Client( OAuth2Client oAuth2Client );
+
+ void updateOAuth2Client( OAuth2Client oAuth2Client );
+
+ void deleteOAuth2Client( OAuth2Client oAuth2Client );
+
+ OAuth2Client getOAuth2Client( int id );
+
+ OAuth2Client getOAuth2Client( String uid );
+
+ OAuth2Client getOAuth2ClientByClientId( String cid );
+
+ Collection<OAuth2Client> getOAuth2Clients();
+}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/oauth2/OAuth2ClientStore.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,48 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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 org.hisp.dhis.common.GenericIdentifiableObjectStore;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface OAuth2ClientStore
+ extends GenericIdentifiableObjectStore<OAuth2Client>
+{
+ String ID = OAuth2ClientStore.class.getName();
+
+ /**
+ * Get OAuth2 client by cid.
+ *
+ * @param cid ClientID
+ * @return Matched OAuth2Client or null if not found
+ */
+ OAuth2Client getByClientId( String cid );
+}
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/DefaultOAuth2ClientService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/DefaultOAuth2ClientService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/DefaultOAuth2ClientService.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collection;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Transactional
+public class DefaultOAuth2ClientService implements OAuth2ClientService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private OAuth2ClientStore oAuth2ClientStore;
+
+ // -------------------------------------------------------------------------
+ // OAuth2ClientService
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void saveOAuth2Client( OAuth2Client oAuth2Client )
+ {
+ oAuth2ClientStore.save( oAuth2Client );
+ }
+
+ @Override
+ public void updateOAuth2Client( OAuth2Client oAuth2Client )
+ {
+ oAuth2ClientStore.update( oAuth2Client );
+ }
+
+ @Override
+ public void deleteOAuth2Client( OAuth2Client oAuth2Client )
+ {
+ oAuth2ClientStore.delete( oAuth2Client );
+ }
+
+ @Override
+ public OAuth2Client getOAuth2Client( int id )
+ {
+ return oAuth2ClientStore.get( id );
+ }
+
+ @Override
+ public OAuth2Client getOAuth2Client( String uid )
+ {
+ return oAuth2ClientStore.getByUid( uid );
+ }
+
+ @Override
+ public OAuth2Client getOAuth2ClientByClientId( String cid )
+ {
+ return oAuth2ClientStore.getByClientId( cid );
+ }
+
+ @Override
+ public Collection<OAuth2Client> getOAuth2Clients()
+ {
+ return oAuth2ClientStore.getAll();
+ }
+}
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate/HibernateOAuth2ClientStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate/HibernateOAuth2ClientStore.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/oauth2/hibernate/HibernateOAuth2ClientStore.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,48 @@
+package org.hisp.dhis.oauth2.hibernate;
+
+/*
+ * 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 org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.oauth2.OAuth2Client;
+import org.hisp.dhis.oauth2.OAuth2ClientStore;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class HibernateOAuth2ClientStore
+ extends HibernateIdentifiableObjectStore<OAuth2Client>
+ implements OAuth2ClientStore
+{
+ @Override
+ public OAuth2Client getByClientId( String cid )
+ {
+ return (OAuth2Client) getCriteria().add( Restrictions.eq( "cid", cid ) ).uniqueResult();
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-06-01 15:28:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-06-10 08:13:05 +0000
@@ -361,7 +361,7 @@
<property name="sessionFactory" ref="sessionFactory" />
<property name="cacheable" value="true" />
</bean>
-
+
<bean id="org.hisp.dhis.mapping.MapStore" class="org.hisp.dhis.mapping.hibernate.HibernateMapStore">
<property name="clazz" value="org.hisp.dhis.mapping.Map" />
<property name="sessionFactory" ref="sessionFactory" />
@@ -446,7 +446,7 @@
<property name="securityService" ref="org.hisp.dhis.security.SecurityService" />
</bean>
- <bean id="org.hisp.dhis.dataelement.DataElementService" class="org.hisp.dhis.dataelement.DefaultDataElementService">
+ <bean id="org.hisp.dhis.dataelement.DataElementService" class="org.hisp.dhis.dataelement.DefaultDataElementService">
<property name="dataElementStore" ref="org.hisp.dhis.dataelement.DataElementStore" />
<property name="dataElementGroupStore" ref="org.hisp.dhis.dataelement.DataElementGroupStore" />
<property name="dataElementGroupSetStore" ref="org.hisp.dhis.dataelement.DataElementGroupSetStore" />
@@ -691,12 +691,20 @@
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
-
+
<bean id="org.hisp.dhis.legend.LegendService" class="org.hisp.dhis.legend.DefaultLegendService">
<property name="legendStore" ref="org.hisp.dhis.legend.LegendStore" />
<property name="legendSetStore" ref="org.hisp.dhis.legend.LegendSetStore" />
</bean>
+ <bean id="org.hisp.dhis.oauth2.OAuth2ClientStore" class="org.hisp.dhis.oauth2.hibernate.HibernateOAuth2ClientStore">
+ <property name="clazz" value="org.hisp.dhis.oauth2.OAuth2Client" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="cacheable" value="true" />
+ </bean>
+
+ <bean id="oAuth2ClientService" class="org.hisp.dhis.oauth2.DefaultOAuth2ClientService" />
+
<bean id="org.hisp.dhis.setting.SystemSettingManager" class="org.hisp.dhis.setting.DefaultSystemSettingManager">
<property name="systemSettingStore" ref="org.hisp.dhis.setting.SystemSettingStore" />
<property name="flags">
@@ -771,7 +779,7 @@
<value>south_africa</value>
<value>south_africa_department_of_health</value>
<value>sri_lanka</value>
- <value>sudan</value>
+ <value>sudan</value>
<value>swaziland</value>
<value>tajikistan</value>
<value>tanzania</value>
@@ -843,7 +851,7 @@
<bean id="org.hisp.dhis.system.SystemService" class="org.hisp.dhis.system.DefaultSystemService" />
<!-- SMS Services -->
-
+
<bean id="org.hisp.dhis.sms.MessageQueue" class="org.hisp.dhis.sms.DatabaseSupportedInternalMemoryMessageQueue">
<property name="smsStore" ref="org.hisp.dhis.sms.hibernate.IncomingSmsStore" />
</bean>
@@ -880,7 +888,7 @@
<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
</bean>
- <bean id="org.hisp.dhis.sms.SmsMessageSender" class="org.hisp.dhis.sms.SmsMessageSender"/>
+ <bean id="org.hisp.dhis.sms.SmsMessageSender" class="org.hisp.dhis.sms.SmsMessageSender" />
<bean id="org.hisp.dhis.sms.task.SendSmsTask" class="org.hisp.dhis.sms.task.SendSmsTask" scope="prototype" />
@@ -1065,8 +1073,8 @@
class="org.hisp.dhis.dataelement.DataElementCategoryComboDeletionHandler">
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
-
- <bean id="org.hisp.dhis.dataelement.DataElementCategoryDimensionDeletionHandler"
+
+ <bean id="org.hisp.dhis.dataelement.DataElementCategoryDimensionDeletionHandler"
class="org.hisp.dhis.dataelement.DataElementCategoryDimensionDeletionHandler" />
<bean id="org.hisp.dhis.dataset.DataSetDeletionHandler" class="org.hisp.dhis.dataset.DataSetDeletionHandler" />
@@ -1132,8 +1140,8 @@
<bean id="org.hisp.dhis.user.UserSettingDeletionHandler" class="org.hisp.dhis.user.UserSettingDeletionHandler" />
- <bean id="org.hisp.dhis.dataelement.DataElementCategoryDeletionHandler"
- class="org.hisp.dhis.dataelement.DataElementCategoryDeletionHandler" />
+ <bean id="org.hisp.dhis.dataelement.DataElementCategoryDeletionHandler"
+ class="org.hisp.dhis.dataelement.DataElementCategoryDeletionHandler" />
<bean id="org.hisp.dhis.dataelement.DataElementGroupSetDeletionHandler"
class="org.hisp.dhis.dataelement.DataElementGroupSetDeletionHandler" />
@@ -1156,7 +1164,7 @@
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
- <bean id="org.hisp.dhis.legend.LegendSetDeletionHandler" class="org.hisp.dhis.legend.LegendSetDeletionHandler"/>
+ <bean id="org.hisp.dhis.legend.LegendSetDeletionHandler" class="org.hisp.dhis.legend.LegendSetDeletionHandler" />
<bean id="org.hisp.dhis.mapping.MapViewDeletionHandler" class="org.hisp.dhis.mapping.MapViewDeletionHandler">
<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/oauth2.hibernate/OAuth2Client.hbm.xml 2015-06-10 08:13:05 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
+ [<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
+ >
+
+<hibernate-mapping>
+ <class name="org.hisp.dhis.oauth2.OAuth2Client" table="oauth2client">
+
+ <cache usage="read-write" />
+
+ <id name="id" column="oauth2clientid">
+ <generator class="native" />
+ </id>
+ &identifiableProperties;
+
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
+
+ <property name="cid" column="cid" not-null="true" unique="true" length="230" />
+
+ <property name="secret" column="secret" not-null="true" unique="false" length="512" />
+
+ </class>
+</hibernate-mapping>
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientServiceTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientServiceTest.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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 org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OAuth2ClientServiceTest
+ extends DhisSpringTest
+{
+ @Autowired
+ private OAuth2ClientService oAuth2ClientService;
+
+ private OAuth2Client clientA;
+
+ private OAuth2Client clientB;
+
+ private OAuth2Client clientC;
+
+ @Override
+ public void setUpTest()
+ {
+ clientA = new OAuth2Client();
+ clientA.setName( "clientA" );
+ clientA.setCid( "clientA" );
+
+ clientB = new OAuth2Client();
+ clientB.setName( "clientB" );
+ clientB.setCid( "clientB" );
+
+ clientC = new OAuth2Client();
+ clientC.setName( "clientC" );
+ clientC.setCid( "clientC" );
+ }
+
+ @Test
+ public void testGetAll()
+ {
+ oAuth2ClientService.saveOAuth2Client( clientA );
+ oAuth2ClientService.saveOAuth2Client( clientB );
+ oAuth2ClientService.saveOAuth2Client( clientC );
+
+ Collection<OAuth2Client> all = oAuth2ClientService.getOAuth2Clients();
+
+ assertEquals( 3, all.size() );
+ }
+
+ @Test
+ public void testGetByClientID()
+ {
+ oAuth2ClientService.saveOAuth2Client( clientA );
+ oAuth2ClientService.saveOAuth2Client( clientB );
+ oAuth2ClientService.saveOAuth2Client( clientC );
+
+ assertNotNull( oAuth2ClientService.getOAuth2ClientByClientId( "clientA" ) );
+ assertNotNull( oAuth2ClientService.getOAuth2ClientByClientId( "clientB" ) );
+ assertNotNull( oAuth2ClientService.getOAuth2ClientByClientId( "clientC" ) );
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientStoreTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/oauth2/OAuth2ClientStoreTest.java 2015-06-10 08:13:05 +0000
@@ -0,0 +1,94 @@
+package org.hisp.dhis.oauth2;
+
+/*
+ * 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 org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OAuth2ClientStoreTest
+ extends DhisSpringTest
+{
+ @Autowired
+ private OAuth2ClientStore oAuth2ClientStore;
+
+ private OAuth2Client clientA;
+
+ private OAuth2Client clientB;
+
+ private OAuth2Client clientC;
+
+ @Override
+ public void setUpTest()
+ {
+ clientA = new OAuth2Client();
+ clientA.setName( "clientA" );
+ clientA.setCid( "clientA" );
+
+ clientB = new OAuth2Client();
+ clientB.setName( "clientB" );
+ clientB.setCid( "clientB" );
+
+ clientC = new OAuth2Client();
+ clientC.setName( "clientC" );
+ clientC.setCid( "clientC" );
+ }
+
+ @Test
+ public void testGetAll()
+ {
+ oAuth2ClientStore.save( clientA );
+ oAuth2ClientStore.save( clientB );
+ oAuth2ClientStore.save( clientC );
+
+ Collection<OAuth2Client> all = oAuth2ClientStore.getAll();
+
+ assertEquals( 3, all.size() );
+ }
+
+ @Test
+ public void testGetByClientID()
+ {
+ oAuth2ClientStore.save( clientA );
+ oAuth2ClientStore.save( clientB );
+ oAuth2ClientStore.save( clientC );
+
+ assertNotNull( oAuth2ClientStore.getByClientId( "clientA" ) );
+ assertNotNull( oAuth2ClientStore.getByClientId( "clientB" ) );
+ assertNotNull( oAuth2ClientStore.getByClientId( "clientC" ) );
+ }
+}