-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebService.java
More file actions
112 lines (74 loc) · 3.91 KB
/
WebService.java
File metadata and controls
112 lines (74 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
* WebService.java 1.0 Copyright Stefan Gsottbauer © 2015. all rights reserved
*
* @author: Stefan Gsottbauer
*/
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class WebService {
private final String mUserManagerServiceURL = "http://schule-dev.tugraz.at/usermanager/soap?wsdl";
private final int mAppId = **;
private final String mAppKey = "******************************************************";
public SoapObject isUserAllowed(String username, String password_hash) throws Exception {
SoapObject _client = new SoapObject("", "isUserAllowed");
_client.addProperty("username", username);
_client.addProperty("password", password_hash);
_client.addProperty("idApp", mAppId);
String hmac = username + password_hash + mAppId;
String hmac_hash = KryptoHelper.getHMAC(hmac, mAppKey, "HmacSHA256");
_client.addProperty("hmacClient", hmac_hash);
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
public SoapObject getID(String username) throws Exception {
SoapObject _client = new SoapObject("", "getID");
_client.addProperty("username", username);
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
public SoapObject getName(int idUser) throws Exception {
SoapObject _client = new SoapObject("", "getName");
_client.addProperty("idUser", idUser + "");
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
public SoapObject getRoles() throws Exception {
SoapObject _client = new SoapObject("", "getRoles");
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
public SoapObject getSchoolclasses(int idUser) throws Exception {
SoapObject _client = new SoapObject("", "getSchoolclasses");
_client.addProperty("idUser", idUser + "");
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
public SoapObject getStudentsToClass(int idSchoolclass) throws Exception {
SoapObject _client = new SoapObject("", "getSchoolclasses");
_client.addProperty("idSchoolclass", idSchoolclass + "");
SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
_envelope.bodyOut = _client;
HttpTransportSE androidHttpTransport = new HttpTransportSE(mUserManagerServiceURL);
androidHttpTransport.call("", _envelope);
return (SoapObject) _envelope.bodyIn;
}
}