1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package org.apache.wss4j.common.crypto; 21 22 import java.math.BigInteger; 23 24 /** 25 * This class represents a way of passing information to the Crypto.getX509Certificates() method. 26 * The TYPE enum describes which method to use to retrieve the Certificate(s). The corresponding 27 * get accessor must be set accordingly. 28 */ 29 public class CryptoType { 30 31 /** 32 * TYPE.ISSUER_SERIAL - A certificate (chain) is located by the issuer name and serial number 33 * TYPE.THUMBPRINT_SHA1 - A certificate (chain) is located by the SHA1 of the (root) cert 34 * TYPE.SKI_BYTES - A certificate (chain) is located by the SKI bytes of the (root) cert 35 * TYPE.SUBJECT_DN - A certificate (chain) is located by the Subject DN of the (root) cert 36 * TYPE.ALIAS - A certificate (chain) is located by an alias. This alias is implementation 37 * specific, for example - it could be a java KeyStore alias. 38 */ 39 public enum TYPE { 40 ISSUER_SERIAL, THUMBPRINT_SHA1, SKI_BYTES, SUBJECT_DN, ALIAS, ENDPOINT 41 } 42 43 private TYPE type; 44 private String issuer; 45 private BigInteger serial; 46 private byte[] bytes; 47 private String subjectDN; 48 private String alias; 49 private String endpoint; 50 51 /** 52 * Default constructor 53 */ 54 public CryptoType() { 55 // 56 } 57 58 /** 59 * Constructor with a TYPE argument 60 * @param type describes which method to use to retrieve a certificate (chain) 61 */ 62 public CryptoType(TYPE type) { 63 this.type = type; 64 } 65 66 /** 67 * Set the type. 68 * @param type describes which method to use to retrieve a certificate (chain) 69 */ 70 public void setType(TYPE type) { 71 this.type = type; 72 } 73 74 /** 75 * Get the type 76 * @return which method to use to retrieve a certificate (chain) 77 */ 78 public TYPE getType() { 79 return type; 80 } 81 82 /** 83 * Set the Issuer String, and Serial number of the cert (chain) to retrieve. 84 * @param issuer the issuer String 85 * @param serial the serial number 86 */ 87 public void setIssuerSerial(String issuer, BigInteger serial) { 88 this.issuer = issuer; 89 this.serial = serial; 90 } 91 92 /** 93 * Get the issuer String. 94 * @return the issuer String 95 */ 96 public String getIssuer() { 97 return issuer; 98 } 99 100 /** 101 * Get the serial number 102 * @return the serial number 103 */ 104 public BigInteger getSerial() { 105 return serial; 106 } 107 108 /** 109 * Set the byte[], which could be the SHA1 thumbprint, or SKI bytes of the cert. 110 * @param bytes an array of bytes 111 */ 112 public void setBytes(byte[] bytes) { 113 this.bytes = bytes; 114 } 115 116 /** 117 * Get the array of bytes, which could be the SHA1 thumbprint, or SKI bytes of the cert. 118 * @return an array of bytes 119 */ 120 public byte[] getBytes() { 121 return bytes; 122 } 123 124 /** 125 * Set the Subject DN of the cert (chain) to locate 126 * @param subjectDN the Subject DN of the cert (chain) to locate 127 */ 128 public void setSubjectDN(String subjectDN) { 129 this.subjectDN = subjectDN; 130 } 131 132 /** 133 * Get the Subject DN of the cert (chain) to locate 134 * @return the Subject DN of the cert (chain) to locate 135 */ 136 public String getSubjectDN() { 137 return subjectDN; 138 } 139 140 /** 141 * Set the alias of the cert (chain) to locate. 142 * @param alias the alias of the cert (chain) to locate. 143 */ 144 public void setAlias(String alias) { 145 this.alias = alias; 146 } 147 148 /** 149 * Get the alias of the cert (chain) to locate. 150 * @return the alias of the cert (chain) to locate. 151 */ 152 public String getAlias() { 153 return alias; 154 } 155 156 /** 157 * Set the endpoint to locate certificate. 158 * @param endpoint to locate. 159 */ 160 public void setEndpoint(String endpoint) { 161 this.endpoint = endpoint; 162 } 163 164 /** 165 * Get the endpoint to locate certificate. 166 * @return endpoint to locate certificate. 167 */ 168 public String getEndpoint() { 169 return endpoint; 170 } 171 172 }