001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.util.asn1.misc; 019 020 import org.apache.geronimo.util.asn1.*; 021 022 /** 023 * The NetscapeCertType object. 024 * <pre> 025 * NetscapeCertType ::= BIT STRING { 026 * SSLClient (0), 027 * SSLServer (1), 028 * S/MIME (2), 029 * Object Signing (3), 030 * Reserved (4), 031 * SSL CA (5), 032 * S/MIME CA (6), 033 * Object Signing CA (7) } 034 * </pre> 035 */ 036 public class NetscapeCertType 037 extends DERBitString 038 { 039 public static final int sslClient = (1 << 7); 040 public static final int sslServer = (1 << 6); 041 public static final int smime = (1 << 5); 042 public static final int objectSigning = (1 << 4); 043 public static final int reserved = (1 << 3); 044 public static final int sslCA = (1 << 2); 045 public static final int smimeCA = (1 << 1); 046 public static final int objectSigningCA = (1 << 0); 047 048 /** 049 * Basic constructor. 050 * 051 * @param usage - the bitwise OR of the Key Usage flags giving the 052 * allowed uses for the key. 053 * e.g. (X509NetscapeCertType.sslCA | X509NetscapeCertType.smimeCA) 054 */ 055 public NetscapeCertType( 056 int usage) 057 { 058 super(getBytes(usage), getPadBits(usage)); 059 } 060 061 public NetscapeCertType( 062 DERBitString usage) 063 { 064 super(usage.getBytes(), usage.getPadBits()); 065 } 066 067 public String toString() 068 { 069 return "NetscapeCertType: 0x" + Integer.toHexString(data[0] & 0xff); 070 } 071 }