1 package org.ejbca.core.protocol.ws; 2 3 import java.net.URL ; 4 import java.security.KeyPair ; 5 import java.security.cert.X509Certificate ; 6 import java.util.Enumeration ; 7 import java.util.List ; 8 9 import javax.xml.namespace.QName ; 10 11 import junit.framework.TestCase; 12 13 import org.bouncycastle.jce.PKCS10CertificationRequest; 14 import org.ejbca.core.model.ca.catoken.CATokenConstants; 15 import org.ejbca.core.model.ca.crl.RevokedCertInfo; 16 import org.ejbca.core.protocol.ws.client.gen.Certificate; 17 import org.ejbca.core.protocol.ws.client.gen.EjbcaException_Exception; 18 import org.ejbca.core.protocol.ws.client.gen.EjbcaWS; 19 import org.ejbca.core.protocol.ws.client.gen.EjbcaWSService; 20 import org.ejbca.core.protocol.ws.client.gen.KeyStore; 21 import org.ejbca.core.protocol.ws.client.gen.RevokeStatus; 22 import org.ejbca.core.protocol.ws.client.gen.UserDataVOWS; 23 import org.ejbca.core.protocol.ws.client.gen.UserMatch; 24 import org.ejbca.core.protocol.ws.common.CertificateHelper; 25 import org.ejbca.core.protocol.ws.common.KeyStoreHelper; 26 import org.ejbca.util.Base64; 27 import org.ejbca.util.CertTools; 28 import org.ejbca.util.KeyTools; 29 30 35 public class TestEjbcaWS extends TestCase { 36 37 private static EjbcaWS ejbcaraws; 38 39 40 protected void setUp() throws Exception { 41 super.setUp(); 42 CertTools.installBCProvider(); 43 44 String urlstr = "https://localhost:8443/ejbca/ejbcaws/ejbcaws?wsdl"; 45 46 System.out.println("Contacting webservice at " + urlstr); 47 48 System.setProperty("javax.net.ssl.trustStore","p12/wstest.jks"); 49 System.setProperty("javax.net.ssl.trustStorePassword","foo123"); 50 51 System.setProperty("javax.net.ssl.keyStore","p12/wstest.jks"); 52 System.setProperty("javax.net.ssl.keyStorePassword","foo123"); 53 54 55 56 QName qname = new QName ("http://ws.protocol.core.ejbca.org/", "EjbcaWSService"); 57 EjbcaWSService service = new EjbcaWSService(new URL (urlstr),qname); 58 ejbcaraws = service.getEjbcaWSPort(); 59 } 60 61 public void test01EditUser() throws Exception { 62 63 UserDataVOWS user1 = new UserDataVOWS(); 65 user1.setUsername("WSTESTUSER1"); 66 user1.setPassword("foo123"); 67 user1.setClearPwd(true); 68 user1.setSubjectDN("CN=WSTESTUSER1"); 69 user1.setCaName("AdminCA1"); 70 user1.setEmail(null); 71 user1.setSubjectAltName(null); 72 user1.setStatus(10); 73 user1.setTokenType("USERGENERATED"); 74 user1.setEndEntityProfileName("EMPTY"); 75 user1.setCertificateProfileName("ENDUSER"); 76 77 ejbcaraws.editUser(user1); 78 79 UserMatch usermatch = new UserMatch(); 80 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 81 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 82 usermatch.setMatchvalue("WSTESTUSER1"); 83 84 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 85 assertTrue(userdatas != null); 86 assertTrue(userdatas.size() == 1); 87 UserDataVOWS userdata = userdatas.get(0); 88 assertTrue(userdata.getUsername().equals("WSTESTUSER1")); 89 assertTrue(userdata.getPassword() == null); 90 assertTrue(!userdata.isClearPwd()); 91 assertTrue(userdata.getSubjectDN().equals("CN=WSTESTUSER1")); 92 assertTrue(userdata.getCaName().equals("AdminCA1")); 93 assertTrue(userdata.getSubjectAltName() == null); 94 assertTrue(userdata.getEmail() == null); 95 assertTrue(userdata.getCertificateProfileName().equals("ENDUSER")); 96 assertTrue(userdata.getEndEntityProfileName().equals("EMPTY")); 97 assertTrue(userdata.getTokenType().equals("USERGENERATED")); 98 assertTrue(userdata.getStatus() == 10); 99 100 userdata.setSubjectDN("CN=WSTESTUSER1,O=Test"); 102 ejbcaraws.editUser(userdata); 103 List <UserDataVOWS> userdatas2 = ejbcaraws.findUser(usermatch); 104 assertTrue(userdatas2 != null); 105 assertTrue(userdatas2.size() == 1); 106 UserDataVOWS userdata2 = userdatas.get(0); 107 assertTrue(userdata2.getSubjectDN().equals("CN=WSTESTUSER1,O=Test")); 108 109 } 110 111 public void test02findUser() throws Exception { 112 UserMatch usermatch = new UserMatch(); 114 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 115 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 116 usermatch.setMatchvalue("WSTESTUSER2"); 117 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 118 assertTrue(userdatas != null); 119 assertTrue(userdatas.size() == 0); 120 121 usermatch = new UserMatch(); 123 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 124 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 125 usermatch.setMatchvalue("WSTESTUSER1"); 126 127 List <UserDataVOWS> userdatas2 = ejbcaraws.findUser(usermatch); 128 assertTrue(userdatas2 != null); 129 assertTrue(userdatas2.size() == 1); 130 131 usermatch = new UserMatch(); 133 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_ORGANIZATION); 134 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_BEGINSWITH); 135 usermatch.setMatchvalue("Te"); 136 List <UserDataVOWS> userdatas3 = ejbcaraws.findUser(usermatch); 137 assertTrue(userdatas3 != null); 138 assertTrue(userdatas3.size() == 1); 139 assertTrue(userdatas3.get(0).getSubjectDN().equals("CN=WSTESTUSER1,O=Test")); 140 141 usermatch = new UserMatch(); 143 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_DN); 144 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_CONTAINS); 145 usermatch.setMatchvalue("WSTESTUSER1"); 146 List <UserDataVOWS> userdatas4 = ejbcaraws.findUser(usermatch); 147 assertTrue(userdatas4 != null); 148 assertTrue(userdatas4.size() == 1); 149 assertTrue(userdatas4.get(0).getSubjectDN().equals("CN=WSTESTUSER1,O=Test")); 150 151 usermatch = new UserMatch(); 152 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_ENDENTITYPROFILE); 153 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 154 usermatch.setMatchvalue("EMPTY"); 155 List <UserDataVOWS> userdatas5 = ejbcaraws.findUser(usermatch); 156 assertTrue(userdatas5 != null); 157 assertTrue(userdatas5.size() > 0); 158 159 usermatch = new UserMatch(); 160 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_CERTIFICATEPROFILE); 161 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 162 usermatch.setMatchvalue("ENDUSER"); 163 List <UserDataVOWS> userdatas6 = ejbcaraws.findUser(usermatch); 164 assertTrue(userdatas6 != null); 165 assertTrue(userdatas6.size() > 0); 166 167 usermatch = new UserMatch(); 168 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_CA); 169 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 170 usermatch.setMatchvalue("AdminCA1"); 171 List <UserDataVOWS> userdatas7 = ejbcaraws.findUser(usermatch); 172 assertTrue(userdatas7 != null); 173 assertTrue(userdatas7.size() > 0); 174 175 usermatch = new UserMatch(); 176 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_TOKEN); 177 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 178 usermatch.setMatchvalue("USERGENERATED"); 179 List <UserDataVOWS> userdatas8 = ejbcaraws.findUser(usermatch); 180 assertTrue(userdatas8 != null); 181 assertTrue(userdatas8.size() > 0); 182 } 183 184 public void test03GeneratePkcs10() throws Exception { 185 KeyPair keys = KeyTools.genKeys("1024", CATokenConstants.KEYALGORITHM_RSA); 186 PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest("SHA1WithRSA", 187 CertTools.stringToBcX509Name("CN=NOUSED"), keys.getPublic(), null, keys.getPrivate()); 188 189 Certificate certenv = ejbcaraws.pkcs10Req("WSTESTUSER1","foo123",new String (Base64.encode(pkcs10.getEncoded())),null); 190 191 assertNotNull(certenv); 192 193 X509Certificate cert = (X509Certificate ) CertificateHelper.getCertificate(certenv.getCertificateData()); 194 195 assertNotNull(cert); 196 197 assertTrue(cert.getSubjectDN().toString().equals("CN=WSTESTUSER1,O=Test")); 198 System.out.println("test03GeneratePkcs10() Certificate " +cert.getSubjectDN().toString() + " equals CN=WSTESTUSER1,O=Test"); 199 200 } 201 202 public void test04GeneratePkcs12() throws Exception { 203 204 boolean exceptionThrown = false; 205 try{ 206 ejbcaraws.pkcs12Req("WSTESTUSER1","foo123",null,"1024", CATokenConstants.KEYALGORITHM_RSA); 207 }catch(EjbcaException_Exception e){ 208 exceptionThrown = true; 209 } 210 assertTrue(exceptionThrown); 212 UserMatch usermatch = new UserMatch(); 214 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 215 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 216 usermatch.setMatchvalue("WSTESTUSER1"); 217 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 218 assertTrue(userdatas != null); 219 assertTrue(userdatas.size() == 1); 220 userdatas.get(0).setTokenType("P12"); 221 ejbcaraws.editUser(userdatas.get(0)); 222 223 exceptionThrown = false; 224 try{ 225 ejbcaraws.pkcs12Req("WSTESTUSER1","foo123",null,"1024", CATokenConstants.KEYALGORITHM_RSA); 226 }catch(EjbcaException_Exception e){ 227 exceptionThrown = true; 228 } 229 assertTrue(exceptionThrown); 231 userdatas.get(0).setStatus(10); 233 userdatas.get(0).setPassword("foo456"); 234 userdatas.get(0).setClearPwd(true); 235 ejbcaraws.editUser(userdatas.get(0)); 236 237 KeyStore ksenv = null; 238 try{ 239 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo456",null,"1024", CATokenConstants.KEYALGORITHM_RSA); 240 }catch(EjbcaException_Exception e){ 241 assertTrue(e.getMessage(),false); 242 } 243 244 assertNotNull(ksenv); 245 246 java.security.KeyStore ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo456"); 247 248 assertNotNull(ks); 249 Enumeration en = ks.aliases(); 250 String alias = (String ) en.nextElement(); 251 X509Certificate cert = (X509Certificate ) ks.getCertificate(alias); 252 assertTrue(cert.getSubjectDN().toString().equals("CN=WSTESTUSER1,O=Test")); 253 System.out.println("test03GeneratePkcs12() Certificate " +cert.getSubjectDN().toString() + " equals CN=WSTESTUSER1,O=Test"); 254 255 } 256 257 public void test05findCerts() throws Exception { 258 259 UserMatch usermatch = new UserMatch(); 261 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 262 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 263 usermatch.setMatchvalue("WSTESTUSER1"); 264 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 265 assertTrue(userdatas != null); 266 assertTrue(userdatas.size() == 1); 267 userdatas.get(0).setTokenType("P12"); 268 userdatas.get(0).setStatus(10); 269 userdatas.get(0).setPassword("foo123"); 270 userdatas.get(0).setClearPwd(true); 271 ejbcaraws.editUser(userdatas.get(0)); 272 KeyStore ksenv = null; 273 try{ 274 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo123",null,"1024", CATokenConstants.KEYALGORITHM_RSA); 275 }catch(EjbcaException_Exception e){ 276 assertTrue(e.getMessage(),false); 277 } 278 java.security.KeyStore ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo123"); 279 280 assertNotNull(ks); 281 Enumeration en = ks.aliases(); 282 String alias = (String ) en.nextElement(); 283 X509Certificate gencert = (X509Certificate ) ks.getCertificate(alias); 284 285 List <Certificate > foundcerts = ejbcaraws.findCerts("WSTESTUSER1",false); 286 assertTrue(foundcerts != null); 287 assertTrue(foundcerts.size() > 0); 288 289 boolean certFound = false; 290 for(int i=0;i<foundcerts.size();i++){ 291 X509Certificate cert = (X509Certificate ) CertificateHelper.getCertificate(foundcerts.get(i).getCertificateData()); 292 if(gencert.getSerialNumber().equals(cert.getSerialNumber())){ 293 certFound = true; 294 } 295 } 296 assertTrue(certFound); 297 298 String issuerdn = gencert.getIssuerDN().toString(); 299 String serno = gencert.getSerialNumber().toString(16); 300 301 ejbcaraws.revokeCert(issuerdn,serno, RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 302 303 foundcerts = ejbcaraws.findCerts("WSTESTUSER1",true); 304 assertTrue(foundcerts != null); 305 assertTrue(foundcerts.size() > 0); 306 307 certFound = false; 308 for(int i=0;i<foundcerts.size();i++){ 309 X509Certificate cert = (X509Certificate ) CertificateHelper.getCertificate(foundcerts.get(i).getCertificateData()); 310 if(gencert.getSerialNumber().equals(cert.getSerialNumber())){ 311 certFound = true; 312 } 313 } 314 assertFalse(certFound); 315 316 317 } 318 319 public void test06revokeCert() throws Exception { 320 UserMatch usermatch = new UserMatch(); 321 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 322 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 323 usermatch.setMatchvalue("WSTESTUSER1"); 324 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 325 assertTrue(userdatas != null); 326 assertTrue(userdatas.size() == 1); 327 userdatas.get(0).setTokenType("P12"); 328 userdatas.get(0).setStatus(10); 329 userdatas.get(0).setPassword("foo456"); 330 userdatas.get(0).setClearPwd(true); 331 ejbcaraws.editUser(userdatas.get(0)); 332 333 KeyStore ksenv = null; 334 try{ 335 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo456",null,"1024", CATokenConstants.KEYALGORITHM_RSA); 336 }catch(EjbcaException_Exception e){ 337 assertTrue(e.getMessage(),false); 338 } 339 340 java.security.KeyStore ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo456"); 341 assertNotNull(ks); 342 Enumeration en = ks.aliases(); 343 String alias = (String ) en.nextElement(); 344 X509Certificate cert = (X509Certificate ) ks.getCertificate(alias); 345 assertTrue(cert.getSubjectDN().toString().equals("CN=WSTESTUSER1,O=Test")); 346 347 String issuerdn = cert.getIssuerDN().toString(); 348 String serno = cert.getSerialNumber().toString(16); 349 350 ejbcaraws.revokeCert(issuerdn,serno, RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 351 352 RevokeStatus revokestatus = ejbcaraws.checkRevokationStatus(issuerdn,serno); 353 assertNotNull(revokestatus); 354 assertTrue(revokestatus.getReason() == RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 355 356 assertTrue(revokestatus.getCertificateSN().equals(serno)); 357 assertTrue(revokestatus.getIssuerDN().equals(issuerdn)); 358 assertNotNull(revokestatus.getRevocationDate()); 359 360 } 361 362 public void test07revokeToken() throws Exception { 363 UserMatch usermatch = new UserMatch(); 364 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 365 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 366 usermatch.setMatchvalue("WSTESTUSER1"); 367 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 368 userdatas.get(0).setTokenType("P12"); 369 userdatas.get(0).setStatus(10); 370 userdatas.get(0).setPassword("foo123"); 371 userdatas.get(0).setClearPwd(true); 372 ejbcaraws.editUser(userdatas.get(0)); 373 KeyStore ksenv = null; 374 try{ 375 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo123","12345678","1024", CATokenConstants.KEYALGORITHM_RSA); 376 }catch(EjbcaException_Exception e){ 377 assertTrue(e.getMessage(),false); 378 } 379 java.security.KeyStore ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo123"); 380 381 assertNotNull(ks); 382 Enumeration en = ks.aliases(); 383 String alias = (String ) en.nextElement(); 384 X509Certificate cert1 = (X509Certificate ) ks.getCertificate(alias); 385 386 userdatas.get(0).setStatus(10); 387 userdatas.get(0).setPassword("foo123"); 388 userdatas.get(0).setClearPwd(true); 389 ejbcaraws.editUser(userdatas.get(0)); 390 391 try{ 392 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo123","12345678","1024", CATokenConstants.KEYALGORITHM_RSA); 393 }catch(EjbcaException_Exception e){ 394 assertTrue(e.getMessage(),false); 395 } 396 ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo123"); 397 398 assertNotNull(ks); 399 en = ks.aliases(); 400 alias = (String ) en.nextElement(); 401 X509Certificate cert2 = (X509Certificate ) ks.getCertificate(alias); 402 403 ejbcaraws.revokeToken("12345678",RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 404 405 String issuerdn1 = cert1.getIssuerDN().toString(); 406 String serno1 = cert1.getSerialNumber().toString(16); 407 408 RevokeStatus revokestatus = ejbcaraws.checkRevokationStatus(issuerdn1,serno1); 409 assertNotNull(revokestatus); 410 assertTrue(revokestatus.getReason() == RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 411 412 String issuerdn2 = cert2.getIssuerDN().toString(); 413 String serno2 = cert2.getSerialNumber().toString(16); 414 415 revokestatus = ejbcaraws.checkRevokationStatus(issuerdn2,serno2); 416 assertNotNull(revokestatus); 417 assertTrue(revokestatus.getReason() == RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 418 419 } 420 421 public void test08checkRevokeStatus() throws Exception { 422 UserMatch usermatch = new UserMatch(); 423 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 424 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 425 usermatch.setMatchvalue("WSTESTUSER1"); 426 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 427 userdatas.get(0).setTokenType("P12"); 428 userdatas.get(0).setStatus(10); 429 userdatas.get(0).setPassword("foo123"); 430 userdatas.get(0).setClearPwd(true); 431 ejbcaraws.editUser(userdatas.get(0)); 432 KeyStore ksenv = null; 433 try{ 434 ksenv = ejbcaraws.pkcs12Req("WSTESTUSER1","foo123","12345678","1024", CATokenConstants.KEYALGORITHM_RSA); 435 }catch(EjbcaException_Exception e){ 436 assertTrue(e.getMessage(),false); 437 } 438 java.security.KeyStore ks = KeyStoreHelper.getKeyStore(ksenv.getKeystoreData(),"PKCS12","foo123"); 439 440 assertNotNull(ks); 441 Enumeration en = ks.aliases(); 442 String alias = (String ) en.nextElement(); 443 X509Certificate cert = (X509Certificate ) ks.getCertificate(alias); 444 445 String issuerdn = cert.getIssuerDN().toString(); 446 String serno = cert.getSerialNumber().toString(16); 447 448 RevokeStatus revokestatus = ejbcaraws.checkRevokationStatus(issuerdn,serno); 449 assertNotNull(revokestatus); 450 assertTrue(revokestatus.getReason() == RevokedCertInfo.NOT_REVOKED); 451 452 ejbcaraws.revokeCert(issuerdn,serno, RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 453 454 revokestatus = ejbcaraws.checkRevokationStatus(issuerdn,serno); 455 assertNotNull(revokestatus); 456 assertTrue(revokestatus.getReason() == RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE); 457 assertTrue(revokestatus.getCertificateSN().equals(serno)); 458 assertTrue(revokestatus.getIssuerDN().equals(issuerdn)); 459 assertNotNull(revokestatus.getRevocationDate()); 460 } 461 462 public void test01UTF8() throws Exception { 463 464 UserDataVOWS user1 = new UserDataVOWS(); 466 user1.setUsername("WSTESTUSER1"); 467 user1.setPassword("foo123"); 468 user1.setClearPwd(true); 469 user1.setSubjectDN("CN=WS������"); 470 user1.setCaName("AdminCA1"); 471 user1.setEmail(null); 472 user1.setSubjectAltName(null); 473 user1.setStatus(10); 474 user1.setTokenType("USERGENERATED"); 475 user1.setEndEntityProfileName("EMPTY"); 476 user1.setCertificateProfileName("ENDUSER"); 477 478 ejbcaraws.editUser(user1); 479 480 UserMatch usermatch = new UserMatch(); 481 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 482 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 483 usermatch.setMatchvalue("WSTESTUSER1"); 484 485 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 486 assertTrue(userdatas != null); 487 assertTrue(userdatas.size() == 1); 488 UserDataVOWS userdata = userdatas.get(0); 489 assertTrue(userdata.getUsername().equals("WSTESTUSER1")); 490 assertTrue(userdata.getSubjectDN().equals("CN=WS������")); 491 492 } 493 494 495 public void test10revokeUser() throws Exception { 496 497 ejbcaraws.revokeUser("WSTESTUSER1",RevokedCertInfo.REVOKATION_REASON_KEYCOMPROMISE,true); 499 500 UserMatch usermatch = new UserMatch(); 501 usermatch.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_USERNAME); 502 usermatch.setMatchtype(org.ejbca.util.query.UserMatch.MATCH_TYPE_EQUALS); 503 usermatch.setMatchvalue("WSTESTUSER1"); 504 List <UserDataVOWS> userdatas = ejbcaraws.findUser(usermatch); 505 assertTrue(userdatas != null); 506 assertTrue(userdatas.size() == 0); 507 508 } 509 510 } 511 512 | Popular Tags |