Commit 5ba3e9af authored by Peter Rafaj's avatar Peter Rafaj

IOT-3234 Add support for new sec URI in AS

Change-Id: I1a851e83c2570c736be2b3c7a2172337f8520271
Signed-off-by: default avatarPeter Rafaj <peter.rafaj@kistler.com>
parent 2001b751
......@@ -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)));
......
......@@ -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
......
/*
* //******************************************************************
* //
* // 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));
}
}
/*
* //******************************************************************
* //
* // 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));
}
}
......@@ -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 {
......
/*
* //******************************************************************
* //
* // 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));
}
}
......@@ -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 {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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 {
......
/*
* //******************************************************************
* //
* // 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));
}
}
/*
* //******************************************************************
* //
* // 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
......@@ -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 + "/"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment