Posted by '김용환'
,
 

흑 멋있어~ 이런 통찰있는 글 쓰고 파 

'java core' 카테고리의 다른 글

multipool / 웹 미들웨어 조사  (0) 2009.02.06
JVM Tiered Compiler (또는 compilations)  (0) 2009.02.04
FreeMarker 바로 간단 사용하기  (0) 2008.12.31
method Inlining (JVM)  (0) 2008.11.11
메모리 덤프 뜨기  (0) 2008.09.23
Posted by '김용환'
,

사용예는 freemarket 공식 홈페이지보다 이게 더 나은 것 같음...

 

출처

http://www.mimul.com/pebble/default/2007/02/12/1171290600000.html

 

 

FreeMarker는 Velocity와 마찬가지로 templating 언어이다.
우리가 Jsp를 코딩하다보면 날코딩으로 생산성이 떨어진다. 그래서 우리는 좀더 편리하게 사용하기위해서 템플릿 엔진을 사용한다.
그리고 가장 큰 장점은 아래의 1번에서 보듯이 매크로 기능으로 기능을 만들어서 사용할 수 있다는 점이다.
다음은 FreeMarker의 사용 방법을 기술했다.

1. @macro
 - 프리마커 템플릿 전역에서 공통으로 사용되는 UI 디펜던트한 함수는 매크로로 만들어 여러 ftl에서 사용할 수 있도록 해준다. 샘플을 참고하도록 한다.
 - 형식 : <@매크로명 변수1, 변수2, ... />
 - 샘플1) 긴 문자열을 적당한 크기로 자르는 기능의 매크로
   *사용법 : <@trimX ${item.title}, 20 />
   *매크로 :
   <#macro trimX src max><#compress>
   <#if src?length &gt; max>
      ${src[0..max-1]}..
   <#else>
      ${src}
    </#if>
   </#compress></#macro>

 - 샘플2) YYYYMMDD 형식의 문자열을 YYYY.MM.DD 형식으로 변환하는 매크로
   *사용법 : <@parseDay ${item.regdate} />
   *매크로 :
   <#macro parseDay src><#compress>
   <#if src?length == 8>
        ${src[0..3]}.${src[4..5]?number}.${src[6..7]?number}
   <#else>
      ${src}
    </#if>
   </#compress></#macro>

2. #list
 - 배열 형식의 오브젝트를 루핑 처리할때 사용하는 프리마커 지시자이다. “로컬엘리어스_index” 라는 변수는 0부터 시작하는 시퀀스번호이다.
 - 형식 : <#list 배열객체 as 로컬엘리어스명></#list>
 - 샘플1)
   <#list LIST as item>
      번호 : ${item_index+1} | 이름 : ${item.name} | 아이디 : ${item.id}
   </#list>

3. #if
 - 프리마커 조건문에 사용되는 지시자이다.
 - 형식 : <#if 조건식></#if>
 - 샘플1) string 비교
   <#if ENTITY.usergrade == “A” >......</#if>
 - 샘플2) number 비교
   <#if ENTITY.userclass?number == 3>.....</#if>
 - 샘플3) boolean 비교
   <#if ENTITY.isAuth()>.....</#if>

4. #break
 - Loop문을 중단하고 다음 스크립트로 넘어가려고 할때 사용되는 지시자이다.
 - 형식 : <#break>
 - 샘플1) 루프문을 실행하는 중 5번째에서 escape 하는 예
 <#list LIST as item>
  <#if item_index &gt; 3><#break></#if>
 </#list>

5. #assign
 - 프리마커내에서 사용자 정의 로컬변수가 필요할 때 사용하는 지시자이다.
 - 형식 : <#assign 로컬변수명 = 초기화값>
 - 샘플1) <#assign CHECK = item_index>

6. [x...y]
 - 문자열의 일정 범위를 자를때 사용하는 함수
 - 형식 : ${문자열[1..5]}
 - 샘플1) ${item.name[1..5]}

7. ?has_content
 - 리스트형 오브젝트가 null이 아니고 최소 1개 이상의 컨텐츠를 가지고 있는지 체크하는함수로써 ?has_content는 ?exists와 ?size>0 두가지 체크를 동시에 해주는 함수이다.
 - 형식 : 리스트오브젝트?has_content
 - 샘플1) <#if LIST?has_content>.....</#if>

8. ?exists
 - NULL체크 함수. if_exists는 <#if 지시자 없이도 사용할 수 있게 해주는 표현식이다.
 - 형식 : 오브젝트?exists
 - 샘플1) <#if ENTITY.username?exists>${ENTITY.username?substring(0, 5)}</#if>
 - 샘플2) <#if LIST?exists && LIST?size &gt; 0>.....</#if>
 - 샘플3) ${ENTITY.username?if_exists}

9. ?default
 - NULL값을 대체해주는 함수
 - 형식 : 오브젝트?default(디폴트값)
 - 샘플1) ${item.userclass?default(“99”)}
 - 샘플2) ${item.age?default(20)}

10. ?string
 - 문자열로 형변환하는 함수
 - 형식 : 오브젝트?string
 - 샘플1) <#if item.age?string == “29”>.....</#if>
 - 샘플2) ${item.regdate?string(“yyyy/MM/dd HH:mm”)}
 - 샘플3) 숫자를 통화표시로 나타내는 예
  <#assign MONEY = 1234567>
  ${MONEY?string(",##0")}

11. ?number
 - 숫자로 형변환하는 함수
 - 형식 : 오브젝트?number
 - 샘플1) <#if item.userclass?number &gt; 3>.....</#if>
 - 샘플2) ${LIST_POINTS[item.gid?number].entityname?default(“”)}

12. ?js_string
 - 문자열을 자바스크립트에 유효하도록 필터링해주는 함수. 문자열내에 싱글쿼테이션(‘)등이 포함되어 스크립트에 오류가 나는것을 방지하기 위하여 사용되는 함수이다. 화면상에는 HTML 태그로 취급된다.
 - 형식 : 오브젝트?js_string
 - 샘플1) 문자열 <img src=’/image/enterprise.gif’>을 js_string으로 처리했을때 소스보기를 하면 <img src=\’/image/enterprise.gif\’>으로 출력된다.
 - 샘플2) <a href=”javascript:getName(‘${item.homeurl?js_string}’);”>

13. ?html
 - 문자열을 HTML Symbolic Entity로 필터링해주는 함수. 문자열내의 HTML태그등을 깨뜨려 화면상으로 출력되도록 할때 사용하는 함수이다. 화면상에 HTML태그가 아닌 일반 문자열로 취급된다.
 - 형식 : 오브젝트?html
 - 샘플1) 문자열 <img src=’/image/enterprise.gif’>을 html로 처리하면 화면상에 <img src=’/image/enterprise.gif’> 로 출력되고 소스보기를 하면 &lt;img src=’/image/enterprise.gif’&gt;로 출력된다.

14. ?index_of
 - 특정 문자(열)가 시작되는 위치를 정수형으로 반환한다. 인덱스는 0부터 시작됨.
 - 형식 : 오브젝트?index_of(특정문자)
 - 샘플1) “abcde”?index_of(“c”) 는 2를 반환한다.

15. ?replace
 - 문자열의 일부를 주어진 문자로 대체하는 함수
 - 형식 : 오브젝트?replace(찾을문자열, 대체할문자열)
 - 샘플1) ${item.content?replace(“>”, “&gt;”)}

16. item_has_next
 -리스트 객체의 다음 컨텐츠가 존재하는지(EOF) 체크하는 함수
 -형식 : 리스트엘리어스이름_has_next
 -샘플1) 이름과 이름사이에 , 를 찍어주되 마지막은 찍지 않는 경우의 예
  <#list LIST as item>
      ${item.name?default(“”)}<#if item_has_next>,</#if>
  </#list>

 

 

Posted by '김용환'
,

method Inlining (JVM)

java core 2008. 11. 11. 02:30

출처

http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html

 

JVM에서 메소드 인라이닝이란, JVM이 메소드를 바로 호출하지 않고, 바로 그 자리에 리턴된 상수값또는 메소드를 넣어서 최대한 속도를 높이는 것을 말한다.

 

특징은 다음과 같다.

 

  • 메소드 콜이 없어서 부하를 낮춘다. No method call
  • 다이나믹 디스패치가 없다. No dynamic dispatch
  • 상수값이 주어지도록 한다. Possible to constant-fold the value, eg. "a.foo()+2" becomes 5 with no code executed at runtime.
  •  

    과거에는 final을 추가하여 inlining이 하도록 지시하게 하여 속도를 최대한 높일 수 있도록 하였다는 점이 주목적이다.

    (임베디드에서는 final이 필수적이다. 속도 빠르게 해야 와따니까.)

    하지만, 이런 테크닉이 모듈화에 적잖이 부담을 줄 수도 있다.

     

    그런데 말이지. HotSpot JVM은 final로 선언하지 않아도 알아서 inlining이 가능하다.

     

    모든 클래스들이 로딩할때마다 inlining을 하다가, 체크를 해보고 아니다 싶으면, 다시 도로 푸는 작업을 한다고 한다. deoptimized를 한다고 표현하고 있다.

     

     

    On every class load, all these assumptions are checked and, if violated, the now-incorrect compiled code is retired (deoptimized).

    Posted by '김용환'
    ,

    메모리 덤프 뜨기

    java core 2008. 9. 23. 01:07

    메모리 덤프하기

     

    1.     옵션 추가

    Catalina.sh에 우선 이 옵션을 사용한다.  Depth 15로 잡으면, 메모리 인스턴스의 reference또는 상속관계를 15단계까지 포함한다는 내용

    -agentlib:hprof=heap=dump,file=cms.txt,depth=15

      

    2.     아파치 스톱 : 더 이상 아파치 요청이 들어오지 않도록 함, 메모리 덤프시에는 서비스를 정상적으로 처리를 못함

    apachctl stop

     

    3.     메모리 덤프

    kill -3 java프로세스id

    => 바이너리 메모리 덤프, signal을 보내면 메모리를 cms.txt에 저장

     

    4.     /usr/local/tomcat/lucy8080/bin cms.txt 메모리 덤프파일을 확인, 더 이상 파일 크기가 커지지 않으면, 메모리 덤프 완료.

    보통, 메모리 싸이트가 200m이상일 때 덤프를 뜲.

    너무 많이 쌓인 상태에서는 파일 디스크나 오류로 인해서 정상적인 메모리 덤프가 안될 수도 있음. 너무 데이터량이 적으면, 분석하기 어려움. 적당하게 판단할 필요 있음

    'java core' 카테고리의 다른 글

    FreeMarker 바로 간단 사용하기  (0) 2008.12.31
    method Inlining (JVM)  (0) 2008.11.11
    자바 튜닝 관련  (0) 2008.08.27
    자바 Security 알고리즘 보기  (0) 2008.06.20
    jdk 6 update 6 Release Notes  (0) 2008.05.30
    Posted by '김용환'
    ,

    자바 튜닝 관련

    java core 2008. 8. 27. 08:17

     

     

     - Xms600m

        Xmx600m

        XX:NewSize=128m

    할당된   Heap Size 부족할 경우 추가로 확보할 힙싸이즈 제한

        XX:MaxNewSize=128m

    Heap Size 추가 확보시 최대 확보가능 용량

         XX:PermSize=128m

        JVM에서 사용하는 메타데이터 정보(영구적 사용)에 대한 저장 공간 : Static 공간

        XX:MaxPermSize=128m

        최대 확보 가능한 PermSize

         XX:SurvivorRatio=5

    기본값은 32 이며, 수치가 낮을수록 동적 클레스 로딩이 낮은 서비스에 도움이 된다.

    하지만 상황에 따라서 달리 된다.

     

    JDK 1.5 이상이면, JConsole을 이용하여 웹 서버가 JMX포트를 열어 jvm의 상태를 볼 수 있도록 해야 한다.

     

    상태에 따른 정보를 보고 정확한 진단이 필요하다.

    'java core' 카테고리의 다른 글

    method Inlining (JVM)  (0) 2008.11.11
    메모리 덤프 뜨기  (0) 2008.09.23
    자바 Security 알고리즘 보기  (0) 2008.06.20
    jdk 6 update 6 Release Notes  (0) 2008.05.30
    자바 개발자라면 꼭 봐야할 것들  (0) 2008.05.21
    Posted by '김용환'
    ,

     

     

    만약 내가 특정 알고리즘으로 파일을 인코딩하고, 디코딩하며 보안을 철저히 하고 싶을때..

    또는 통신 알고리즘상에서 스푸핑을 방지하고 싶을때..

     

    또는 DB 설정파일을 보안화하고 싶을때..

     

    그냥 자바를 보면 답이 나온다.

     

     

     import java.util.Iterator;
    import java.security.Security;
    import java.security.Provider;

    public class PrintProviders {
        public static void main(String[] args) {
            Provider[] providers = Security.getProviders();
            for (int i = 0; i < providers.length; i++) {
                String name = providers[i].getName();
                String info = providers[i].getInfo();
                double version = providers[i].getVersion();
                System.out.println("-------------------------------------");
                System.out.println("name: " + name);
                System.out.println("info: " + info);
                System.out.println("version: " + version);

                for (Iterator iter = providers[i].keySet().iterator(); iter
                        .hasNext();) {
                    String key = (String) iter.next();
                    System.out.println("\t" + key + "\t"
                            + providers[i].getProperty(key));
                }

                System.out.println("-------------------------------------");

            }
        }
    }

     

     

    자바에서는 Security 알고리즘이 무상하게 제공되고 있다.

     

    위의 소스의 결과를 볼까?

     

     -------------------------------------
    name: SUN
    info: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
    version: 1.6
     Alg.Alias.Signature.SHA1/DSA SHA1withDSA
     Alg.Alias.Signature.1.2.840.10040.4.3 SHA1withDSA
     Alg.Alias.Signature.DSS SHA1withDSA
     SecureRandom.SHA1PRNG ImplementedIn Software
     KeyStore.JKS sun.security.provider.JavaKeyStore$JKS
     Alg.Alias.MessageDigest.SHA-1 SHA
     MessageDigest.SHA sun.security.provider.SHA
     KeyStore.CaseExactJKS sun.security.provider.JavaKeyStore$CaseExactJKS
     CertStore.com.sun.security.IndexedCollection ImplementedIn Software
     Alg.Alias.Signature.DSA SHA1withDSA
     KeyFactory.DSA ImplementedIn Software
     KeyStore.JKS ImplementedIn Software
     AlgorithmParameters.DSA ImplementedIn Software
     Signature.NONEwithDSA sun.security.provider.DSA$RawDSA
     Alg.Alias.CertificateFactory.X509 X.509
     CertStore.com.sun.security.IndexedCollection sun.security.provider.certpath.IndexedCollectionCertStore
     Provider.id className sun.security.provider.Sun
     Alg.Alias.Signature.SHA-1/DSA SHA1withDSA
     CertificateFactory.X.509 ImplementedIn Software
     Signature.SHA1withDSA KeySize 1024
     KeyFactory.DSA sun.security.provider.DSAKeyFactory
     CertPathValidator.PKIX ImplementedIn Software
     Configuration.JavaLoginConfig sun.security.provider.ConfigSpiFile
     Alg.Alias.Signature.OID.1.2.840.10040.4.3 SHA1withDSA
     Alg.Alias.KeyFactory.1.2.840.10040.4.1 DSA
     MessageDigest.MD5 ImplementedIn Software
     Alg.Alias.Signature.RawDSA NONEwithDSA
     Provider.id name SUN
     Alg.Alias.AlgorithmParameters.1.2.840.10040.4.1 DSA
     CertPathBuilder.PKIX ValidationAlgorithm RFC3280
     Policy.JavaPolicy sun.security.provider.PolicySpiFile
     Alg.Alias.AlgorithmParameters.1.3.14.3.2.12 DSA
     Alg.Alias.Signature.SHA/DSA SHA1withDSA
     Alg.Alias.KeyPairGenerator.1.3.14.3.2.12 DSA
     MessageDigest.SHA-384 sun.security.provider.SHA5$SHA384
     Signature.SHA1withDSA ImplementedIn Software
     AlgorithmParameterGenerator.DSA sun.security.provider.DSAParameterGenerator
     Signature.NONEwithDSA SupportedKeyClasses java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
     MessageDigest.SHA-512 sun.security.provider.SHA5$SHA512
     CertPathBuilder.PKIX sun.security.provider.certpath.SunCertPathBuilder
     Alg.Alias.Signature.1.3.14.3.2.27 SHA1withDSA
     CertPathBuilder.PKIX ImplementedIn Software
     Provider.id version 1.6
     AlgorithmParameters.DSA sun.security.provider.DSAParameters
     Signature.SHA1withDSA SupportedKeyClasses java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
     CertStore.Collection sun.security.provider.certpath.CollectionCertStore
     AlgorithmParameterGenerator.DSA ImplementedIn Software
     KeyPairGenerator.DSA KeySize 1024
     CertStore.LDAP sun.security.provider.certpath.LDAPCertStore
     CertificateFactory.X.509 sun.security.provider.X509Factory
     CertStore.LDAP LDAPSchema RFC2587
     CertStore.LDAP ImplementedIn Software
     KeyPairGenerator.DSA ImplementedIn Software
     CertPathValidator.PKIX ValidationAlgorithm RFC3280
     CertStore.Collection ImplementedIn Software
     Alg.Alias.Signature.1.3.14.3.2.13 SHA1withDSA
     CertPathValidator.PKIX sun.security.provider.certpath.PKIXCertPathValidator
     Alg.Alias.MessageDigest.SHA1 SHA
     AlgorithmParameterGenerator.DSA KeySize 1024
     SecureRandom.SHA1PRNG sun.security.provider.SecureRandom
     Signature.SHA1withDSA sun.security.provider.DSA$SHA1withDSA
     Alg.Alias.KeyFactory.1.3.14.3.2.12 DSA
     KeyPairGenerator.DSA sun.security.provider.DSAKeyPairGenerator
     MessageDigest.SHA ImplementedIn Software
     Provider.id info SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
     Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1 DSA
     Alg.Alias.Signature.SHAwithDSA SHA1withDSA
     MessageDigest.MD5 sun.security.provider.MD5
     Alg.Alias.Signature.DSAWithSHA1 SHA1withDSA
     MessageDigest.SHA-256 sun.security.provider.SHA2
     Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1 DSA
     MessageDigest.MD2 sun.security.provider.MD2
    -------------------------------------
    -------------------------------------
    name: SunRsaSign
    info: Sun RSA signature provider
    version: 1.5
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.4 MD5withRSA
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.2 MD2withRSA
     Alg.Alias.KeyFactory.1.2.840.113549.1.1 RSA
     Signature.SHA512withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Provider.id version 1.5
     Signature.MD5withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Alg.Alias.Signature.1.2.840.113549.1.1.13 SHA512withRSA
     KeyPairGenerator.RSA sun.security.rsa.RSAKeyPairGenerator
     Alg.Alias.Signature.1.2.840.113549.1.1.12 SHA384withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.11 SHA256withRSA
     KeyFactory.RSA sun.security.rsa.RSAKeyFactory
     Alg.Alias.Signature.1.3.14.3.2.29 SHA1withRSA
     Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1 RSA
     Signature.MD2withRSA sun.security.rsa.RSASignature$MD2withRSA
     Signature.SHA384withRSA sun.security.rsa.RSASignature$SHA384withRSA
     Signature.MD5withRSA sun.security.rsa.RSASignature$MD5withRSA
     Provider.id info Sun RSA signature provider
     Signature.SHA1withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Signature.SHA1withRSA sun.security.rsa.RSASignature$SHA1withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.5 SHA1withRSA
     Signature.SHA256withRSA sun.security.rsa.RSASignature$SHA256withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.4 MD5withRSA
     Provider.id className sun.security.rsa.SunRsaSign
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.13 SHA512withRSA
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.12 SHA384withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.2 MD2withRSA
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.11 SHA256withRSA
     Signature.MD2withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Provider.id name SunRsaSign
     Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1 RSA
     Signature.SHA384withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Signature.SHA512withRSA sun.security.rsa.RSASignature$SHA512withRSA
     Signature.SHA256withRSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.5 SHA1withRSA
     Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1 RSA
    -------------------------------------
    -------------------------------------
    name: SunJSSE
    info: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
    version: 1.6
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.4 MD5withRSA
     Alg.Alias.KeyFactory.1.2.840.113549.1.1 RSA
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.2 MD2withRSA
     SSLContext.Default com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl
     Provider.id version 1.6
     TrustManagerFactory.SunX509 com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$SimpleFactory
     KeyManagerFactory.NewSunX509 com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$X509
     KeyPairGenerator.RSA sun.security.rsa.RSAKeyPairGenerator
     KeyStore.PKCS12 com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore
     SSLContext.SSLv3 com.sun.net.ssl.internal.ssl.SSLContextImpl
     KeyFactory.RSA sun.security.rsa.RSAKeyFactory
     Alg.Alias.Signature.1.3.14.3.2.29 SHA1withRSA
     Alg.Alias.TrustManagerFactory.X509 PKIX
     Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1 RSA
     Signature.MD5andSHA1withRSA com.sun.net.ssl.internal.ssl.RSASignature
     Signature.MD2withRSA sun.security.rsa.RSASignature$MD2withRSA
     Signature.MD5withRSA sun.security.rsa.RSASignature$MD5withRSA
     Provider.id info Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1)
     Signature.SHA1withRSA sun.security.rsa.RSASignature$SHA1withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.5 SHA1withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.4 MD5withRSA
     Provider.id className com.sun.net.ssl.internal.ssl.Provider
     Alg.Alias.Signature.OID.1.3.14.3.2.29 SHA1withRSA
     Alg.Alias.Signature.1.2.840.113549.1.1.2 MD2withRSA
     Provider.id name SunJSSE
     SSLContext.SSL com.sun.net.ssl.internal.ssl.SSLContextImpl
     SSLContext.TLS com.sun.net.ssl.internal.ssl.SSLContextImpl
     TrustManagerFactory.PKIX com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$PKIXFactory
     SSLContext.TLSv1 com.sun.net.ssl.internal.ssl.SSLContextImpl
     Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1 RSA
     KeyManagerFactory.SunX509 com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509
     Alg.Alias.TrustManagerFactory.SunPKIX PKIX
     Alg.Alias.TrustManagerFactory.X.509 PKIX
     Alg.Alias.Signature.OID.1.2.840.113549.1.1.5 SHA1withRSA
     Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1 RSA
    -------------------------------------
    -------------------------------------
    name: SunJCE
    info: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
    version: 1.6
     Cipher.Blowfish SupportedKeyFormats RAW
     AlgorithmParameters.DESede com.sun.crypto.provider.DESedeParameters
     AlgorithmParameters.DES com.sun.crypto.provider.DESParameters
     Cipher.DES SupportedPaddings NOPADDING|PKCS5PADDING|ISO10126PADDING
     AlgorithmParameters.Blowfish com.sun.crypto.provider.BlowfishParameters
     Cipher.DESedeWrap SupportedKeyFormats RAW
     Alg.Alias.KeyAgreement.1.2.840.113549.1.3.1 DiffieHellman
     AlgorithmParameterGenerator.DiffieHellman com.sun.crypto.provider.DHParameterGenerator
     Cipher.RSA SupportedPaddings NOPADDING|PKCS1PADDING|OAEPWITHMD5ANDMGF1PADDING|OAEPWITHSHA1ANDMGF1PADDING|OAEPWITHSHA-1ANDMGF1PADDING|OAEPWITHSHA-256ANDMGF1PADDING|OAEPWITHSHA-384ANDMGF1PADDING|OAEPWITHSHA-512ANDMGF1PADDING
     Alg.Alias.Cipher.TripleDES DESede
     Cipher.ARCFOUR SupportedModes ECB
     Mac.SslMacSHA1 SupportedKeyFormats RAW
     KeyGenerator.DES com.sun.crypto.provider.DESKeyGenerator
     Provider.id version 1.6
     KeyGenerator.DESede com.sun.crypto.provider.DESedeKeyGenerator
     Alg.Alias.SecretKeyFactory.PBE PBEWithMD5AndDES
     Alg.Alias.KeyFactory.1.2.840.113549.1.3.1 DiffieHellman
     Mac.HmacSHA1 com.sun.crypto.provider.HmacSHA1
     Cipher.PBEWithMD5AndDES com.sun.crypto.provider.PBEWithMD5AndDESCipher
     Cipher.AES SupportedModes ECB|CBC|PCBC|CTR|CTS|CFB|OFB|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64|CFB72|CFB80|CFB88|CFB96|CFB104|CFB112|CFB120|CFB128|OFB72|OFB80|OFB88|OFB96|OFB104|OFB112|OFB120|OFB128
     Cipher.AESWrap SupportedModes ECB
     SecretKeyFactory.DESede com.sun.crypto.provider.DESedeKeyFactory
     KeyGenerator.SunTlsKeyMaterial com.sun.crypto.provider.TlsKeyMaterialGenerator
     AlgorithmParameters.OAEP com.sun.crypto.provider.OAEPParameters
     Cipher.AES SupportedKeyFormats RAW
     AlgorithmParameters.RC2 com.sun.crypto.provider.RC2Parameters
     AlgorithmParameters.PBE com.sun.crypto.provider.PBEParameters
     Alg.Alias.KeyPairGenerator.DH DiffieHellman
     Alg.Alias.KeyAgreement.OID.1.2.840.113549.1.3.1 DiffieHellman
     Cipher.AES com.sun.crypto.provider.AESCipher
     KeyGenerator.RC2 com.sun.crypto.provider.KeyGeneratorCore$RC2KeyGenerator
     Mac.HmacSHA512 com.sun.crypto.provider.HmacCore$HmacSHA512
     Provider.id info SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
     Cipher.AES SupportedPaddings NOPADDING|PKCS5PADDING|ISO10126PADDING
     Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     Cipher.Blowfish SupportedPaddings NOPADDING|PKCS5PADDING|ISO10126PADDING
     Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     KeyStore.JCEKS com.sun.crypto.provider.JceKeyStore
     Cipher.Blowfish SupportedModes ECB|CBC|PCBC|CTR|CTS|CFB|OFB|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64
     Alg.Alias.SecretKeyFactory.1.2.840.113549.1.5.12 PBKDF2WithHmacSHA1
     Mac.HmacSHA384 SupportedKeyFormats RAW
     Cipher.DESedeWrap com.sun.crypto.provider.DESedeWrapCipher
     Cipher.ARCFOUR SupportedPaddings NOPADDING
     Alg.Alias.KeyPairGenerator.1.2.840.113549.1.3.1 DiffieHellman
     Cipher.PBEWithMD5AndTripleDES com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher
     Alg.Alias.Cipher.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     Alg.Alias.Cipher.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     Mac.HmacSHA256 SupportedKeyFormats RAW
     Alg.Alias.AlgorithmParameterGenerator.1.2.840.113549.1.3.1 DiffieHellman
     Cipher.PBEWithSHA1AndDESede com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede
     SecretKeyFactory.PBEWithMD5AndDES com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndDES
     KeyPairGenerator.DiffieHellman com.sun.crypto.provider.DHKeyPairGenerator
     Cipher.RC2 SupportedModes ECB|CBC|PCBC|CTR|CTS|CFB|OFB|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64
     Alg.Alias.AlgorithmParameters.Rijndael AES
     KeyAgreement.DiffieHellman SupportedKeyClasses javax.crypto.interfaces.DHPublicKey|javax.crypto.interfaces.DHPrivateKey
     Mac.HmacMD5 SupportedKeyFormats RAW
     KeyGenerator.SunTlsRsaPremasterSecret com.sun.crypto.provider.TlsRsaPremasterSecretGenerator
     Cipher.AESWrap SupportedKeyFormats RAW
     SecretKeyFactory.DES com.sun.crypto.provider.DESKeyFactory
     Cipher.AESWrap SupportedPaddings NOPADDING
     Provider.id name SunJCE
     KeyGenerator.HmacSHA512 com.sun.crypto.provider.KeyGeneratorCore$HmacSHA512KG
     Mac.HmacSHA256 com.sun.crypto.provider.HmacCore$HmacSHA256
     Cipher.ARCFOUR SupportedKeyFormats RAW
     Cipher.DES SupportedModes ECB|CBC|PCBC|CTR|CTS|CFB|OFB|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64
     Cipher.RSA SupportedKeyClasses java.security.interfaces.RSAPublicKey|java.security.interfaces.RSAPrivateKey
     SecretKeyFactory.PBEWithMD5AndTripleDES com.sun.crypto.provider.PBEKeyFactory$PBEWithMD5AndTripleDES
     Cipher.PBEWithSHA1AndRC2_40 com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40
     AlgorithmParameters.DiffieHellman com.sun.crypto.provider.DHParameters
     Mac.HmacMD5 com.sun.crypto.provider.HmacMD5
     Cipher.RSA com.sun.crypto.provider.RSACipher
     Mac.SslMacMD5 com.sun.crypto.provider.SslMacCore$SslMacMD5
     Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     Cipher.DESede SupportedPaddings NOPADDING|PKCS5PADDING|ISO10126PADDING
     Alg.Alias.AlgorithmParameterGenerator.OID.1.2.840.113549.1.3.1 DiffieHellman
     Cipher.DESede com.sun.crypto.provider.DESedeCipher
     Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.3.1 DiffieHellman
     Alg.Alias.AlgorithmParameters.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     Mac.HmacSHA512 SupportedKeyFormats RAW
     Mac.HmacPBESHA1 SupportedKeyFormats RAW
     Alg.Alias.AlgorithmParameterGenerator.DH DiffieHellman
     Cipher.DESedeWrap SupportedPaddings NOPADDING
     Alg.Alias.SecretKeyFactory.OID.1.2.840.113549.1.5.12 PBKDF2WithHmacSHA1
     Alg.Alias.AlgorithmParameters.1.2.840.113549.1.3.1 DiffieHellman
     Mac.HmacPBESHA1 com.sun.crypto.provider.HmacPKCS12PBESHA1
     Cipher.DES SupportedKeyFormats RAW
     AlgorithmParameters.PBEWithMD5AndTripleDES com.sun.crypto.provider.PBEParameters
     Cipher.DESedeWrap SupportedModes CBC
     Alg.Alias.KeyFactory.OID.1.2.840.113549.1.3.1 DiffieHellman
     Alg.Alias.Cipher.OID.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     AlgorithmParameters.AES com.sun.crypto.provider.AESParameters
     Alg.Alias.AlgorithmParameters.TripleDES DESede
     Alg.Alias.SecretKeyFactory.TripleDES DESede
     KeyGenerator.HmacSHA256 com.sun.crypto.provider.KeyGeneratorCore$HmacSHA256KG
     Alg.Alias.KeyGenerator.TripleDES DESede
     Alg.Alias.AlgorithmParameters.DH DiffieHellman
     KeyGenerator.AES com.sun.crypto.provider.AESKeyGenerator
     Cipher.RC2 SupportedPaddings NOPADDING|PKCS5PADDING|ISO10126PADDING
     Alg.Alias.Cipher.RC4 ARCFOUR
     Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.3.1 DiffieHellman
     Mac.HmacSHA384 com.sun.crypto.provider.HmacCore$HmacSHA384
     SecretKeyFactory.PBKDF2WithHmacSHA1 com.sun.crypto.provider.PBKDF2HmacSHA1Factory
     Provider.id className com.sun.crypto.provider.SunJCE
     Cipher.DES com.sun.crypto.provider.DESCipher
     Cipher.Blowfish com.sun.crypto.provider.BlowfishCipher
     KeyGenerator.SunTlsMasterSecret com.sun.crypto.provider.TlsMasterSecretGenerator
     KeyGenerator.HmacSHA1 com.sun.crypto.provider.HmacSHA1KeyGenerator
     Alg.Alias.SecretKeyFactory.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     KeyGenerator.SunTlsPrf com.sun.crypto.provider.TlsPrfGenerator
     SecretKeyFactory.PBEWithSHA1AndDESede com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndDESede
     KeyGenerator.ARCFOUR com.sun.crypto.provider.KeyGeneratorCore$ARCFOURKeyGenerator
     Alg.Alias.KeyAgreement.DH DiffieHellman
     Alg.Alias.KeyGenerator.Rijndael AES
     AlgorithmParameters.PBEWithSHA1AndDESede com.sun.crypto.provider.PBEParameters
     Alg.Alias.KeyGenerator.RC4 ARCFOUR
     Alg.Alias.Cipher.OID.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     Alg.Alias.Cipher.OID.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     Mac.SslMacMD5 SupportedKeyFormats RAW
     Mac.HmacSHA1 SupportedKeyFormats RAW
     Cipher.DESede SupportedKeyFormats RAW
     Cipher.RC2 com.sun.crypto.provider.RC2Cipher
     SecretKeyFactory.PBEWithSHA1AndRC2_40 com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_40
     KeyGenerator.HmacMD5 com.sun.crypto.provider.HmacMD5KeyGenerator
     AlgorithmParameters.PBEWithSHA1AndRC2_40 com.sun.crypto.provider.PBEParameters
     KeyGenerator.HmacSHA384 com.sun.crypto.provider.KeyGeneratorCore$HmacSHA384KG
     Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     KeyFactory.DiffieHellman com.sun.crypto.provider.DHKeyFactory
     Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     AlgorithmParameters.PBEWithMD5AndDES com.sun.crypto.provider.PBEParameters
     Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     Alg.Alias.SecretKeyFactory.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     Cipher.AESWrap com.sun.crypto.provider.AESWrapCipher
     Alg.Alias.SecretKeyFactory.OID.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     Alg.Alias.Cipher.Rijndael AES
     Cipher.RSA SupportedModes ECB
     Cipher.DESede SupportedModes ECB|CBC|PCBC|CTR|CTS|CFB|OFB|CFB8|CFB16|CFB24|CFB32|CFB40|CFB48|CFB56|CFB64|OFB8|OFB16|OFB24|OFB32|OFB40|OFB48|OFB56|OFB64
     Alg.Alias.SecretKeyFactory.OID.1.2.840.113549.1.12.1.6 PBEWithSHA1AndRC2_40
     Alg.Alias.SecretKeyFactory.OID.1.2.840.113549.1.12.1.3 PBEWithSHA1AndDESede
     Cipher.ARCFOUR com.sun.crypto.provider.ARCFOURCipher
     Alg.Alias.Cipher.1.2.840.113549.1.5.3 PBEWithMD5AndDES
     Mac.SslMacSHA1 com.sun.crypto.provider.SslMacCore$SslMacSHA1
     KeyAgreement.DiffieHellman com.sun.crypto.provider.DHKeyAgreement
     Cipher.RC2 SupportedKeyFormats RAW
     Alg.Alias.KeyFactory.DH DiffieHellman
     KeyGenerator.Blowfish com.sun.crypto.provider.BlowfishKeyGenerator
    -------------------------------------
    -------------------------------------
    name: SunJGSS
    info: Sun (Kerberos v5, SPNEGO)
    version: 1.0
     GssApiMechanism.1.3.6.1.5.5.2 sun.security.jgss.spnego.SpNegoMechFactory
     Provider.id info Sun (Kerberos v5, SPNEGO)
     Provider.id className sun.security.jgss.SunProvider
     Provider.id version 1.0
     GssApiMechanism.1.2.840.113554.1.2.2 sun.security.jgss.krb5.Krb5MechFactory
     Provider.id name SunJGSS
    -------------------------------------
    -------------------------------------
    name: SunSASL
    info: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
    version: 1.5
     Provider.id className com.sun.security.sasl.Provider
     SaslClientFactory.CRAM-MD5 com.sun.security.sasl.ClientFactoryImpl
     Provider.id version 1.5
     SaslClientFactory.EXTERNAL com.sun.security.sasl.ClientFactoryImpl
     SaslClientFactory.DIGEST-MD5 com.sun.security.sasl.digest.FactoryImpl
     SaslClientFactory.PLAIN com.sun.security.sasl.ClientFactoryImpl
     Provider.id name SunSASL
     SaslClientFactory.GSSAPI com.sun.security.sasl.gsskerb.FactoryImpl
     SaslServerFactory.DIGEST-MD5 com.sun.security.sasl.digest.FactoryImpl
     SaslServerFactory.CRAM-MD5 com.sun.security.sasl.ServerFactoryImpl
     SaslServerFactory.GSSAPI com.sun.security.sasl.gsskerb.FactoryImpl
     Provider.id info Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)
    -------------------------------------
    -------------------------------------
    name: XMLDSig
    info: XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory)
    version: 1.0
     Alg.Alias.TransformService.XPATH http://www.w3.org/TR/1999/REC-xpath-19991116
     TransformService.http://www.w3.org/TR/1999/REC-xslt-19991116 MechanismType DOM
     Provider.id version 1.0
     Alg.Alias.TransformService.INCLUSIVE http://www.w3.org/TR/2001/REC-xml-c14n-20010315
     TransformService.http://www.w3.org/2000/09/xmldsig#base64 MechanismType DOM
     Alg.Alias.TransformService.EXCLUSIVE http://www.w3.org/2001/10/xml-exc-c14n#
     KeyInfoFactory.DOM org.jcp.xml.dsig.internal.dom.DOMKeyInfoFactory
     TransformService.http://www.w3.org/2001/10/xml-exc-c14n#WithComments org.jcp.xml.dsig.internal.dom.DOMExcC14NMethod
     Alg.Alias.TransformService.INCLUSIVE_WITH_COMMENTS http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments
     TransformService.http://www.w3.org/2002/06/xmldsig-filter2 MechanismType DOM
     TransformService.http://www.w3.org/TR/1999/REC-xpath-19991116 MechanismType DOM
     TransformService.http://www.w3.org/2001/10/xml-exc-c14n# org.jcp.xml.dsig.internal.dom.DOMExcC14NMethod
     XMLSignatureFactory.DOM org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory
     Alg.Alias.TransformService.XPATH2 http://www.w3.org/2002/06/xmldsig-filter2
     TransformService.http://www.w3.org/2001/10/xml-exc-c14n# MechanismType DOM
     TransformService.http://www.w3.org/2001/10/xml-exc-c14n#WithComments MechanismType DOM
     TransformService.http://www.w3.org/TR/1999/REC-xslt-19991116 org.jcp.xml.dsig.internal.dom.DOMXSLTTransform
     TransformService.http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod
     Alg.Alias.TransformService.BASE64 http://www.w3.org/2000/09/xmldsig#base64
     Alg.Alias.TransformService.ENVELOPED http://www.w3.org/2000/09/xmldsig#enveloped-signature
     Provider.id info XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory)
     TransformService.http://www.w3.org/TR/2001/REC-xml-c14n-20010315 org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod
     Provider.id className org.jcp.xml.dsig.internal.dom.XMLDSigRI
     Alg.Alias.TransformService.EXCLUSIVE_WITH_COMMENTS http://www.w3.org/2001/10/xml-exc-c14n#WithComments
     TransformService.http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments MechanismType DOM
     TransformService.http://www.w3.org/2002/06/xmldsig-filter2 org.jcp.xml.dsig.internal.dom.DOMXPathFilter2Transform
     TransformService.http://www.w3.org/2000/09/xmldsig#enveloped-signature org.jcp.xml.dsig.internal.dom.DOMEnvelopedTransform
     Provider.id name XMLDSig
     TransformService.http://www.w3.org/2000/09/xmldsig#base64 org.jcp.xml.dsig.internal.dom.DOMBase64Transform
     TransformService.http://www.w3.org/TR/1999/REC-xpath-19991116 org.jcp.xml.dsig.internal.dom.DOMXPathTransform
     TransformService.http://www.w3.org/TR/2001/REC-xml-c14n-20010315 MechanismType DOM
     Alg.Alias.TransformService.XSLT http://www.w3.org/TR/1999/REC-xslt-19991116
     TransformService.http://www.w3.org/2000/09/xmldsig#enveloped-signature MechanismType DOM
    -------------------------------------
    -------------------------------------
    name: SunPCSC
    info: Sun PC/SC provider
    version: 1.6
     Provider.id info Sun PC/SC provider
     Provider.id className sun.security.smartcardio.SunPCSC
     Provider.id version 1.6
     Provider.id name SunPCSC
     TerminalFactory.PC/SC sun.security.smartcardio.SunPCSC$Factory
    -------------------------------------
    -------------------------------------
    name: SunMSCAPI
    info: Sun's Microsoft Crypto API provider
    version: 1.6
     SecureRandom.Windows-PRNG sun.security.mscapi.PRNG
     Provider.id version 1.6
     Cipher.RSA/ECB/PKCS1Padding sun.security.mscapi.RSACipher
     Signature.MD5withRSA SupportedKeyClasses sun.security.mscapi.Key
     KeyPairGenerator.RSA sun.security.mscapi.RSAKeyPairGenerator
     KeyStore.Windows-ROOT sun.security.mscapi.KeyStore$ROOT
     Signature.NONEwithRSA SupportedKeyClasses sun.security.mscapi.Key
     Cipher.RSA SupportedKeyClasses sun.security.mscapi.Key
     Signature.MD2withRSA sun.security.mscapi.RSASignature$MD2
     Signature.MD5withRSA sun.security.mscapi.RSASignature$MD5
     Cipher.RSA SupportedModes ECB
     Provider.id info Sun's Microsoft Crypto API provider
     Signature.SHA1withRSA SupportedKeyClasses sun.security.mscapi.Key
     Signature.SHA1withRSA sun.security.mscapi.RSASignature$SHA1
     Provider.id className sun.security.mscapi.SunMSCAPI
     KeyPairGenerator.RSA KeySize 1024
     Signature.MD2withRSA SupportedKeyClasses sun.security.mscapi.Key
     Provider.id name SunMSCAPI
     Cipher.RSA SupportedPaddings PKCS1PADDING
     Cipher.RSA sun.security.mscapi.RSACipher
     KeyStore.Windows-MY sun.security.mscapi.KeyStore$MY
    -------------------------------------

     

     

     

    이렇게 많ㅇ이 사용될 수 있는 알고리즘 구현방식이 있다.

     

     

    아래 URL의 샘플 코드를 봐보자.

    http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html

     

     

        import java.security.*;
       import javax.crypto.*;
       import javax.crypto.spec.*;
       import java.io.*;

       /**
       * This program generates a AES key, retrieves its raw bytes, and
       * then reinstantiates a AES key from the key bytes.
       * The reinstantiated key is used to initialize a AES cipher for
       * encryption and decryption.
       */

       public class AES {

         /**
         * Turns array of bytes into string
         *
         * @param buf Array of bytes to convert to hex string
         * @return Generated hex string
         */
         public static String asHex (byte buf[]) {
          StringBuffer strbuf = new StringBuffer(buf.length * 2);
          int i;

          for (i = 0; i < buf.length; i++) {
           if (((int) buf[i] & 0xff) < 0x10)
        strbuf.append("0");

           strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
          }

          return strbuf.toString();
         }

         public static void main(String[] args) throws Exception {

           String message="This is just an example";

           // Get the KeyGenerator

           KeyGenerator kgen = KeyGenerator.getInstance("AES");
           kgen.init(128); // 192 and 256 bits may not be available


           // Generate the secret key specs.
           SecretKey skey = kgen.generateKey();
           byte[] raw = skey.getEncoded();

           SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");


           // Instantiate the cipher

           Cipher cipher = Cipher.getInstance("AES");

           cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

           byte[] encrypted =
             cipher.doFinal((args.length == 0 ?
              "This is just an example" : args[0]).getBytes());
           System.out.println("encrypted string: " + asHex(encrypted));

           cipher.init(Cipher.DECRYPT_MODE, skeySpec);
           byte[] original =
             cipher.doFinal(encrypted);
           String originalString = new String(original);
           System.out.println("Original string: " +
             originalString + " " + asHex(original));
         }
       }

    'java core' 카테고리의 다른 글

    메모리 덤프 뜨기  (0) 2008.09.23
    자바 튜닝 관련  (0) 2008.08.27
    jdk 6 update 6 Release Notes  (0) 2008.05.30
    자바 개발자라면 꼭 봐야할 것들  (0) 2008.05.21
    org.apache.jasper.JasperException: Unable to compile class for JSP  (1) 2008.02.19
    Posted by '김용환'
    ,

     

    jdk 6 update 6가 최근에 Release 했다.

    자세한 내용은 아래와 같댜.

    - 오슬론 타인존이 생겼다.

    - 각 종 버그를 수정했다. 버그 픽스가 많이 수정된 것으로 보아, 어느 정도 안정화되었다고 할 수 있겠다.

     

    출처 :

    http://java.sun.com/javase/6/webnotes/ReleaseNotes.html

     

     
    JavaTM SE 6

    Update Release Notes


    JDK Documentation

    Update Release Notes summarize changes made in all 1.6.0 update releases. Note that bug fixes in previous update versions are also included in the current update version.

    The version numbers are given below, complete with build number. To determine the version of your JDK software, use the following command:

           java -version

    Bug Database - In most cases, the bug ID number in each description below is a link to the detailed bug report on the Bug Database (Bug Parade) web site. Bug Database enables you to file your own bug reports, add comments to existing bug reports, and vote for the bugs you consider most important.

    Current Version Earlier Versions

    Changes in 1.6.0_06

    The full internal version number for this update release is 1.6.0_06-b02 (where "b" means "build"). The external version number is 6u6. Included in JDK 6u6 is version 10.0 of the Java HotSpot Virtual Machine.

    Security Baseline

    This update release specifies the following security baselines:

    JRE Family Version Security Baseline
    5.0 1.5.0_15
    1.4.2 1.4.2_17

    For more information about the security baseline, see Deploying Java Applets With Family JRE Versions in Java Plug-in for Internet Explorer .

    OlsonData 2007k

    This release contains Olson time zone data version 2007k. For more information, refer to 6646197 or see US DST Timezone Updater.

    Bug fixes are listed in the following table.

    BugId Category Subcategory Description
    6532373 java classes_awt xcb_xlib.c:50: xcb_xlib_unlock: Assertion 'c->xlib.lock' failed.
    6632169 java classes_net HttpClient and HttpsClient should not try to reverse lookup IP address of a proxy server
    6648816 java classes_security REGRESSION: setting -Djava.security.debug=failure result in NPE in ACC
    6650748 java classes_util_i18n (tz) Java runtime doesn't detect VET time zone correctly on Windows
    6673080 java classes_util_i18n (tz) Support tzdata2008a
    6676491 java sunservicetags Incorrect locale specified in the URL embedded in the register[_<locale>].html
    6641731 java_deployment general The Java control panel is not showing up in the Windows Vista control panel on a AMD 64 machine
    6618901 java_plugin plugin 6.0 JRE applet running on Vista limits heap to 64 MB
    6648381 java_plugin plugin FontConfiguration exception preventing applets from loading
    6595845 javawebstart general Java 6 JavaWebstart increases footprint by factor 2
    6648395 javawebstart install JWS can't find cache file after network crash
    6672868 jax-ws other Package javax.xml.ws.wsaddressing not included in make/docs/CORE_PKGS.gmk
    6578538 jce classes_crypto com.sun.crypto.provider.SunJCE instance leak using KRB5 and LoginContext

    Posted by '김용환'
    ,

    java개발자라면, 반드시 봐야할 내용들이다.

    java.sun.com에는 모든 것이 있다. 이클립스 플러그인 보다는 훨씬 더 많고 풍부한 자료들이 있는 java.sun.com을 추천한다.

     

    버젼과는 상관없이 봐야하는 것은 다음과 같다.

    Release note, java utitily, 튜닝 팁, tutotial.

     

     

    예)

     

    Java 1.5

    http://java.sun.com/j2se/1.5.0/docs/index.html

     

    java utility

    http://java.sun.com/j2se/1.5.0/docs/tooldocs/index.html

     

    성능 튜닝 및 해결 가이드 및 팁

    http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf

     

    Release Note

    http://java.sun.com/j2se/1.5.0/relnotes.html

    Posted by '김용환'
    ,
    org.apache.jasper.JasperException: Unable to compile class for JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:572)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

     

     

    잘돌아가다가 이런  에러를 만나면.. 톰캣 컨테이너 문제일 수 있다.

     

    배포된 서버에서 WEB-INF  디렉토리를 지우고, 다시 배포한 후, 재시작을 해보자..

     

    바로 된다...^^

     

    이런 경우는 정확한 이유를 찾는 것보다. 다른 일을 많이 하는 게 낫다. 지우고 다시 배포, 시작하기!

    Posted by '김용환'
    ,