Package org.ejbca.core.model.ra

Examples of org.ejbca.core.model.ra.ExtendedInformation


                    profile.setValue(EndEntityProfile.DEFAULTCERTPROFILE, 0, Integer.valueOf(certprofileid).toString());
                    endEntityProfileSession.addEndEntityProfile(admin, TESTPROFILE, profile);
                } catch (EndEntityProfileExistsException pee) {
                }
                // Create a new user
                ExtendedInformation ei = new ExtendedInformation();
                ei.setCustomData(EndEntityProfile.STARTTIME, "0:00:00");
                ei.setCustomData(EndEntityProfile.ENDTIME, "0:00:50");
                UserDataVO userdata = new UserDataVO(TESTUSERNAME, userDN, caid, "", "foo@bar.se", UserDataConstants.STATUS_NEW, SecConst.USER_ENDUSER,
                        endEntityProfileSession.getEndEntityProfileId(admin, TESTPROFILE), certprofileid, new Date(), new Date(), SecConst.TOKEN_SOFT_PEM, 0, ei);
                userdata.setPassword("foo123");
                try {
                    userAdminSession.revokeAndDeleteUser(admin, TESTUSERNAME, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE);
View Full Code Here


            throws PersistenceException, AuthorizationDeniedException, UserDoesntFullfillEndEntityProfile, ApprovalException,
            WaitingForApprovalException, Exception {
        log.info("createUser: username=" + username + ", certProfileId=" + certProfileId);
        UserDataVO userdata = new UserDataVO(username, "CN=" + username, caID, null, null, 1, endEntityProfileId, certProfileId, SecConst.TOKEN_SOFT_P12, 0,
                null);
        ExtendedInformation ei = new ExtendedInformation();
        ei.setMaxLoginAttempts(maxFailedLogins);
        ei.setRemainingLoginAttempts(maxFailedLogins);
        userdata.setExtendedinformation(ei);
        userdata.setPassword(password);
        userAdminSession.addUser(admin, userdata, true);
        UserDataVO userdata2 = userAdminSession.findUser(admin, userdata.getUsername());
        assertNotNull("findUser: " + userdata.getUsername(), userdata2);
View Full Code Here

      subjectaltnames.setDN(subjectaltname, DNFieldExtractor.TYPE_SUBJECTALTNAME);
    }
    public String getSubjectAltName() {return userdata.getSubjectAltName();}

    public void setSubjectDirAttributes( String subjectdirattr) {
      ExtendedInformation ext = userdata.getExtendedinformation();
      if (ext == null) {
        ext = new ExtendedInformation();
      }
      ext.setSubjectDirectoryAttributes(subjectdirattr);
        userdata.setExtendedinformation(ext);
        subjectdirattrs.setDN(subjectdirattr, DNFieldExtractor.TYPE_SUBJECTDIRATTR);
      }
View Full Code Here

                // "0:0:10");
                endEntityProfileSession.addEndEntityProfile(administrator, endEntityProfileName, endEntityProfile);
                eid = endEntityProfileSession.getEndEntityProfileId(administrator, endEntityProfileName);
            }
            userdata.setEndEntityProfileId(eid);
            ExtendedInformation extendedInformation = new ExtendedInformation();
            extendedInformation.setCustomData(EndEntityProfile.ENDTIME, "0:0:10");
            userdata.setExtendedinformation(extendedInformation);
            userdata.setCertificateProfileId(cid);
            userAdminSession.changeUser(administrator, userdata, true);
            // Create some soon-to-be-expired certs
            for (int j = 0; j < CERTS_OF_EACH_KIND; j++) {
View Full Code Here

      String xxpk = d.getPk(); // Keep for later so we can set to success
     
      PublisherQueueVolatileData vd = new PublisherQueueVolatileData();
      vd.setUsername("foo");
      vd.setPassword("bar");
      ExtendedInformation ei = new ExtendedInformation();
      ei.setSubjectDirectoryAttributes("directoryAttr");
      vd.setExtendedInformation(ei);
      publisherQueueSession.addQueueData(123456, PublisherConst.PUBLISH_TYPE_CRL, "YY", vd, PublisherConst.STATUS_PENDING);
     
      c = publisherQueueSession.getPendingEntriesForPublisher(123456);
      assertEquals(2, c.size());
      boolean testedXX = false;
      boolean testedYY = false;
      i = c.iterator();
      while (i.hasNext()) {
          d = i.next();
          if (d.getFingerprint().equals("XX")) {
            assertEquals(PublisherConst.PUBLISH_TYPE_CERT, d.getPublishType());
              assertNotNull(d.getLastUpdate());
              assertNotNull(d.getTimeCreated());
              assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
              assertEquals(0,d.getTryCounter());
              testedXX = true;
          }
          if (d.getFingerprint().equals("YY")) {
            assertEquals(PublisherConst.PUBLISH_TYPE_CRL, d.getPublishType());
              assertEquals(PublisherConst.STATUS_PENDING, d.getPublishStatus());
              assertEquals(0,d.getTryCounter());
              PublisherQueueVolatileData v = d.getVolatileData();
              assertEquals("bar", v.getPassword());
              assertEquals("foo", v.getUsername());
              ExtendedInformation e = v.getExtendedInformation();
              assertNotNull(e);
              assertEquals("directoryAttr", e.getSubjectDirectoryAttributes());
              testedYY = true;
          }
      }
      assertTrue(testedXX);
      assertTrue(testedYY);
View Full Code Here

    String returnval = "CERTREPUBLISHFAILED";
    int certificateProfileId = SecConst.CERTPROFILE_NO_PROFILE;
    String username = null;
    String password = null;
    String dn = null;
    ExtendedInformation ei = null;
    final Certificate certificate = certificatedata.getCertificate();
    final CertReqHistory certreqhist = certificatesession.getCertReqHistory(administrator, CertTools.getSerialNumber(certificate), CertTools.getIssuerDN(certificate));
    if (certreqhist != null) {
      // First try to look up all info using the Certificate Request History from when the certificate was issued
      // We need this since the certificate subjectDN might be a subset of the subjectDN in the template
View Full Code Here

        // Default value should be 1, so it should return 0
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);

        // Now add extended information with allowed requests 2
        ExtendedInformation ei = new ExtendedInformation();
        int allowedrequests = 2;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));
        user = new UserDataVO(username, "C=SE,O=AnaTom,CN="+username, caid, null, null, SecConst.USER_INVALID, SecConst.EMPTY_ENDENTITYPROFILE, SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.TOKEN_SOFT_PEM, 0, ei);
        boolean thrown = false;
        try {
            userAdminSession.changeUser(admin, user, false);         
        } catch (UserDoesntFullfillEndEntityProfile e) {
          thrown = true;
        }
        // This requires "Enable end entity profile limitations" to be checked in admin GUI->System configuration
        assertTrue(thrown);
        // decrease the value, since we use the empty end entity profile, the counter will not be used
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);
       
       
        // Test that it works correctly with end entity profiles using the counter
        int pid = 0;
        try {
            EndEntityProfile profile = new EndEntityProfile();
            profile.addField(DnComponents.ORGANIZATION);
            profile.addField(DnComponents.COUNTRY);
            profile.addField(DnComponents.COMMONNAME);
            profile.setValue(EndEntityProfile.AVAILCAS,0,""+caid);
            profile.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, false);
            endEntityProfileSession.addEndEntityProfile(admin, "TESTREQUESTCOUNTER", profile);
            pid = endEntityProfileSession.getEndEntityProfileId(admin, "TESTREQUESTCOUNTER");
        } catch (EndEntityProfileExistsException pee) {
          assertTrue("Can not create end entity profile", false);
        }
        // Now add extended information with allowed requests 2
        ei = new ExtendedInformation();
        allowedrequests = 2;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));       
        user = new UserDataVO(username, "C=SE,O=AnaTom,CN="+username, caid, null, null, SecConst.USER_INVALID, pid, SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.TOKEN_SOFT_PEM, 0, ei);
        thrown = false;
        try {
            userAdminSession.changeUser(admin, user, false);         
        } catch (UserDoesntFullfillEndEntityProfile e) {
          thrown = true;
        }
        assertTrue(thrown);
        // decrease the value
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);
        // decrease the value again, default value when the counter is not used is 0       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);

        // Now allow the counter
        EndEntityProfile ep = endEntityProfileSession.getEndEntityProfile(admin, pid);
        ep.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, true);
        ep.setValue(EndEntityProfile.ALLOWEDREQUESTS,0,"2");
        endEntityProfileSession.changeEndEntityProfile(admin, "TESTREQUESTCOUNTER", ep);
        // This time changeUser will be ok
        userAdminSession.changeUser(admin, user, false);
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(1, counter);
        // decrease the value again       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);
        // decrease the value again
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(-1, counter);       
        // decrease the value again
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(-1, counter)
       
        // Now disallow the counter, it will be deleted from the user
        ep = endEntityProfileSession.getEndEntityProfile(admin, pid);
        ep.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, false);
        endEntityProfileSession.changeEndEntityProfile(admin, "TESTREQUESTCOUNTER", ep);
        ei = user.getExtendedinformation();
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, null);
        user.setExtendedinformation(ei);
        userAdminSession.changeUser(admin, user, false);         
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);

        // allow the counter
        ep = endEntityProfileSession.getEndEntityProfile(admin, pid);
        ep.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, true);
        ep.setValue(EndEntityProfile.ALLOWEDREQUESTS,0,"2");
        endEntityProfileSession.changeEndEntityProfile(admin, "TESTREQUESTCOUNTER", ep);
        ei = user.getExtendedinformation();
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, "0");
        user.setExtendedinformation(ei);
        user.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user, false);
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(1, counter);
        // decrease the value again       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter);
        // decrease the value again
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(-1, counter)

        // test setuserstatus it will re-set the counter
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_GENERATED);
        ep = endEntityProfileSession.getEndEntityProfile(admin, pid);
        ep.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, true);
        ep.setValue(EndEntityProfile.ALLOWEDREQUESTS,0,"3");
        endEntityProfileSession.changeEndEntityProfile(admin, "TESTREQUESTCOUNTER", ep);
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_NEW);
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(2, counter);
        // decrease the value again       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(1, counter);
        // test setuserstatus again it will not re-set the counter if it is already new
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_NEW);
        assertEquals(1, counter);
        // decrease the value again
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(0, counter); // sets status to generated
        // decrease the value again
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(-1, counter);
       
        // test setuserstatus again it will re-set the counter since status is generated
        ep = endEntityProfileSession.getEndEntityProfile(admin, pid);
        ep.setUse(EndEntityProfile.ALLOWEDREQUESTS, 0, true);
        ep.setValue(EndEntityProfile.ALLOWEDREQUESTS,0,"3");
        endEntityProfileSession.changeEndEntityProfile(admin, "TESTREQUESTCOUNTER", ep);
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_NEW);
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(2, counter);

        // Also changeUser to new from something else will re-set status, if ei value is 0
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_GENERATED);
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, "0");       
        user.setExtendedinformation(ei);
        user.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user, false);
        // decrease the value       
        counter = userAdminSession.decRequestCounter(admin, username);
        assertEquals(2, counter);
       
        // Test set and re-set logic
       
        // The profile has 3 as default value, if I change user with status to generated and value 2 it should be set as that
        UserDataVO user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = new ExtendedInformation();
        allowedrequests = 2;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));
        user1.setExtendedinformation(ei);
        user1.setStatus(UserDataConstants.STATUS_GENERATED);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        String value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("2", value);
        // If I change user with status to new and value 1 it should be set as that
        ei = new ExtendedInformation();
        allowedrequests = 1;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));
        user1.setExtendedinformation(ei);
        user1.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("1", value);
        // If I set status to new again, with noting changed, nothing should change
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_NEW);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("1", value);
        // The same when I change the user
        user1.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("1", value);
        // If I change the status to generated, nothing should happen
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_GENERATED);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("1", value);
        // If I change the status to new from generated the default value should be used
        userAdminSession.setUserStatus(admin, user.getUsername(), UserDataConstants.STATUS_NEW);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("3", value);
        // It should be possible to simply set the value to 0
        ei = new ExtendedInformation();
        allowedrequests = 0;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));
        user1.setExtendedinformation(ei);
        user1.setStatus(UserDataConstants.STATUS_GENERATED);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("0", value);
        // Changing again to new, with 0 passed in will set the default value
        user1.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("3", value);
        // Set back to 0
        user1.setStatus(UserDataConstants.STATUS_GENERATED);
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, "0");
        user1.setExtendedinformation(ei);
        userAdminSession.changeUser(admin, user1, false);
        user1 = userAdminSession.findUser(admin, user.getUsername());
        ei = user1.getExtendedinformation();
        value = ei.getCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER);
        assertEquals("0", value);
        // Setting with null value will always remove the request counter (the whole extendedinformatin actually)
        user1.setExtendedinformation(null);
        user1.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user1, false);
View Full Code Here

            authstatus = true;
        }
        assertTrue("Should have failed to create cert", authstatus);

        // Change already existing user to add extended information with counter
        ExtendedInformation ei = new ExtendedInformation();
        int allowedrequests = 2;
        ei.setCustomData(ExtendedInformation.CUSTOM_REQUESTCOUNTER, String.valueOf(allowedrequests));
        user.setExtendedinformation(ei);
        user.setStatus(UserDataConstants.STATUS_NEW);
        userAdminSession.changeUser(admin, user, false);

        // create first cert
View Full Code Here

        // Check that it is active
        boolean isRevoked = certificateStoreSession.isRevoked(CertTools.getIssuerDN(cert), CertTools.getSerialNumber(cert));
        assertFalse(isRevoked);

        // Now add extended information with the revocation reason
        ExtendedInformation ei = new ExtendedInformation();
        ei.setCustomData(ExtendedInformation.CUSTOM_REVOCATIONREASON, "" + RevokedCertInfo.REVOCATION_REASON_CERTIFICATEHOLD);
        user.setExtendedinformation(ei);
        userAdminSession.changeUser(admin, user, false);
        userAdminSession.setUserStatus(admin, "foo", UserDataConstants.STATUS_NEW);
        // create first cert
        cert = (X509Certificate) signSession.createCertificate(admin, "foo", "foo123", rsakeys.getPublic());
View Full Code Here

    p10.setPassword("foo123");

    UserDataVO user = new UserDataVO("foo", "C=SE,O=AnaTom,CN=foo", rsacaid, null, "foo@anatom.se", SecConst.USER_ENDUSER, fooEEProfileId, fooCertProfileId,
        SecConst.TOKEN_SOFT_BROWSERGEN, 0, null);
    user.setPassword("foo123");
    ExtendedInformation ei = new ExtendedInformation();
    ei.setCertificateSerialNumber(serno);
    user.setExtendedinformation(ei);
    IResponseMessage resp = certificateRequestSession.processCertReq(admin, user, p10, org.ejbca.core.protocol.X509ResponseMessage.class);

    X509Certificate cert = (X509Certificate) CertTools.getCertfromByteArray(resp.getResponseMessage());
    assertNotNull("Failed to create certificate", cert);
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.ExtendedInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.