|
@@ -121,18 +121,40 @@ namespace OCPPServer.Protocol
|
|
|
authorizated = false;
|
|
|
}
|
|
|
|
|
|
- if (session.Items.ContainsKey("Authorization"))
|
|
|
+ if (session.Items.ContainsKey("Authorization") || session.Items.ContainsKey("authorization"))
|
|
|
{
|
|
|
+
|
|
|
+ using (var db = new MainDBContext())
|
|
|
+ {
|
|
|
+
|
|
|
+ authorizationKey = db.MachineConfiguration.Where(x => x.ChargeBoxId == session.ChargeBoxId && x.ConfigureName == StandardConfiguration.AuthorizationKey)
|
|
|
+ .Select(x => x.ConfigureSetting).FirstOrDefault();
|
|
|
+
|
|
|
|
|
|
+ if (session.ISOCPP20)
|
|
|
+ {
|
|
|
+ // 1.6 server only support change server function
|
|
|
+ securityProfile = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.Info("***********Authorization ");
|
|
|
|
|
|
- string base64Encoded = session.Items["Authorization"].ToString().Replace("Basic ", "");
|
|
|
- byte[] data = Convert.FromBase64String(base64Encoded);
|
|
|
- string[] base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data).Split(':');
|
|
|
- if (base64Decoded.Count() == 2 && base64Decoded[0] == session.ChargeBoxId && base64Decoded[1] == authorizationKey)
|
|
|
+ if (!string.IsNullOrEmpty(authorizationKey))
|
|
|
{
|
|
|
- authorizated = true;
|
|
|
+ string base64Encoded = session.Items.ContainsKey("Authorization") ? session.Items["Authorization"].ToString().Replace("Basic ", "") : session.Items["authorization"].ToString().Replace("Basic ", "");
|
|
|
+ byte[] data = Convert.FromBase64String(base64Encoded);
|
|
|
+ string[] base64Decoded = System.Text.ASCIIEncoding.ASCII.GetString(data).Split(':');
|
|
|
+ logger.Info("***********Authorization " + System.Text.ASCIIEncoding.ASCII.GetString(data));
|
|
|
+ if (base64Decoded.Count() == 2 && base64Decoded[0] == session.ChargeBoxId && base64Decoded[1] == authorizationKey)
|
|
|
+ {
|
|
|
+ authorizated = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|