function initPredefinedSecurity() {
//alert('in initPredefinedSecurity');
serverInfo = new ServerInfo();
serverInfo.server = 'https://'+window.location.hostname+'/arcgis03';
serverInfo.tokenServiceUrl = 'https://'+window.location.hostname+'/arcgis03/tokens/generateToken';
serverInfo.shortLivedTokenValidity = 720;
esri.id.registerServers([serverInfo]);
//add your own password
var def = esri.id.generateToken(serverInfo, {"username": "util", "password": ""});
def.addCallback(lang.hitch(this, function (tokenInfo) {
//get token creation time in epoch
var creationTime = (new Date).getTime();
//calculate the token expiration based on short lived token validity
var expirationTime = creationTime + (serverInfo.shortLivedTokenValidity * 60000);
//create array of secured services
var idObject ={};
idObject.serverInfos= [serverInfo];
var credentials={};
credentials.userId = "util";
credentials.server = "https://"+window.location.hostname+"/arcgis03";
credentials.token = tokenInfo.token;
credentials.expires = expirationTime;
credentials.ssl = false;
credentials.scope = "server";
credentials.validity = 720;
credentials.creationTime = creationTime;
idObject.credentials = [credentials];
//credential object is correct
esri.id.initialize(idObject);
// now create map
initMap();
}));
};