View Javadoc
1 /* 2 * ==================================================================== 3 * 4 * This code is subject to the freebxml License, Version 1.1 5 * 6 * Copyright (c) 2003 freebxml.org. All rights reserved. 7 * 8 * ==================================================================== 9 */ 10 package com.sun.xml.registry.client.browser.registration; 11 12 import com.sun.xml.registry.client.browser.RegistryBrowser; 13 import javax.xml.registry.JAXRException; 14 import javax.xml.registry.infomodel.InternationalString; 15 import javax.xml.registry.infomodel.User; 16 17 import com.sun.xml.registry.client.browser.swing.Model; 18 import com.sun.xml.registry.ebxml.infomodel.InternationalStringImpl; 19 import com.sun.xml.registry.ebxml.util.ProviderProperties; 20 21 /*** 22 * Wrapper around {@link javax.xml.registry.infomodel.User}. This allows 23 * us to check the validity of the input. Usually one would do that in the 24 * model itself (i.e. class User), but an extra layer inbetween gives us 25 * more flexibility. 26 * 27 * @author Fabian Ritzmann 28 */ 29 public class UserModel implements Model { 30 31 private final User user; 32 private final PersonNameModel personName; 33 private final EmailAddressModel emailAddress; 34 private final PostalAddressModel postalAddress; 35 private final TelephoneNumberModel phoneNumber; 36 private String alias = null; 37 private char[] keyPassword = null; 38 private char[] storePassword = null; 39 40 41 /*** 42 * @param u Underlying User implementation 43 */ 44 public UserModel(User u) throws JAXRException { 45 this.user = u; 46 this.personName = new PersonNameModel(u); 47 this.emailAddress = new EmailAddressModel(u); 48 this.postalAddress = new PostalAddressModel(u); 49 this.phoneNumber = new TelephoneNumberModel(u); 50 // hard coded for now: 51 this.storePassword = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.storepass").toCharArray(); 52 } 53 54 55 public User getUser() { 56 return this.user; 57 } 58 59 60 /*** 61 * Method setAlias. 62 * @param text 63 */ 64 public void setAlias(String text) { 65 this.alias = text.trim(); 66 } 67 68 69 /*** 70 * Method setKeyPassword. 71 * @param text 72 */ 73 public void setKeyPassword(char[] text) { 74 // Don't trim text here. It's not a good idea to use whitespace 75 // in a password, but if somebody does, it shouldn't be changed. 76 this.keyPassword = text; 77 } 78 79 80 public void setStorePassword(char[] text) { 81 this.storePassword = text; 82 } 83 84 85 /*** 86 * Method getAlias. 87 */ 88 public String getAlias() { 89 return this.alias; 90 } 91 92 93 /*** 94 * Method getKeyPassword. 95 */ 96 public char[] getKeyPassword() { 97 return this.keyPassword; 98 } 99 100 101 /*** 102 * Method getStorePassword. 103 */ 104 public char[] getStorePassword() { 105 return this.storePassword; 106 } 107 108 109 /*** 110 * Method getPersonNameModel. 111 */ 112 public PersonNameModel getPersonNameModel() { 113 return this.personName; 114 } 115 116 117 /*** 118 * Method getEmailAddressModel. 119 */ 120 public EmailAddressModel getEmailAddressModel() { 121 return this.emailAddress; 122 } 123 124 125 /*** 126 * Method getPostalAddressModel. 127 */ 128 public PostalAddressModel getPostalAddressModel() { 129 return this.postalAddress; 130 } 131 132 133 /*** 134 * Method getTelephoneNumberModel. 135 */ 136 public TelephoneNumberModel getTelephoneNumberModel() { 137 return this.phoneNumber; 138 } 139 140 141 public void validate() throws JAXRException { 142 143 this.personName.validate(); 144 this.emailAddress.validate(); 145 this.postalAddress.validate(); 146 this.phoneNumber.validate(); 147 148 // TO DO: Review JAXR implementation dependency 149 InternationalStringImpl roName = (InternationalStringImpl)this.user.getName(); 150 if ((roName == null) || (roName.getClosestValue() == null) 151 || (roName.getClosestValue().trim().length() == 0)) { 152 153 String name = this.user.getPersonName().getFullName(); 154 roName = (InternationalStringImpl)this.user.getLifeCycleManager().createInternationalString(name); 155 this.user.setName(roName); 156 } 157 158 if ((this.alias == null) || (this.alias.length() < 3)) { 159 throw new JAXRException("Keystore Alias must be at least 3 characters"); 160 } 161 if ((this.keyPassword == null) || (this.keyPassword.length < 6)) { 162 throw new JAXRException("Private Key Password must be at least 6 characters"); 163 } 164 if ((this.storePassword == null) || (this.storePassword.length < 6)) { 165 throw new JAXRException("Key Store password must be at least 6 characters"); 166 } 167 } 168 169 }

This page was automatically generated by Maven