Authentication
Authentication 은 HSP 에서 기본으로 제공하는 API로 별도의 설정 없이 사용 가능하다.
Authentication는 허브와 HSP 간 동작 예제를 위해 만들어졌으며 사용자는 이 코드를 이용해 허브와 통신하는 데이터 구조와 헤더 정보등을 파악할 수 있다.
doLogin
doLogin 은 허브에 사용자 아이디와 사용자 비밀번호를 전달 하여 로그인을 요청하고 결과로 AuthToken 을 전달 받는다.
Example
///////////////
// 3.10.18 이상
///////////////
let network = DAPNetwork()
let param = DAPAuthenticationLoginParam()
param.typeName = "dologin"
param.context = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["username":"jim", "password":"jim"]
param.message = ["header": ["a":"a"], "payload":payloadDict]
network.execute(with: param, completion: { (dict) in
}) { (resultError) in
}
///////////////
// 3.10.18 이하
///////////////
let network = DAPNetwork()
let contextDict = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["username":"jim", "password":"jim"]
let messageDict = ["header": ["a":"a"], "payload":payloadDict]
let dictInfo = ["context": contextDict, "message":messageDict] as [String : Any]
let params = [dictInfo] as [Any]
network.execute(withActionName: "doLogin", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}) { (resultError) in
guard let error = resultError else {
return
}
}
// 3.10.18 이상
///////////////
let network = DAPNetwork()
let param = DAPAuthenticationLoginParam()
param.typeName = "dologin"
param.context = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["username":"jim", "password":"jim"]
param.message = ["header": ["a":"a"], "payload":payloadDict]
network.execute(with: param, completion: { (dict) in
}) { (resultError) in
}
///////////////
// 3.10.18 이하
///////////////
let network = DAPNetwork()
let contextDict = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["username":"jim", "password":"jim"]
let messageDict = ["header": ["a":"a"], "payload":payloadDict]
let dictInfo = ["context": contextDict, "message":messageDict] as [String : Any]
let params = [dictInfo] as [Any]
network.execute(withActionName: "doLogin", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}) { (resultError) in
guard let error = resultError else {
return
}
}
///////////////
// 3.10.18 이상
///////////////
DAPNetwork *network = [DAPNetwork new];
DAPAuthenticationLoginParam *loginParam = [DAPAuthenticationLoginParam new];
loginParam.typeName = @"dologin";
loginParam.context = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"login", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionaryWithObjectsAndKeys:@"jim", @"username", @"jim", @"password", nil];
loginParam.message = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
[network executeWithParam:loginParam completion:^(NSDictionary *resultDict) {
} failure:^(NSError *error) {
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPNetwork new];
NSDictionary *contextDict = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"login", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionaryWithObjectsAndKeys:@"jim", @"username", @"jim", @"password", nil];
NSDictionary *messageDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:contextDict, @"context", messageDict, @"message", nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"doLogin" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPNetwork *network = [DAPNetwork new];
DAPAuthenticationLoginParam *loginParam = [DAPAuthenticationLoginParam new];
loginParam.typeName = @"dologin";
loginParam.context = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"login", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionaryWithObjectsAndKeys:@"jim", @"username", @"jim", @"password", nil];
loginParam.message = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
[network executeWithParam:loginParam completion:^(NSDictionary *resultDict) {
} failure:^(NSError *error) {
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPNetwork new];
NSDictionary *contextDict = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"login", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionaryWithObjectsAndKeys:@"jim", @"username", @"jim", @"password", nil];
NSDictionary *messageDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:contextDict, @"context", messageDict, @"message", nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"doLogin" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
doLogout
doLogout 은 허브에 로그인하여 전달 받은 AuthToken 을 삭제 하고 로그아웃 정보를 서버에 전달 한다.
Example
///////////////
// 3.10.18 이상
///////////////
let network = DAPNetwork()
let param = DAPAuthenticationLogoutParam()
param.typeName = "dologout"
param.context = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"logout"]
let payloadDict = ["":""]
param.message = ["header": ["":""], "payload":payloadDict]
network.execute(with: param, completion: { (dict) in
}) { (resultError) in
}
///////////////
// 3.10.18 이하
///////////////
let network = DAPNetwork()
let contextDict = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["":"",]
let messageDict = ["header": ["":""], "payload":payloadDict]
let dictInfo = ["context": contextDict, "message":messageDict] as [String : Any]
let params = [dictInfo] as [Any]
network.execute(withActionName: "doLogout", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}) { (resultError) in
guard let error = resultError else {
return
}
}
// 3.10.18 이상
///////////////
let network = DAPNetwork()
let param = DAPAuthenticationLogoutParam()
param.typeName = "dologout"
param.context = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"logout"]
let payloadDict = ["":""]
param.message = ["header": ["":""], "payload":payloadDict]
network.execute(with: param, completion: { (dict) in
}) { (resultError) in
}
///////////////
// 3.10.18 이하
///////////////
let network = DAPNetwork()
let contextDict = ["targetName":"hub1", "serviceCategory":"default", "serviceName":"login"]
let payloadDict = ["":"",]
let messageDict = ["header": ["":""], "payload":payloadDict]
let dictInfo = ["context": contextDict, "message":messageDict] as [String : Any]
let params = [dictInfo] as [Any]
network.execute(withActionName: "doLogout", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}) { (resultError) in
guard let error = resultError else {
return
}
}
///////////////
// 3.10.18 이상
///////////////
DAPNetwork *network = [DAPNetwork new];
DAPAuthenticationLogoutParam *param = [DAPAuthenticationLogoutParam new];
param.typeName = @"dologout";
param.context = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"logout", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionary];
param.message = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
[network executeWithParam:param completion:^(NSDictionary *resultDict) {
} failure:^(NSError *error) {
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPNetwork new];
NSDictionary *contextDict = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"logout", @"serviceName", nil];
NSDictionary *messageDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", [NSDictionary dictionary], @"payload", nil];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:contextDict, @"context", messageDict, @"message", nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"doLogout" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPNetwork *network = [DAPNetwork new];
DAPAuthenticationLogoutParam *param = [DAPAuthenticationLogoutParam new];
param.typeName = @"dologout";
param.context = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"logout", @"serviceName", nil];
NSDictionary *payloadDict = [NSDictionary dictionary];
param.message = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", payloadDict, @"payload", nil];
[network executeWithParam:param completion:^(NSDictionary *resultDict) {
} failure:^(NSError *error) {
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPNetwork new];
NSDictionary *contextDict = [NSDictionary dictionaryWithObjectsAndKeys:@"hub1", @"targetName", @"default", @"serviceCategory", @"logout", @"serviceName", nil];
NSDictionary *messageDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSDictionary dictionary], @"header", [NSDictionary dictionary], @"payload", nil];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:contextDict, @"context", messageDict, @"message", nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"doLogout" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];