예제 #1
0
파일: EMail.cs 프로젝트: bpaziaud/Hermod
        private EMail(IEnumerable <KeyValuePair <String, String> > MailHeader)
        {
            _Header = new List <KeyValuePair <String, String> >(MailHeader);

            foreach (var KVP in _Header)
            {
                switch (KVP.Key.ToLower())
                {
                case "from":       this.From = EMailAddress.Parse(KVP.Value); break;

                case "to":         this.To = EMailAddressList.Parse(KVP.Value); break;

                case "cc":         this.Cc = EMailAddressList.Parse(KVP.Value); break;

                case "bcc":        this.Bcc = EMailAddressList.Parse(KVP.Value); break;

                case "replyto":    this.ReplyTo = EMailAddressList.Parse(KVP.Value); break;

                case "subject":    this.Subject = KVP.Value; break;

                case "date":       this.Date = DateTime.Parse(KVP.Value); break;

                case "message-id": this.MessageId = MessageId.Parse(KVP.Value); break;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Create an instance of the OCPI HTTP API for Charge Point Operators
        /// using a newly created HTTP server.
        /// </summary>
        public CPOAPI(RoamingNetwork    RoamingNetwork,
                      String            HTTPServerName    = DefaultHTTPServerName,
                      IPPort            HTTPServerPort    = null,
                      String            URIPrefix         = "",

                      String            ServiceName       = DefaultHTTPServerName,
                      EMailAddress      APIEMailAddress   = null,
                      PgpSecretKeyRing  APISecretKeyRing  = null,
                      String            APIPassphrase     = null,
                      EMailAddressList  APIAdminEMail     = null,
                      SMTPClient        APISMTPClient     = null,

                      DNSClient         DNSClient         = null,
                      String            LogfileName       = DefaultLogfileName)
            : base(RoamingNetwork,
                   HTTPServerName,
                   HTTPServerPort != null ? HTTPServerPort : DefaultHTTPServerPort,
                   URIPrefix,
                   ResourceName => typeof(CPOAPI).Assembly.GetManifestResourceStream("org.GraphDefined.WWCP.OCPIv2_1.HTTPAPI.CPOAPI.HTTPRoot." + ResourceName),

                   ServiceName,
                   APIEMailAddress,
                   null,//OpenPGP.ReadPublicKeyRing(typeof(CPOAPI).Assembly.GetManifestResourceStream("org.GraphDefined.WWCP.OCPIv2_1.HTTPAPI.GenericAPI.HTTPRoot.robot@offenes-jena_pubring.gpg")),
                   APISecretKeyRing,
                   APIPassphrase,
                   APIAdminEMail,
                   APISMTPClient,

                   DNSClient,
                   LogfileName)
        {
            RegisterCPOURITemplates();
        }
예제 #3
0
파일: EMail.cs 프로젝트: bpaziaud/Hermod
        /// <summary>
        /// Create a new e-mail based on the given e-mail builder.
        /// </summary>
        /// <param name="MailBuilder">An e-mail builder.</param>
        public EMail(AbstractEMailBuilder MailBuilder)

            : this(MailBuilder.
                   EncodeBodyparts().
                   // Copy only everything which is not related to the e-mail body!
                   MailHeaders.Where(header => !header.Key.ToLower().StartsWith("content")).
                   Concat(MailBuilder.Body.MailHeaders))

        {
            //ToDo: Do a real deep-copy here!
            Body = MailBuilder.Body;

            //ToDo: Work-aroung for PGP/GPG!
            this.From = MailBuilder.From;
            this.To   = MailBuilder.To;
            this.Cc   = MailBuilder.Cc;
        }
예제 #4
0
        internal GenericAPI(RoamingNetwork        RoamingNetwork,
                            String                HTTPServerName          = DefaultHTTPServerName,
                            IPPort                HTTPServerPort          = null,
                            String                URIPrefix               = "",
                            Func<String, Stream>  GetRessources           = null,

                            String                ServiceName             = DefaultHTTPServerName,
                            EMailAddress          APIEMailAddress         = null,
                            PgpPublicKeyRing      APIPublicKeyRing        = null,
                            PgpSecretKeyRing      APISecretKeyRing        = null,
                            String                APIPassphrase           = null,
                            EMailAddressList      APIAdminEMail           = null,
                            SMTPClient            APISMTPClient           = null,

                            DNSClient             DNSClient               = null,
                            String                LogfileName             = DefaultLogfileName)
            : this(RoamingNetwork,
                   new HTTPServer(DefaultServerName: DefaultHTTPServerName).AttachTCPPorts(HTTPServerPort != null ? HTTPServerPort : DefaultHTTPServerPort),
                   URIPrefix,
                   GetRessources,

                   ServiceName,
                   APIEMailAddress,
                   APIPublicKeyRing,
                   APISecretKeyRing,
                   APIPassphrase,
                   APIAdminEMail,
                   APISMTPClient,

                   LogfileName)
        {
        }
예제 #5
0
        /// <summary>
        /// Initialize the OCPI HTTP server using IPAddress.Any, http port 8080 and maybe start the server.
        /// </summary>
        internal GenericAPI(RoamingNetwork        RoamingNetwork,
                            HTTPServer            HTTPServer,
                            String                URIPrefix               = "/ext/OCPI",
                            Func<String, Stream>  GetRessources           = null,

                            String                ServiceName             = DefaultHTTPServerName,
                            EMailAddress          APIEMailAddress         = null,
                            PgpPublicKeyRing      APIPublicKeyRing        = null,
                            PgpSecretKeyRing      APISecretKeyRing        = null,
                            String                APIPassphrase           = null,
                            EMailAddressList      APIAdminEMail           = null,
                            SMTPClient            APISMTPClient           = null,

                            String                LogfileName             = DefaultLogfileName)
        {
            #region Initial checks

            if (RoamingNetwork == null)
                throw new ArgumentNullException("RoamingNetwork", "The given parameter must not be null!");

            if (HTTPServer == null)
                throw new ArgumentNullException("HTTPServer", "The given parameter must not be null!");

            if (URIPrefix.IsNullOrEmpty())
                throw new ArgumentNullException("URIPrefix", "The given parameter must not be null or empty!");

            if (!URIPrefix.StartsWith("/"))
                URIPrefix = "/" + URIPrefix;

            #endregion

            #region Init data

            this._HTTPServer              = HTTPServer;
            this._GetRessources           = GetRessources;
            this._URIPrefix               = URIPrefix;

            this._ServiceName             = ServiceName;
            this._APIEMailAddress         = APIEMailAddress;
            this._APIPublicKeyRing        = APIPublicKeyRing;
            this._APISecretKeyRing        = APISecretKeyRing;
            this._APIPassphrase           = APIPassphrase;
            this._APIAdminEMail           = APIAdminEMail;
            this._APISMTPClient           = APISMTPClient;

            this._DNSClient               = HTTPServer.DNSClient;

            #endregion

            RegisterURITemplates();
        }
예제 #6
0
파일: EMail.cs 프로젝트: Vanaheimr/Hermod
        /// <summary>
        /// Create a new e-mail based on the given e-mail builder.
        /// </summary>
        /// <param name="MailBuilder">An e-mail builder.</param>
        public EMail(AbstractEMailBuilder MailBuilder)
            : this(MailBuilder.
                       EncodeBodyparts().
                       // Copy only everything which is not related to the e-mail body!
                       MailHeaders.Where(header => !header.Key.ToLower().StartsWith("content")).
                       Concat(MailBuilder.Body.MailHeaders))
        {
            //ToDo: Do a real deep-copy here!
            Body  = MailBuilder.Body;

            //ToDo: Work-aroung for PGP/GPG!
            this.From = MailBuilder.From;
            this.To   = MailBuilder.To;
            this.Cc   = MailBuilder.Cc;
        }
예제 #7
0
파일: EMail.cs 프로젝트: Vanaheimr/Hermod
        private EMail(IEnumerable<KeyValuePair<String, String>> MailHeader)
        {
            _Header = new List<KeyValuePair<String, String>>(MailHeader);

            foreach (var KVP in _Header)
            {

                switch (KVP.Key.ToLower())
                {

                    case "from":       this.From       = EMailAddress.    Parse(KVP.Value); break;
                    case "to":         this.To         = EMailAddressList.Parse(KVP.Value); break;
                    case "cc":         this.Cc         = EMailAddressList.Parse(KVP.Value); break;
                    case "bcc":        this.Bcc        = EMailAddressList.Parse(KVP.Value); break;
                    case "replyto":    this.ReplyTo    = EMailAddressList.Parse(KVP.Value); break;
                    case "subject":    this.Subject    =                        KVP.Value ; break;
                    case "date":       this.Date       = DateTime.        Parse(KVP.Value); break;
                    case "message-id": this.MessageId  = MessageId.       Parse(KVP.Value); break;

                }

            }
        }