Mobile Signature Server , which is written by using Mobile Signature Server API, connects to an MSSP server and makes mobile signature requests. For this purpose, it must take information such as the data to be signed, the operator , user phone number from the client and send the request to the MSSP accordingly.
The server can be web service which must have at least two methods that can be called by the clients. For clients to query their certificates , a certificate query method, taking the operator and the phone number as parameters, must be defined. The method must return the mobile signature certificate of the user.
The code segment below demonstrates a certificate query method.
<sxh java>
public String getUserCertificate(String phoneNumber,int iOperator)
{
Operator mobileOperator = fromInt(iOperator);
PhoneNumberAndOperator phoneNumberAndOperator = new PhoneNumberAndOperator(phoneNumber, mobileOperator);
MSSParams mobilParams = new MSSParams("http://MImzaTubitakBilgem", "********", "www.turkcelltech.com");
EMSSPRequestHandler msspRequestHandler = new EMSSPRequestHandler(mobilParams);
ECertificate[] eCertificates;
try {
eCertificates = msspRequestHandler.getCertificates(phoneNumberAndOperator);
} catch (Exception e) {
e.printStackTrace();
returnnull;
}
if1)
{
returnnull;
}
ECertificate eCert = eCertificates[0];
byte[] certBytes = eCert.getEncoded();
return Base64.encode(certBytes);
}
</sxh>
The second method that must be included in the service is signature creation method. This method must sign the data to be signed which is sent by the user and return the signature.
A sample service method which take the data to be signed in Base64 format, the signing message displayed on the user's mobile device, the phone number abd the operator as parameters can be implemented as follows:
<sxh java>
public String SignHash(String hashForSign64, String displayText,String phoneNumber, int iOperator)
{
Operator mobileOperator = fromInt(iOperator);
PhoneNumberAndOperator phoneNumberAndOperator = new PhoneNumberAndOperator(phoneNumber, mobileOperator);
MSSParams mobilParams = new MSSParams("http://MImzaTubitakBilgem", "*******", "www.turkcelltech.com");
EMSSPRequestHandler msspRequestHandler = new EMSSPRequestHandler(mobilParams);
byte[] dataForSign = Base64.decode(hashForSign64);
byte[] signedData;
try {
signedData = msspRequestHandler.sign(dataForSign,SigningMode.SIGNHASH, phoneNumberAndOperator, displayText, SignatureAlg.RSA_SHA1.getName(),null);
} catch (Exception e) {
e.printStackTrace();
returnnull;
}
return Base64.encode(signedData);
}
</sxh>