2011年10月16日 星期日

[English] Difference among Image, Photo, Picture and Graphic

Photo
  • A photo is a picture taken with a camera.
  • Short for "Photograph".
  • Photo means 'light'. (?)

Picture
  • A picture is any visual representation of a subject.
  • A picture is usually something real.
  • Refers to a photo or drawing of something for art purposes

Image
  • An "image" is something generated or a representation of something in any other way.
  • All photos are images, but not all images are photos.

Graphic
  • A graphic is usually something drawn on a computer. realize that those terms are pretty broad and overlap a bit.
  • Sometimes a picture is a graphic and a graphic is a picture if you are using the terms loosely. Both of the two are still shots that happen at one point in time.
  • Work done for a company, occasion or event. ie, a logo.
  • Generally done on computers, and normally includes words or symbols

Animation
  • A collection of images, that rotate around like a movie, so only one is visible at a time, and is only shown for a short amount of time, like a movie


* Reference
- What is the difference between Image, Photo, and Picture? - Yahoo! Answers
- word choice - Difference between "picture" and "photo" - English Language and Usage - Stack Exchange
- word choice - What is the difference between "photo" and "image"? - English Language and Usage - Stack Exchange
- What's the difference between a picture, graphics and an animation? - Yahoo! Answers

[English] Difference between "day" and "date"

Day
Referring the seven days in a week: Sunday, Monday, and so on.

Date
Talking about what particular date of a month: 23rd of April, 1st of August, etc.


* Reference
- difference between "day" and "date" - UsingEnglish.com ESL Forum

[Security] SSL and HTTPS

[SSL]
  • Secure Socket Layer (安全套接層)。
  • 運行在TCP/IP層之上、應用層之下,與其繼任者傳輸層安全(TLS)是在網絡上為應用程序提供加密數據通道
  • 是網頁伺服器和瀏覽器之間以加解密方式溝通的安全技術標準,這個溝通過程確保了所有在伺服器與瀏覽器之間通過資料的私密性與完整性。
  • 採用了RC4、MD5以及RSA等加密算法。

Used for...
  • 確保 client 和 server 間的認證(網站身份認證)。
    • 因為 www 上充斥著假網站(釣魚網站)來騙取帳密,所以要驗證對方是真的。
  • 加密傳送資料,以防中途被竊取。
  • 維護數據的完整性,防範數據在傳送過程中被改變。

Process
  • 當瀏覽器端與 WWW 伺服器端同時支援 SSL 的傳輸協定時,在連線階段 SSL 同步確認 client 和 server,瀏覽器與伺服器就會產生那把的金鑰。
  • 產生金鑰後就能夠利用瀏覽器來傳送與接收加密過的重要資料啦。
  • 要注意的是,在某些很舊的瀏覽器上面是不支援 SSL 的。
  • Steps:
  1. Client request for server so start a new session. 告知伺服器端本身可實現的算法列表和其他一些需要的資訊。  
  2. Server 根據 client 的訊息確定是否要生成新的主密鑰,如果需要則 server 在 response 中包含生成主密鑰所需的資訊(資訊內包含身分及公鑰)。  
  3. client 根據收到的 response,產生一個密鑰,並用 server 的公鑰加密後傳給 server。(client 會自動的分析此證書,並根據不同版本的 browser,產生 40 位或 128 位的 session private key,用於加密傳送訊息。
  4. server 再用自己得私鑰解密得到 client 傳來的私鑰,並以私鑰加密要回傳的訊息,以讓 client 認證 server。




Problem
  • 那把 Public key 是伺服器產生且任何人都能取得的! ex:
    • 如果你不小心在釣魚網站輸入帳密,因為公鑰是誰都能拿到的,所以你的帳密還是被竊取,所以這時就需要第三方公正單位。

憑證
  • 可分為兩種:
    • 最低 40位和 128位 (private key 的長度,越長越不容破解)證書。
    • 最低 40位 server 證書在建立 session 時,根據 browser 版本不同,兩種都可以產生;而最低 128位 server 證書不受 browser 版本限制可以產生 128位以上的 private key,無論是 IE 或 Netscape,需要十年才能破解。
  • 一份 SSL 證書包含一個公鑰和一個私鑰。
    • 公鑰用於加密信息,私鑰用於解譯加密的信息。

CA
  • Certification Authority,認證中心。
  • 就是一個公認的公正單位,你可以自行產生一把金鑰且製作出必要的憑證資料並向 CA 單位註冊 (要錢的意思!),那麼當用戶端的瀏覽器在瀏覽時,該瀏覽器會主動的向 CA 單位確認該憑證是否為合法註冊過的:
    • 如果是的話,那麼該次連線才會建立。
    • 如果不是呢,那麼瀏覽器就會發出警告訊息, 告知使用者應避免建立連線啊。

Digital Signature
  • 在網路上﹐我們還可以使用“數位簽章(Digital Signature)”來進行身份確認。
  • 數位簽章可以說是一個獨一無二的數值﹐它由使用者的私有鍵值進行加密﹐然後利用公用鍵值進行確認
    • 若 public key 能通過驗證,那我們就肯定所對應的 private key 之正確性m
    • 否則,則可排除簽章所用的 private key 。
  • 換而言之,數位簽章兼具這兩種雙重屬性
    • 可確認性。
    • 不可抵賴性。


[HTTPS]
  • Secure Hyper Text Transfer Protocol (安全超文本傳輸協議)
  • Netscape公司相應開發了HTTPS協議並內置於其瀏覽器中。
  • 它是一個URI scheme(抽象識別字體系),https:URL表明它使用了HTTP,但HTTPS存在不同於HTTP的默認埠及一個加密/身份驗證層(在HTTP與TCP之間)。
  • HTTPS是以安全為目標的 HTTP通道,簡單講是HTTP的安全版,即HTTP下加入SSL層(因此加密的詳細內容請看SSL),實際上就是SSL over HTTP

HTTP vs. HTTPS

Advantages:
  • 所傳送的數據不容易被網絡黑客截獲和解密
    • 使用SSL在發送方把原始數據進行加密,然後在接受方進行解密,加密和解密需要發送方和接受方通過交換共知的密鑰來實現。

Disadvantages:
  • 耗效能
  • 加密和解密過程需要耗費系統大量的開銷,嚴重降低機器的性能,相關測試數據表明使用HTTPS協議傳輸數據的工作效率只有使用 HTTP協議傳輸的十分之一
    • 所以,我們只需對那些涉及機密數據如網上購物、交易付錢的交互處理、安全電子郵件等使用HTTPS協議,不需要用HTTPS 的地方,盡量不要用。

Overview


* Reference
- 小詞典: SSL和HTTPS
- 鳥哥的 Linux 私房菜 -- WWW 伺服器 Apache
- 加密網路封包鑑識設備
- 網路教學-資料加密
- SSL证书_百度百科
- https_百度百科
SSL和CA基礎知識
- 網站SSL加密原理簡介 ***

2011年10月15日 星期六

[Programming] Dev note

可以另外 export project 專門用來 build

apart build and editor projects

[JPA] Repeat fields

有重複 mapping 的欄位的話 只能有一個是可 insert 和 update 的

不然 JPA 不知道哪一個 attribute 才是要吃的值(不是取出時發生問題,是 set to db 的問題)

ex:
a attribute 跟 b attribute 都是 column "APP_ID"

存檔的時候,a 的值是 a ,b 的值是 b

它根本不知道要存 a 還是 b


[Note]

要存檔時是從物件呼叫 getter 塞給 db

setter 是從 db 取出來之後呼叫 setter 把值塞給物件

[Resources] not found for MessageSource

Error Message

main WARN org.springframework.context.support.ResourceBundleMessageSource.getResourceBundle(ResourceBundleMessageSource.java:223) - ResourceBundle [resource] not found for MessageSource: Can't find bundle for base name resource, locale en


Solution

因為找不到 properties file

一般應該要在 class 下

test case 中應和 configuration 放在同一層 否則要記得在 configuration 中要指定路徑。


[Note]

Sping test case 中指定 configuration 的 annotation:

@ContextConfiguration(locations = {"/applicationContext.xml"})


[SQL] ORA-00979: 不是一個 GROUP BY 表示式

Error Message

main WARN org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:233) - SQL Error: 979, SQLState: 42000
main ERROR org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:234) - ORA-00979: 不是一個 GROUP BY 表示式


Solution

做為 ORDER BY 的欄位

如果有使用到 GROUP BY 的話

那些欄位也要在 GROUP BY 中


2011年10月9日 星期日

[Java] Copying list to linkedList

Error Message

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 2, Size: 0

occurred when copying list to linkedList


Solution

[Java] List


Error Message

java.lang.UnsupportedOperationException
      at java.util.AbstractList.remove(AbstractList.java:144)
      at java.util.AbstractList$Itr.remove(AbstractList.java:360)
      at java.util.AbstractCollection.removeAll(AbstractCollection.java:337)

occurred when  using removeAll


Solution

[JPA] Join

JPA get attribute in another table will join that table.


[J2EE] JUnit with weblogic

junit 沒通過 weblogic, run on J2SE


[J2EE] Log

Exception e

logger.error("test message", e);

log:
[2011...] main (...A) - test message
(......B)

A: log4j 裡設定的 pattern
B: e's trace stack

[Design] SQL condition

若 A、B、C 都要限制條件 x

可以以外層條件來寫 A.x = B.x and A.x = C.x

這樣 value 只要寫一次就可以了

......

form A

join A.x = B.x and A.x = C.x

where A.x = 'value'


[SQL] condition order

執行順序如下:
  1. where
  2. group by
  3. having

where 會在 group by 前執行

having 在 group by 後才執行



[JSP] type of Map's key

Map autoboxing uses Integer as key; JSP EL uses Long.

That's why the following codes are not working, if key defined as "1":



    ....