2 * //******************************************************************
4 * // Copyright 2016 Samsung Electronics All Rights Reserved.
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * // Licensed under the Apache License, Version 2.0 (the "License");
9 * // you may not use this file except in compliance with the License.
10 * // You may obtain a copy of the License at
12 * // http://www.apache.org/licenses/LICENSE-2.0
14 * // Unless required by applicable law or agreed to in writing, software
15 * // distributed under the License is distributed on an "AS IS" BASIS,
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * // See the License for the specific language governing permissions and
18 * // limitations under the License.
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 package org.iotivity.cloud.accountserver;
24 import java.net.InetSocketAddress;
25 import java.util.Scanner;
27 import org.iotivity.cloud.accountserver.resources.account.AccountResource;
28 import org.iotivity.cloud.accountserver.resources.account.session.SessionResource;
29 import org.iotivity.cloud.accountserver.resources.account.tokenrefresh.TokenRefreshResource;
30 import org.iotivity.cloud.accountserver.resources.acl.group.GroupResource;
31 import org.iotivity.cloud.accountserver.resources.acl.id.AclResource;
32 import org.iotivity.cloud.accountserver.resources.acl.invite.InviteResource;
33 import org.iotivity.cloud.accountserver.resources.credprov.cert.CertificateResource;
34 import org.iotivity.cloud.accountserver.resources.credprov.crl.CrlResource;
35 import org.iotivity.cloud.base.ServerSystem;
36 import org.iotivity.cloud.base.server.CoapServer;
37 import org.iotivity.cloud.util.Log;
41 * This class is in charge of running of account server.
44 public class AccountServer {
46 public static void main(String[] args) throws Exception {
49 System.out.println("-----Account SERVER-----");
51 if (args.length != 2) {
52 Log.e("coap server port and TLS mode required\n" + "ex) 5685 0\n");
56 ServerSystem serverSystem = new ServerSystem();
58 serverSystem.addResource(new AccountResource());
60 serverSystem.addResource(new SessionResource());
62 serverSystem.addResource(new TokenRefreshResource());
64 serverSystem.addResource(new GroupResource());
66 serverSystem.addResource(new AclResource());
68 serverSystem.addResource(new CertificateResource());
70 serverSystem.addResource(new CrlResource());
72 serverSystem.addResource(new AclResource());
74 serverSystem.addResource(new InviteResource());
76 serverSystem.addServer(new CoapServer(
77 new InetSocketAddress(Integer.parseInt(args[0]))));
79 boolean tlsMode = Integer.parseInt(args[1]) == 1;
81 serverSystem.startSystem(tlsMode);
83 Scanner in = new Scanner(System.in, "UTF-8");
85 System.out.println("press 'q' to terminate");
87 while (!in.nextLine().equals("q"));
91 System.out.println("Terminating...");
93 serverSystem.stopSystem();
95 System.out.println("Terminated");