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 */ 017package org.apache.juneau.bean.html5; 018 019import org.apache.juneau.marshall.*; 020 021/** 022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#the-keygen-element"><keygen></a> 023 * element. 024 * 025 * <p> 026 * The keygen element represents a key-pair generator control for forms. It generates a public/private 027 * key pair and submits the public key to the server. This element is deprecated in HTML5 and should 028 * not be used in new projects. Modern web applications should use Web Crypto API instead. 029 * 030 * <h5 class='section'>Examples:</h5> 031 * <p class='bcode w800'> 032 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 033 * 034 * <jc>// Basic keygen with RSA key type</jc> 035 * Keygen <jv>keygen1</jv> = <jsm>keygen</jsm>() 036 * .name(<js>"userkey"</js>) 037 * .keytype(<js>"RSA"</js>); 038 * 039 * <jc>// Keygen with challenge string</jc> 040 * Keygen <jv>keygen2</jv> = <jsm>keygen</jsm>() 041 * .name(<js>"certkey"</js>) 042 * .keytype(<js>"RSA"</js>) 043 * .challenge(<js>"server-challenge-string"</js>); 044 * 045 * <jc>// Keygen with form association</jc> 046 * Keygen <jv>keygen3</jv> = <jsm>keygen</jsm>() 047 * .name(<js>"formkey"</js>) 048 * .keytype(<js>"DSA"</js>) 049 * .form(<js>"myform"</js>); 050 * 051 * <jc>// Keygen with disabled state</jc> 052 * Keygen <jv>keygen4</jv> = <jsm>keygen</jsm>() 053 * .name(<js>"disabledkey"</js>) 054 * .keytype(<js>"RSA"</js>) 055 * .disabled(<jk>true</jk>); 056 * </p> 057 * 058 * <p> 059 * The following convenience methods are provided for constructing instances of this bean: 060 * <ul class='javatree'> 061 * <li class='jc'>{@link HtmlBuilder} 062 * <ul class='javatree'> 063 * <li class='jm'>{@link HtmlBuilder#keygen() keygen()} 064 * </ul> 065 * </ul> 066 * </p> 067 * 068 * <h5 class='section'>See Also:</h5><ul> 069 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 070 * </ul> 071 */ 072@Marshalled(typeName = "keygen") 073public class Keygen extends HtmlElementVoid<Keygen> { 074 075 /** 076 * Creates an empty {@link Keygen} element. 077 */ 078 public Keygen() { /* Empty constructor. */ } 079 080 /** 081 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-autofocus">autofocus</a> attribute. 082 * 083 * <p> 084 * Automatically focus the form control when the page is loaded. 085 * 086 * @param value 087 * The new value for this attribute. 088 * Typically a {@link Boolean} or {@link String}. 089 * Can be <jk>null</jk> to unset the attribute. 090 * @return This object. 091 */ 092 public Keygen autofocus(Object value) { 093 attr("autofocus", value); 094 return this; 095 } 096 097 /** 098 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-keygen-challenge">challenge</a> attribute. 099 * 100 * <p> 101 * Specifies a challenge string that will be packaged with the generated and signed public key. 102 * This is used for additional security in key generation processes. 103 * 104 * <p> 105 * The challenge string is typically provided by the server and used to verify the key generation. 106 * 107 * @param value The challenge string to package with the generated key. Can be <jk>null</jk> to unset the attribute. 108 * @return This object. 109 */ 110 public Keygen challenge(String value) { 111 attr("challenge", value); 112 return this; 113 } 114 115 /** 116 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-disabled">disabled</a> attribute. 117 * 118 * <p> 119 * Whether the form control is disabled. 120 * 121 * <p> 122 * This attribute uses deminimized values: 123 * <ul> 124 * <li><jk>false</jk> - Attribute is not added</li> 125 * <li><jk>true</jk> - Attribute is added as <js>"disabled"</js></li> 126 * <li>Other values - Passed through as-is</li> 127 * </ul> 128 * 129 * @param value 130 * The new value for this attribute. 131 * Typically a {@link Boolean} or {@link String}. 132 * Can be <jk>null</jk> to unset the attribute. 133 * @return This object. 134 */ 135 public Keygen disabled(Object value) { 136 attr("disabled", deminimize(value, "disabled")); 137 return this; 138 } 139 140 /** 141 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fae-form">form</a> attribute. 142 * 143 * <p> 144 * Associates the keygen element with a form element by specifying the form's ID. This allows the keygen 145 * to be placed outside the form element while still being part of the form. 146 * 147 * <p> 148 * The value should match the ID of a form element in the same document. 149 * 150 * @param value The ID of the form element to associate with this keygen. Can be <jk>null</jk> to unset the attribute. 151 * @return This object. 152 */ 153 public Keygen form(String value) { 154 attr("form", value); 155 return this; 156 } 157 158 /** 159 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-keygen-keytype">keytype</a> attribute. 160 * 161 * <p> 162 * Specifies the type of cryptographic key to generate. 163 * 164 * <p> 165 * Common values: 166 * <ul> 167 * <li><js>"RSA"</js> - RSA key pair (default)</li> 168 * <li><js>"DSA"</js> - DSA key pair</li> 169 * <li><js>"EC"</js> - Elliptic curve key pair</li> 170 * </ul> 171 * 172 * @param value The type of cryptographic key to generate. Can be <jk>null</jk> to unset the attribute. 173 * @return This object. 174 */ 175 public Keygen keytype(String value) { 176 attr("keytype", value); 177 return this; 178 } 179 180 /** 181 * <a class="doclink" href="https://www.w3.org/TR/html5/forms.html#attr-fe-name">name</a> attribute. 182 * 183 * <p> 184 * Specifies the name of the keygen element. This name is used when the form is submitted and 185 * can be used to access the element via the form.elements API. 186 * 187 * <p> 188 * The name should be unique within the form and should not contain spaces or special characters. 189 * 190 * @param value The name of the keygen element for submission and API access. Can be <jk>null</jk> to unset the attribute. 191 * @return This object. 192 */ 193 public Keygen name(String value) { 194 attr("name", value); 195 return this; 196 } 197 198}