001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: AMAttributeSchema.java,v 1.3 2008/06/25 05:41:19 qcheng Exp $ 026 * 027 */ 028 029package com.iplanet.am.sdk; 030 031import java.util.Set; 032 033import com.iplanet.sso.SSOException; 034import com.sun.identity.sm.AttributeSchema; 035import com.sun.identity.sm.SMSException; 036 037/** 038 * The class <code>AMAttributeSchema</code> provides the interfaces to obtain 039 * meta information about service configuration variable. 040 * 041 * @deprecated This class has been deprecated. Please use 042 * <code>com.sun.identity.sm.AttributeSchema</code>. 043 * @supported.all.api 044 */ 045public class AMAttributeSchema extends Object { 046 047 /** 048 * The <code>TYPE_SINGLE</code> attribute type specifies that the 049 * attribute can have only a single value 050 */ 051 public static final int TYPE_SINGLE = 1; 052 053 /** 054 * The <code>TYPE_LIST</code> attribute type specifies that the attribute 055 * can have multiple values, i.e., multi-valued attribute 056 */ 057 public static final int TYPE_LIST = 2; 058 059 /** 060 * The <code>TYPE_SINGLE_CHOICE</code> attribute type specifies that the 061 * attribute can have value defined by the <code>getChoiceValues</code> 062 * method of <code>AMAttributeSchema</code>. 063 */ 064 public static final int TYPE_SINGLE_CHOICE = 3; 065 066 /** 067 * The <code>TYPE_MULTIPLE_CHOICE</code> attribute type specifies that the 068 * attribute can have multiple values defined by the 069 * <code>getChoiceValues</code> method of <code>AMAttributeSchema</code>. 070 */ 071 public static final int TYPE_MULTIPLE_CHOICE = 4; 072 073 /** 074 * The <code>TYPE_SIGNATURE</code> attribute type specifies that the 075 * attribute is a signing attribute. 076 */ 077 public static final int TYPE_SIGNATURE = 20; 078 079 /** 080 * The <code>VALIDATOR</code> attribute type specifies that the attribute 081 * defines a attribute validator plugin. 082 */ 083 public static final int TYPE_VALIDATOR = 21; 084 085 /** 086 * The <code>UITYPE_RADIO</code> attribute type specifies that the 087 * attribute should be display as a radio button. 088 */ 089 public static final int UITYPE_RADIO = 22; 090 091 /** 092 * The <code>UITYPE_LINK</code> attribute type specifies that the 093 * attribute should be display as a link. 094 */ 095 public static final int UITYPE_LINK = 23; 096 097 /** 098 * The <code>UITYPE_BUTTON</code> attribute type specifies that the 099 * attribute should be display as a button. 100 */ 101 public static final int UITYPE_BUTTON = 24; 102 103 /** 104 * The <code>UITYPE_UNDEFINED</code> attribute type specifies that the UI 105 * type is not defined. 106 */ 107 public static final int UITYPE_UNDEFINED = 25; 108 109 /** 110 * The <code>SYNTAX_BOOLEAN</code> attribute syntax specifies that the 111 * attribute is of boolean type, i.e., can have a value of either 112 * <code>true</code> or <code> 113 * false</code> 114 */ 115 public static final int SYNTAX_BOOLEAN = 5; 116 117 /** 118 * The <code>SYNTAX_EMAIL</code> attribute syntax specifies that the 119 * attribute is a email address. 120 */ 121 public static final int SYNTAX_EMAIL = 6; 122 123 /** 124 * The <code>SYNTAX_URL</code> attribute syntax specifies that the 125 * attribute is a URL. 126 */ 127 public static final int SYNTAX_URL = 7; 128 129 /** 130 * The <code>SYNTAX_STRING</code> attribute syntax specifies that the 131 * attribute is of text type, i.e., can have any unicode characters 132 */ 133 public static final int SYNTAX_STRING = 8; 134 135 /** 136 * The <code>SYNTAX_PASSWORD</code> attribute syntax specifies that the 137 * attribute is of password type, will be used by UI to mask the password 138 * typed. 139 */ 140 public static final int SYNTAX_PASSWORD = 9; 141 142 /** 143 * The <code>SYNTAX_NUMERIC</code> attribute syntax specifies that the 144 * attribute is numeric, i.e., can have numbers only. 145 */ 146 public static final int SYNTAX_NUMERIC = 10; 147 148 /** 149 * The <code>SYNTAX_NUMBER</code> attribute syntax specifies that the 150 * attribute is a number. 151 */ 152 public static final int SYNTAX_NUMBER = 11; 153 154 /** 155 * The <code>SYNTAX_PERCENT</code> attribute syntax specifies that the 156 * attribute is a percentage. 157 */ 158 public static final int SYNTAX_PERCENT = 12; 159 160 /** 161 * The <code>SYNTAX_NUMBER_RANGE</code> attribute syntax specifies that 162 * the attribute is a number within a range. 163 */ 164 public static final int SYNTAX_NUMBER_RANGE = 13; 165 166 /** 167 * The <code>SYNTAX_DECIMAL_RANGE</code> attribute syntax specifies that 168 * the attribute is a decimal number within a range. 169 */ 170 public static final int SYNTAX_DECIMAL_RANGE = 14; 171 172 /** 173 * The <code>SYNTAX_DECIMAL_NUMBER</code> attribute syntax specifies that 174 * the attribute is a floating point number, e.g., 1.5, 3.56, etc. 175 */ 176 public static final int SYNTAX_DECIMAL_NUMBER = 15; 177 178 /** 179 * The <code>SYNTAX_DN</code> attribute syntax specifies that the 180 * attribute should be an LDAP distinguished name (DN). 181 */ 182 public static final int SYNTAX_DN = 16; 183 184 /** 185 * The <code>SYNTAX_PARAGRAPH</code> attribute syntax specifies that the 186 * attribute should be a paragraph 187 */ 188 public static final int SYNTAX_PARAGRAPH = 17; 189 190 /** 191 * The <code>SYNTAX_DATE</code> attribute syntax specifies that the 192 * attribute should be a date 193 */ 194 public static final int SYNTAX_DATE = 18; 195 196 /** 197 * The <code>SYNTAX_XML</code> attribute syntax specifies that the 198 * attribute should be a XML blob 199 */ 200 public static final int SYNTAX_XML = 19; 201 202 /** 203 * The <code>SYNTAX_ENCRYPTED_PASSWORD</code> attribute syntax specifies 204 * that the attribute is of password type, will be used by UI to mask the 205 * password typed. 206 */ 207 public static final int SYNTAX_ENCRYPTED_PASSWORD = 20; 208 209 /** 210 * The <code>SYNTAX_SCRIPT</code> attribute syntax specifies that the 211 * attribute should be a script 212 */ 213 public static final int SYNTAX_SCRIPT = 21; 214 215 private AttributeSchema attrSchema; 216 217 protected AMAttributeSchema(AttributeSchema as) { 218 attrSchema = as; 219 } 220 221 /** 222 * The method returns the name of the attribute 223 * 224 * @return name of the attribute 225 */ 226 public String getName() { 227 return attrSchema.getName(); 228 } 229 230 /** 231 * The method returns the type of the attribute i.e., single, list or choice 232 * 233 * @return the type of the attribute. 234 */ 235 public int getType() { 236 String type = attrSchema.getType().toString(); 237 238 // Map the SMS attribute type to public attribute type 239 if (type.equals(AttributeSchema.Type.SINGLE.toString())) 240 return TYPE_SINGLE; 241 else if (type.equals(AttributeSchema.Type.LIST.toString())) 242 return TYPE_LIST; 243 else if (type.equals(AttributeSchema.Type.SINGLE_CHOICE.toString())) 244 return TYPE_SINGLE_CHOICE; 245 else if (type.equals(AttributeSchema.Type.MULTIPLE_CHOICE.toString())) 246 return TYPE_MULTIPLE_CHOICE; 247 else if (type.equals(AttributeSchema.Type.SIGNATURE.toString())) 248 return TYPE_SIGNATURE; 249 else if (type.equals(AttributeSchema.Type.VALIDATOR.toString())) 250 return TYPE_VALIDATOR; 251 252 return -1; // Should'nt occur 253 } 254 255 /** 256 * The method returns the UI type of the attribute i.e., link, button, ... 257 * 258 * @return the UI type of the attribute; <code>UITYPE_UNDEFINED</code> if 259 * the UI type is not defined for the attribute 260 */ 261 public int getUIType() { 262 AttributeSchema.UIType uitype = attrSchema.getUIType(); 263 264 // Map the SMS attribute UI type to public attribute type 265 if (uitype == null) { 266 // UI type not defined 267 return UITYPE_UNDEFINED; 268 } else if (uitype.equals(AttributeSchema.UIType.RADIO)) { 269 return UITYPE_RADIO; 270 } else if (uitype.equals(AttributeSchema.UIType.LINK)) { 271 return UITYPE_LINK; 272 } else if (uitype.equals(AttributeSchema.UIType.BUTTON)) { 273 return UITYPE_BUTTON; 274 } 275 276 return UITYPE_UNDEFINED; 277 } 278 279 /** 280 * The method returns the syntax of the attribute i.e., string, boolean, 281 * distinguished name (String), numeric. 282 * 283 * @return syntax of the attribute 284 */ 285 public int getSyntax() { 286 String syntax = attrSchema.getSyntax().toString(); 287 288 // Map the SMS attribute type to public attribute type 289 if (syntax.equals(AttributeSchema.Syntax.BOOLEAN.toString())) 290 return SYNTAX_BOOLEAN; 291 else if (syntax.equals(AttributeSchema.Syntax.EMAIL.toString())) 292 return SYNTAX_EMAIL; 293 else if (syntax.equals(AttributeSchema.Syntax.URL.toString())) 294 return SYNTAX_URL; 295 else if (syntax.equals(AttributeSchema.Syntax.STRING.toString())) 296 return SYNTAX_STRING; 297 else if (syntax.equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD 298 .toString())) 299 return SYNTAX_ENCRYPTED_PASSWORD; 300 else if (syntax.equals(AttributeSchema.Syntax.PASSWORD.toString())) 301 return SYNTAX_PASSWORD; 302 else if (syntax.equals(AttributeSchema.Syntax.NUMERIC.toString())) 303 return SYNTAX_NUMERIC; 304 else if (syntax.equals(AttributeSchema.Syntax.NUMBER.toString())) 305 return SYNTAX_NUMBER; 306 else if (syntax.equals(AttributeSchema.Syntax.PERCENT.toString())) 307 return SYNTAX_PERCENT; 308 else if (syntax.equals(AttributeSchema.Syntax.NUMBER_RANGE.toString())) 309 return SYNTAX_NUMBER_RANGE; 310 else if (syntax.equals(AttributeSchema.Syntax.DECIMAL_RANGE.toString())) 311 return SYNTAX_DECIMAL_RANGE; 312 else if (syntax 313 .equals(AttributeSchema.Syntax.DECIMAL_NUMBER.toString())) 314 return SYNTAX_DECIMAL_NUMBER; 315 else if (syntax.equals(AttributeSchema.Syntax.DN.toString())) 316 return SYNTAX_DN; 317 else if (syntax.equals(AttributeSchema.Syntax.PARAGRAPH.toString())) 318 return SYNTAX_PARAGRAPH; 319 else if (syntax.equals(AttributeSchema.Syntax.XML.toString())) 320 return SYNTAX_XML; 321 else if (syntax.equals(AttributeSchema.Syntax.DATE.toString())) 322 return SYNTAX_DATE; 323 else if (syntax.equals(AttributeSchema.Syntax.SCRIPT.toString())) 324 return SYNTAX_SCRIPT; 325 326 return -1; 327 } 328 329 /** 330 * Returns the value of the <code>cosQualifier</code> for this attribute 331 * that is default or merge-schemes. 332 * 333 * @return String value of <code>cosQualifier</code>. 334 */ 335 public String getCosQualifier() { 336 return attrSchema.getCosQualifier(); 337 } 338 339 /** 340 * The method returns the default value of the attribute; 341 * 342 * @return Set containing the default values of the attribute or 343 * <code>Collections.EMPTY_SET<code> otherwise 344 */ 345 public Set getDefaultValues() { 346 return attrSchema.getDefaultValues(); 347 } 348 349 /** 350 * If the attribute is of choice type, this method returns the possible 351 * values for the attribute; <code>null</code> otherwise 352 * 353 * @return String array of possible choice values; null otherwise 354 */ 355 public String[] getChoiceValues() { 356 return attrSchema.getChoiceValues(); 357 } 358 359 /** 360 * Given a choice value, this method returns the i18nKey for that choice 361 * value 362 * 363 * @param cValue 364 * the choice value 365 * @return the i18N key corresponding to the choice value 366 */ 367 public String getChoiceValueI18NKey(String cValue) { 368 return attrSchema.getChoiceValueI18NKey(cValue); 369 } 370 371 /** 372 * Returns I18N key to describe the configuration attribute. 373 * 374 * @return i18n index key to the resource bundle 375 */ 376 public String getI18NKey() { 377 return attrSchema.getI18NKey(); 378 } 379 380 /** 381 * Set I18N key to describe the configuration attribute 382 * 383 * @param i18nKey 384 * value of <code>i18nKey</code>. 385 * @throws AMException 386 */ 387 public void setI18NKey(String i18nKey) throws AMException { 388 try { 389 attrSchema.setI18NKey(i18nKey); 390 } catch (SMSException se) { 391 AMCommonUtils.debug.message( 392 "AMAttributeSchema.setAttributeDefaults(Map): ", se); 393 throw new AMException(AMSDKBundle.getString("916"), "916"); 394 } catch (SSOException so) { 395 AMCommonUtils.debug.message( 396 "AMAttributeSchema.setAttributeDefaults(Map): ", so); 397 throw new AMException(AMSDKBundle.getString("916"), "916"); 398 } 399 } 400 401 /** 402 * Method to get starting range for possible values of the attribute 403 * 404 * @return starting range for the attribute value 405 */ 406 public String getStartRange() { 407 return attrSchema.getStartRange(); 408 } 409 410 /** 411 * Method to get ending range for possible values of the attribute 412 * 413 * @return ending range for the attribute value 414 */ 415 public String getEndRange() { 416 return attrSchema.getEndRange(); 417 } 418 419 /** 420 * Method to get service specific attributes. It return the value of the 421 * "any" attribute, if set in the XML schema for the service 422 * 423 * @return value of "any" attribute 424 */ 425 public String getAny() { 426 return attrSchema.getAny(); 427 } 428 429 /** 430 * Returns URL of the view bean for the attribute. 431 * 432 * @return URL for view bean 433 */ 434 public String getPropertiesViewBeanURL() { 435 return attrSchema.getPropertiesViewBeanURL(); 436 } 437 438 /** 439 * Method to get the string value for "TRUE" 440 * 441 * @return String for TRUE value 442 */ 443 public String getTrueValue() { 444 return attrSchema.getTrueValue(); 445 } 446 447 /** 448 * Method to get the i18n Key for <code>BooleanTrueValue</code>. 449 * 450 * @return String i18nKey for TRUE value 451 */ 452 public String getTrueValueI18NKey() { 453 return attrSchema.getTrueValueI18NKey(); 454 } 455 456 /** 457 * Method to get string value for "FALSE" 458 * 459 * @return String for FALSE value 460 */ 461 public String getFalseValue() { 462 return attrSchema.getFalseValue(); 463 } 464 465 /** 466 * Method to get the i18n Key for <code>BooleanFalseValue</code>. 467 * 468 * @return String i18nKey for FALSE value. 469 */ 470 public String getFalseValueI18NKey() { 471 return attrSchema.getFalseValueI18NKey(); 472 } 473 474 /** 475 * Method that returns the String representation of the 476 * <code>AMAttributeSchema</code>. 477 * 478 * @return String representation of the <code>AMAttributeSchema</code>/ 479 */ 480 public String toString() { 481 return attrSchema.toString(); 482 } 483}
Copyright © 2010-2017, ForgeRock All Rights Reserved.