Security Developer s Guide - Oracle

Java Platform, Standard Edition

Security Developer¡¯s Guide

Release 9

E68624-04

October 2017

Java Platform, Standard Edition Security Developer¡¯s Guide, Release 9

E68624-04

Copyright ? 1993, 2017, Oracle and/or its affiliates. All rights reserved.

This software and related documentation are provided under a license agreement containing restrictions on

use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your

license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify,

license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means.

Reverse engineering, disassembly, or decompilation of this software, unless required by law for

interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If

you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on

behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,

any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are

"commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agencyspecific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the

programs, including any operating system, integrated software, any programs installed on the hardware,

and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.

No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management applications.

It is not developed or intended for use in any inherently dangerous applications, including applications that

may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you

shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its

safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this

software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of

their respective owners.

Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are

used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron,

the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro

Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products,

and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly

disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise

set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be

responsible for any loss, costs, or damages incurred due to your access to or use of third-party content,

products, or services, except as set forth in an applicable agreement between you and Oracle.

Contents

Preface

1

Audience

xvi

Documentation Accessibility

xvi

Related Documents

xvi

Conventions

xvi

General Security

Java Security Overview

1-1

Introduction to Java Security

1-1

Java Language Security and Bytecode Verification

1-2

Basic Security Architecture

1-3

Security Providers

1-3

File Locations

1-5

Java Cryptography

1-6

Public Key Infrastructure

1-7

Key and Certificate Storage

1-7

Public Key Infrastructure Tools

1-8

Authentication

Secure Communication

1-9

1-10

SSL, TLS, and DTLS Protocols

1-11

Simple Authentication and Security Layer (SASL)

1-11

Generic Security Service API and Kerberos

1-12

Access Control

1-12

Permissions

1-12

Security Policy

1-13

Access Control Enforcement

1-14

XML Signature

1-15

Additional Information about Java Security

1-16

Java Security Classes Summary

1-16

Deprecated Security APIs Marked for Removal

1-18

Security Tools Summary

1-19

Built-In Providers

1-20

iii

Security Architecture

1-20

Standard Algorithm Names

1-20

Permissions in the Java Development Kit (JDK)

1-21

Permission Descriptions and Risks

NIO-Related Targets

1-23

Methods and the Required Permissions

1-23

java.lang.SecurityManager Method Permission Checks

1-48

Default Policy Implementation and Policy File Syntax

1-50

Default Policy Implementation

1-51

Default Policy File Locations

1-51

Modifying the Policy Implementation

1-52

Policy File Syntax

1-53

Policy File Examples

1-58

Property Expansion in Policy Files

1-60

Windows Systems, File Paths, and Property Expansion

1-62

Path-Name Canonicalization

1-63

General Expansion in Policy Files

1-65

API for Privileged Blocks

2

1-22

1-66

Using the doPrivileged API

1-66

What It Means to Have Privileged Code

1-71

Reflection

1-73

Troubleshooting Security

1-73

Java Cryptography Architecture (JCA) Reference Guide

Introduction to Java Cryptography Architecture

2-1

JCA Design Principles

2-2

Provider Architecture

2-3

Cryptographic Service Providers

2-3

How Providers Are Actually Implemented

2-5

Keystores

2-7

Engine Classes and Algorithms

2-7

Core Classes and Interfaces

2-8

The Provider Class

2-9

How Provider Implementations Are Requested and Supplied

2-10

Installing Providers

2-12

Provider Class Methods

2-12

The Security Class

2-13

Managing Providers

2-14

Security Properties

2-15

The SecureRandom Class

2-15

iv

Creating a SecureRandom Object

2-16

Seeding or Re-Seeding the SecureRandom Object

2-16

Using a SecureRandom Object

2-17

Generating Seed Bytes

2-17

The MessageDigest Class

2-17

Creating a MessageDigest Object

2-17

Updating a Message Digest Object

2-18

Computing the Digest

2-18

The Signature Class

2-18

Signature Object States

2-19

Creating a Signature Object

2-19

Initializing a Signature Object

2-20

Signing with a Signature Object

2-20

Verifying with a Signature Object

2-21

The Cipher Class

2-21

Other Cipher-based Classes

2-29

The Cipher Stream Classes

2-30

The SealedObject Class

2-32

The Mac Class

2-34

Key Interfaces

2-35

The KeyPair Class

2-37

Key Specification Interfaces and Classes

2-37

The KeySpec Interface

2-37

The KeySpec Subinterfaces

2-37

The EncodedKeySpec Class

2-38

Generators and Factories

2-39

The KeyFactory Class

2-39

The SecretKeyFactory Class

2-40

The KeyPairGenerator Class

2-42

The KeyGenerator Class

2-44

The KeyAgreement Class

2-45

Key Management

2-47

The KeyStore Class

Algorithm Parameters Classes

2-48

2-52

The AlgorithmParameterSpec Interface

2-52

The AlgorithmParameters Class

2-53

The AlgorithmParameterGenerator Class

2-54

The CertificateFactory Class

2-55

How the JCA Might Be Used in a SSL/TLS Implementation

2-56

Cryptographic Strength Configuration

2-58

Jurisdiction Policy File Format

2-61

v

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download