was.policy 파일을 Java 2 보안을 위한 애플리케이션에 추가
기본 app.policy 파일에서 부여된 권한보다 많은 권한을 필요로 하는 자원에 액세스하는 경우에는 애플리케이션에 was.policy 파일이 필요할 수도 있습니다.
이 태스크 정보
모든 애플리케이션을 위한 기본 정책 파일은 app.policy 파일에 지정됩니다. 이 파일은 제품 보안에 의해 제공되고 모든 애플리케이션에 공통이고 이 파일을 변경하지 않습니다. was.policy 파일에 애플리케이션에 필요한 새 권한을 추가하십시오.
WebSphere Application Server에 의해 제공된 app.policy 파일은 app_server_root/config/cells/profile/profile_name/config/cell_name/노드/node_name/app.policy에 상주합니다. app.policy 파일의 컨텐츠는 다음 예에 제공됩니다.
// The following permissions apply to all the components under the application.
grant codeBase "file:${application}" {
// The following are required by JavaMail
permission java.io.FilePermission "
${was.install.root}${/}lib${/}activation-impl.jar",
"read";
permission java.io.FilePermission "
${was.install.root}${/}lib${/}mail-impl.jar","read";
};
// The following permissions apply to all utility .jar files (other
// than enterprise beans JAR files) in the application.
grant codeBase "file:${jars}" {
permission java.net.SocketPermission "*", "connect";
permission java.util.PropertyPermission "*", "read";
};
// The following permissions apply to connector resources within the application
grant codeBase "file:${connectorComponent}" {
permission java.net.SocketPermission "*", "connect";
permission java.util.PropertyPermission "*", "read";
};
// The following permissions apply to all the web modules (.war files)
// within the application.
grant codeBase "file:${webComponent}" {
permission java.io.FilePermission "${was.module.path}${/}-", "read, write";
// where "was.module.path" is the path where the web module is
// installed. Refer to Dynamic policy concepts for other symbols.
permission java.lang.RuntimePermission "loadLibrary.*";
permission java.lang.RuntimePermission "queuePrintJob";
permission java.net.SocketPermission "*", "connect";
permission java.util.PropertyPermission "*", "read";
};
// The following permissions apply to all the EJB modules within the application.
grant codeBase "file:${ejbComponent}" {
permission java.lang.RuntimePermission "queuePrintJob";
permission java.net.SocketPermission "*", "connect";
permission java.util.PropertyPermission "*", "read";
};
애플리케이션을 위해서나 애플리케이션의 하나 이상의 모듈을 위해 추가적 권한이 필요한 경우에는 해당 애플리케이션을 위한 was.policy 파일을 사용하십시오. 예를 들어, ${application}의 codeBase를 사용하고 추가 권한을 부여하기 위해 필수 권한을 전체 애플리케이션에 추가하십시오. 마찬가지로 ${webComponent} 및 ${ejbComponent}의 codeBase를모든 웹 모듈과 애플리케이션에 있는 모든 엔터프라이즈 Bean 모듈에 추가 권한을 부여하십시오. 다음 예제에서처럼, 추가적 권한을 각 모듈(.war 파일 또는 .jar 파일)에 지정할 수 있습니다.
이 예는 애플리케이션을 위한 추가 권한을 was.policy 파일에 추가한 것을 설명합니다.
// grant additional permissions to a web module
grant codeBase " file:aWebModule.war" {
permission java.security.SecurityPermission "printIdentity";
};
// grant additional permission to an EJB module
grant codeBase "file:aEJBModule.jar" {
permission java.io.FilePermission "
${user.install.root}${/}bin${/}DefaultDB${/}-", "read,write,delete";
// where, ${user.install.root} is the system property whose value is
// located in the app_server_root directory.
};
사용자의 애플리케이션에 was.policy 파일을 사용하려면, 다음 단계를 수행하십시오.
프로시저
결과
예
이 단계는 또한 Java 2 보안이 사용 가능할 때 애플리케이션이 제대로 실행되기 위해서도 필요합니다. was.policy 파일이 작성되지 않고 필수 권한을 포함하지 않은 경우에는 애플리케이션은 시스템 자원에 액세스하지 않을 수도 있습니다.
누락된 권한의 증상은 java.security.AccessControlException 예외입니다. 누락된 권한은 예외 데이터에 나열됩니다. 예:
![[IBM i]](../images/iseries.gif)
![[z/OS]](../images/ngzos.gif)
java.security.AccessControlException: access denied (java.io.FilePermission
${was.install.root}/java/ext/mail.jar read)
![[IBM i]](../images/iseries.gif)
![[z/OS]](../images/ngzos.gif)
grant codeBase "file:user_client_installed_location" {
permission java.io.FilePermission
"${was.install.root}$(/)java$(/)jre$(/)lib$(/)ext$(/)mail.jar", "read";
};
이전 권한 정보 행은 설명을 위해서 분할되었습니다. 권한을 한 행에 입력하십시오.