IOT-3234 Add support for new sec URI in AS 53/27553/1
authorPeter Rafaj <peter.rafaj@kistler.com>
Fri, 23 Nov 2018 11:57:46 +0000 (12:57 +0100)
committerPeter Rafaj <peter.rafaj@kistler.com>
Fri, 23 Nov 2018 11:58:16 +0000 (12:58 +0100)
Change-Id: I1a851e83c2570c736be2b3c7a2172337f8520271
Signed-off-by: Peter Rafaj <peter.rafaj@kistler.com>
14 files changed:
cloud/account/src/main/java/org/iotivity/cloud/accountserver/AccountServer.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/AccountResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/SecAccountResource.java [new file with mode: 0644]
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/session/SecSessionResource.java [new file with mode: 0644]
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/session/SessionResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/tokenrefresh/SecTokenRefreshResource.java [new file with mode: 0644]
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/tokenrefresh/TokenRefreshResource.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/CloudInterfaceServer.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/DeviceServerSystem.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/Account.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/AccountSession.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccount.java [new file with mode: 0644]
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccountSession.java [new file with mode: 0644]
cloud/stack/src/main/java/org/iotivity/cloud/base/OICConstants.java

index d4318ac..6beea9c 100644 (file)
@@ -25,6 +25,9 @@ import java.net.InetSocketAddress;
 import java.util.Scanner;
 import java.util.concurrent.TimeUnit;
 
+import org.iotivity.cloud.accountserver.resources.account.SecAccountResource;
+import org.iotivity.cloud.accountserver.resources.account.session.SecSessionResource;
+import org.iotivity.cloud.accountserver.resources.account.tokenrefresh.SecTokenRefreshResource;
 import org.iotivity.cloud.base.healthcheck.HealthHolder;
 import org.iotivity.cloud.base.healthcheck.SimpleHealthHolder;
 import org.iotivity.cloud.base.server.SimpleHttpServer;
@@ -82,6 +85,11 @@ public class AccountServer {
         serverSystem.addResource(new AclResource());
         serverSystem.addResource(new InviteResource());
 
+        //change in version 2.0.0
+        serverSystem.addResource(new SecAccountResource());
+        serverSystem.addResource(new SecTokenRefreshResource());
+        serverSystem.addResource(new SecSessionResource());
+
         serverSystem.addServer(
                 new CoapServer(new InetSocketAddress(coapServerPort)));
 
index 53358fe..7ee11d4 100644 (file)
@@ -56,7 +56,10 @@ public class AccountResource extends Resource {
 
     public AccountResource() {
         super(Arrays.asList(Constants.PREFIX_OIC, Constants.ACCOUNT_URI));
+    }
 
+    public AccountResource(final List<String> pathSegments) {
+        super(pathSegments);
     }
 
     @Override
diff --git a/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/SecAccountResource.java b/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/SecAccountResource.java
new file mode 100644 (file)
index 0000000..3883836
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed 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.iotivity.cloud.accountserver.resources.account;
+
+import org.iotivity.cloud.accountserver.Constants;
+
+import java.util.Arrays;
+
+/**
+ *
+ * This class provides a set of APIs to manage resources corresponding with user
+ * account. Version. 2.0.0
+ *
+ */
+public class SecAccountResource extends AccountResource {
+
+    public SecAccountResource() {
+        super(Arrays.asList(Constants.PREFIX_OIC, Constants.SEC_URI ,Constants.ACCOUNT_URI));
+    }
+}
diff --git a/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/session/SecSessionResource.java b/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/session/SecSessionResource.java
new file mode 100644 (file)
index 0000000..8ba8f9b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed 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.iotivity.cloud.accountserver.resources.account.session;
+
+import org.iotivity.cloud.accountserver.Constants;
+
+import java.util.Arrays;
+
+/**
+ *
+ * This class provides a set of APIs to handle sign-in/sign-out requests for. Version 2.0.0
+ *
+ */
+
+public class SecSessionResource extends SessionResource {
+
+    public SecSessionResource() {
+        super(Arrays.asList(Constants.PREFIX_OIC, Constants.SEC_URI,
+                Constants.SESSION_URI));
+    }
+}
index f2d6763..163a359 100644 (file)
@@ -23,6 +23,7 @@ package org.iotivity.cloud.accountserver.resources.account.session;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.resources.account.AccountManager;
@@ -54,6 +55,10 @@ public class SessionResource extends Resource {
                 Constants.SESSION_URI));
     }
 
+    public SessionResource(List<String> pathSegments) {
+        super(pathSegments);
+    }
+
     @Override
     public void onDefaultRequestReceived(Device srcDevice, IRequest request)
             throws ServerException {
diff --git a/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/tokenrefresh/SecTokenRefreshResource.java b/cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/tokenrefresh/SecTokenRefreshResource.java
new file mode 100644 (file)
index 0000000..1743e2b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed 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.iotivity.cloud.accountserver.resources.account.tokenrefresh;
+
+import org.iotivity.cloud.accountserver.Constants;
+
+import java.util.Arrays;
+
+/**
+ *
+ * This class provides a set of APIs to handle token refresh requests. Version 2.0.0
+ *
+ */
+
+public class SecTokenRefreshResource extends TokenRefreshResource {
+
+    public SecTokenRefreshResource() {
+        super(Arrays.asList(Constants.PREFIX_OIC, Constants.SEC_URI,
+                Constants.TOKEN_REFRESH_URI));
+    }
+}
index d189ccf..fac1e76 100644 (file)
@@ -23,6 +23,7 @@ package org.iotivity.cloud.accountserver.resources.account.tokenrefresh;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.resources.account.AccountManager;
@@ -54,6 +55,10 @@ public class TokenRefreshResource extends Resource {
                 Constants.TOKEN_REFRESH_URI));
     }
 
+    public TokenRefreshResource(List<String> pathSegments) {
+        super(pathSegments);
+    }
+
     @Override
     public void onDefaultRequestReceived(Device srcDevice, IRequest request)
             throws ServerException {
index c13b37c..4ec1fa4 100644 (file)
@@ -25,6 +25,7 @@ import java.net.InetSocketAddress;
 import java.util.Scanner;
 
 import org.iotivity.cloud.ciserver.resources.UpdateDeviceStateListener;
+import org.iotivity.cloud.ciserver.resources.proxy.account.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.connector.ConnectorPool;
@@ -34,13 +35,6 @@ import org.iotivity.cloud.base.server.WebSocketServer;
 import org.iotivity.cloud.ciserver.DeviceServerSystem.CoapDevicePool;
 import org.iotivity.cloud.ciserver.resources.KeepAliveResource;
 import org.iotivity.cloud.ciserver.resources.RouteResource;
-import org.iotivity.cloud.ciserver.resources.proxy.account.Account;
-import org.iotivity.cloud.ciserver.resources.proxy.account.AccountSession;
-import org.iotivity.cloud.ciserver.resources.proxy.account.Acl;
-import org.iotivity.cloud.ciserver.resources.proxy.account.AclGroup;
-import org.iotivity.cloud.ciserver.resources.proxy.account.AclInvite;
-import org.iotivity.cloud.ciserver.resources.proxy.account.Certificate;
-import org.iotivity.cloud.ciserver.resources.proxy.account.Crl;
 import org.iotivity.cloud.ciserver.resources.proxy.mq.MessageQueue;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.DevicePresence;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceDirectory;
@@ -111,6 +105,13 @@ public class CloudInterfaceServer {
         Crl crlHandler = new Crl();
         CoapDevicePool devicePool = deviceServer.getDevicePool();
 
+        //version 2.0.0
+        SecAccount secAcHandler = new SecAccount();
+        SecAccountSession secAcSessionHandler = new SecAccountSession();
+        deviceServer.addResource(secAcHandler);
+        deviceServer.addResource(secAcSessionHandler);
+
+
         deviceServer.addResource(acHandler);
 
         deviceServer.addResource(acSessionHandler);
index da16b98..aaa278d 100644 (file)
@@ -233,6 +233,7 @@ public class DeviceServerSystem extends ServerSystem {
 
                 switch (urlPath) {
                     case OICConstants.ACCOUNT_SESSION_FULL_URI:
+                    case OICConstants.SEC_ACCOUNT_SESSION_FULL_URI:
                         final Device device = ctx.channel()
                                 .attr(keyDevice).get();
                         if(device.existParameter(LOGOUT_DEVICE)){
@@ -241,6 +242,7 @@ public class DeviceServerSystem extends ServerSystem {
                         }
                         break;
                     case OICConstants.ACCOUNT_FULL_URI:
+                    case OICConstants.SEC_ACCOUNT_FULL_URI:
                         if (response.getStatus() == ResponseStatus.DELETED) {
                             bCloseConnection = true;
                         }
@@ -377,6 +379,7 @@ public class DeviceServerSystem extends ServerSystem {
                      */
 
                     case OICConstants.ACCOUNT_SESSION_FULL_URI:
+                    case OICConstants.SEC_ACCOUNT_SESSION_FULL_URI:
                         HashMap<String, Object> payloadData = mCbor
                                 .parsePayloadFromCbor(response.getPayload(),
                                         HashMap.class);
@@ -435,8 +438,10 @@ public class DeviceServerSystem extends ServerSystem {
                 switch (urlPath) {
                     // Check whether request is about account
                     case OICConstants.ACCOUNT_FULL_URI:
-                    case OICConstants.ACCOUNT_TOKENREFRESH_FULL_URI:
+                    case OICConstants.SEC_ACCOUNT_FULL_URI:
 
+                    case OICConstants.ACCOUNT_TOKENREFRESH_FULL_URI:
+                    case OICConstants.SEC_ACCOUNT_TOKENREFRESH_FULL_URI:
                         if (ctx.channel().attr(keyDevice).get() == null) {
                             // Create device first and pass to upperlayer
                             Device device = new CoapDevice(ctx);
@@ -446,7 +451,7 @@ public class DeviceServerSystem extends ServerSystem {
                         break;
 
                     case OICConstants.ACCOUNT_SESSION_FULL_URI:
-
+                    case OICConstants.SEC_ACCOUNT_SESSION_FULL_URI:
                         HashMap<String, Object> authPayload = mCbor
                                 .parsePayloadFromCbor(request.getPayload(),
                                         HashMap.class);
index 1d40572..c1ba728 100644 (file)
@@ -22,6 +22,7 @@
 package org.iotivity.cloud.ciserver.resources.proxy.account;
 
 import java.util.Arrays;
+import java.util.List;
 
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.device.Device;
@@ -49,6 +50,10 @@ public class Account extends Resource {
         super(Arrays.asList(Constants.PREFIX_OIC, Constants.ACCOUNT_URI));
     }
 
+    public Account(List<String> pathSegments) {
+        super(pathSegments);
+    }
+
     class RDReceiveHandler implements IResponseEventHandler {
 
         private Device    mSrcDevice;
index 2d80e8b..8165c57 100644 (file)
@@ -23,6 +23,7 @@ package org.iotivity.cloud.ciserver.resources.proxy.account;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.device.Device;
@@ -50,6 +51,10 @@ public class AccountSession extends Resource {
                 Constants.SESSION_URI));
     }
 
+    public AccountSession(List<String> pathSegments) {
+        super(pathSegments);
+    }
+
     @Override
     public void onDefaultRequestReceived(Device srcDevice, IRequest request)
             throws ServerException {
diff --git a/cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccount.java b/cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccount.java
new file mode 100644 (file)
index 0000000..0ab9f44
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed 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.iotivity.cloud.ciserver.resources.proxy.account;
+
+import org.iotivity.cloud.ciserver.Constants;
+
+import java.util.Arrays;
+
+/**
+ *
+ * This class provides a set of APIs to send requests about account to account. Version 2.0.0
+ *
+ */
+
+public class SecAccount extends Account {
+
+    public SecAccount() {
+        super(Arrays.asList(Constants.PREFIX_OIC, Constants.SEC_URI, Constants.ACCOUNT_URI));
+    }
+
+}
diff --git a/cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccountSession.java b/cloud/interface/src/main/java/org/iotivity/cloud/ciserver/resources/proxy/account/SecAccountSession.java
new file mode 100644 (file)
index 0000000..800ad00
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed 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.iotivity.cloud.ciserver.resources.proxy.account;
+
+import org.iotivity.cloud.base.connector.ConnectorPool;
+import org.iotivity.cloud.base.device.Device;
+import org.iotivity.cloud.base.exception.ServerException;
+import org.iotivity.cloud.base.protocols.IRequest;
+import org.iotivity.cloud.base.protocols.MessageBuilder;
+import org.iotivity.cloud.base.protocols.enums.ContentFormat;
+import org.iotivity.cloud.base.resource.Resource;
+import org.iotivity.cloud.ciserver.Constants;
+import org.iotivity.cloud.ciserver.DeviceServerSystem;
+import org.iotivity.cloud.util.Cbor;
+
+import java.util.Arrays;
+import java.util.HashMap;
+
+/**
+ *
+ * This class provides a set of APIs to send requests about session to account. Version 2.0.0
+ *
+ */
+
+public class SecAccountSession extends AccountSession {
+
+    public SecAccountSession() {
+        super(Arrays.asList(Constants.PREFIX_OIC, Constants.SEC_URI,
+                Constants.SESSION_URI));
+    }
+}
\ No newline at end of file
index f230829..b62b6a4 100644 (file)
@@ -53,6 +53,7 @@ public class OICConstants {
 
     public static final String CERT_URI                      = "cert";
 
+    public static final String SEC_URI                       = "sec";
     /* resource url for acl */
     public static final String ACL_URI                       = "acl";
 
@@ -101,6 +102,9 @@ public class OICConstants {
     public static final String ACCOUNT_FULL_URI              = "/"
             + OICConstants.PREFIX_OIC + "/" + OICConstants.ACCOUNT_URI;
 
+    public static final String SEC_ACCOUNT_FULL_URI              = "/"
+            + OICConstants.PREFIX_OIC + "/" + OICConstants.SEC_URI + "/" + OICConstants.ACCOUNT_URI;
+
     public static final String ACCOUNT_SEARCH_FULL_URI       = "/"
             + OICConstants.PREFIX_OIC + "/" + OICConstants.ACCOUNT_URI + "/"
             + OICConstants.SEARCH_URI;
@@ -109,9 +113,15 @@ public class OICConstants {
             + OICConstants.PREFIX_OIC + "/" + OICConstants.ACCOUNT_URI + "/"
             + OICConstants.SESSION_URI;
 
+    public static final String SEC_ACCOUNT_SESSION_FULL_URI      = "/"
+            + OICConstants.PREFIX_OIC + "/" + OICConstants.SEC_URI + "/"
+            + OICConstants.SESSION_URI;
+
     public static final String ACCOUNT_TOKENREFRESH_FULL_URI = "/"
-            + OICConstants.PREFIX_OIC + "/" + OICConstants.ACCOUNT_URI + "/"
-            + OICConstants.TOKEN_REFRESH_URI;
+            + OICConstants.PREFIX_OIC + "/" + OICConstants.ACCOUNT_URI + "/" + OICConstants.TOKEN_REFRESH_URI;
+
+    public static final String SEC_ACCOUNT_TOKENREFRESH_FULL_URI = "/"
+            + OICConstants.PREFIX_OIC + "/" + OICConstants.SEC_URI + "/" + OICConstants.TOKEN_REFRESH_URI;
 
     public static final String ACL_ID_FULL_URI               = "/"
             + OICConstants.PREFIX_OIC + "/" + OICConstants.ACL_URI + "/"