Package org.ejbca.core.model.ra.raadmin

Examples of org.ejbca.core.model.ra.raadmin.EndEntityProfile


/**
     * Help function that checks if administrator is authorized to edit profile with given name.
* @throws AuthorizationDeniedException
     */
    private boolean authorizedToProfileId(int profileid, boolean editcheck) throws AuthorizationDeniedException{             
      EndEntityProfile profile = null
      if(profileid == SecConst.EMPTY_ENDENTITYPROFILE) {
        profile = null;
      } else
       profile = endEntityProfileSession.getEndEntityProfile(administrator, profileid);
      }
View Full Code Here


            }

            int cid = certificateProfileSession.getCertificateProfileId(administrator, certificateProfileName);
            int eid = endEntityProfileSession.getEndEntityProfileId(administrator, endEntityProfileName);
            if (eid == 0) {
                EndEntityProfile endEntityProfile = new EndEntityProfile(true);
                endEntityProfile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, "" + cid);
                endEntityProfile.setUse(EndEntityProfile.ENDTIME, 0, true);
                // endEntityProfile.setValue(EndEntityProfile.ENDTIME, 0,
                // "0:0:10");
                endEntityProfileSession.addEndEntityProfile(administrator, endEntityProfileName, endEntityProfile);
                eid = endEntityProfileSession.getEndEntityProfileId(administrator, endEntityProfileName);
            }
View Full Code Here

     *
     * @throws Exception
     *             error
     */
    public void test06MergeWithWS() throws Exception {
        EndEntityProfile profile = new EndEntityProfile();
        profile.addField(DnComponents.COMMONNAME);
        profile.addField(DnComponents.DNEMAIL);
        profile.addField(DnComponents.ORGANIZATIONUNIT);
        profile.setUse(DnComponents.ORGANIZATIONUNIT, 0, true);
        profile.setValue(DnComponents.ORGANIZATIONUNIT, 0, "FooOrgUnit");
        profile.addField(DnComponents.ORGANIZATION);
        profile.addField(DnComponents.COUNTRY);
        profile.setValue(EndEntityProfile.AVAILCAS, 0, Integer.toString(SecConst.ALLCAS));
        profile.setAllowMergeDnWebServices(true);

        endEntityProfileSession.addEndEntityProfile(admin, "TESTMERGEWITHWS", profile);
        int profileId = endEntityProfileSession.getEndEntityProfileId(admin, "TESTMERGEWITHWS");

        UserDataVO addUser = new UserDataVO(username, "C=SE, O=AnaTom, CN=" + username, caid, null, null, UserDataConstants.STATUS_NEW, SecConst.USER_ENDUSER,
View Full Code Here

    certprof.setAllowKeyUsageOverride(true);
    certprof.setAllowCertSerialNumberOverride(true);
    certificateProfileSession.addCertificateProfile(admin, "FOOCERTPROFILE", certprof);
    fooCertProfileId = certificateProfileSession.getCertificateProfileId(admin,"FOOCERTPROFILE");

    final EndEntityProfile profile = new EndEntityProfile(true);
    profile.setValue(EndEntityProfile.DEFAULTCERTPROFILE, 0, Integer.toString(fooCertProfileId));
    profile.setValue(EndEntityProfile.AVAILCERTPROFILES,0,Integer.toString(fooCertProfileId));
    profile.setValue(EndEntityProfile.AVAILKEYSTORE, 0, Integer.toString(SecConst.TOKEN_SOFT_BROWSERGEN));
    assertTrue(profile.getUse(EndEntityProfile.CERTSERIALNR, 0));
    endEntityProfileSession.addEndEntityProfile(admin, "FOOEEPROFILE", profile);
    fooEEProfileId = endEntityProfileSession.getEndEntityProfileId(admin, "FOOEEPROFILE");
  }   
View Full Code Here

        certprof.setExtendedKeyUsage(list);
        certificateProfileSession.addCertificateProfile(admin, "EXTKEYUSAGECERTPROFILE", certprof);
        final int fooCertProfile = certificateProfileSession.getCertificateProfileId(admin,"EXTKEYUSAGECERTPROFILE");

        endEntityProfileSession.removeEndEntityProfile(admin, "EXTKEYUSAGEEEPROFILE");
        final EndEntityProfile profile = new EndEntityProfile(true);
        profile.setValue(EndEntityProfile.AVAILCERTPROFILES,0,Integer.toString(fooCertProfile));
        endEntityProfileSession.addEndEntityProfile(admin, "EXTKEYUSAGEEEPROFILE", profile);
        final int fooEEProfile = endEntityProfileSession.getEndEntityProfileId(admin, "EXTKEYUSAGEEEPROFILE");

        createOrEditUser(fooCertProfile, fooEEProfile);
View Full Code Here

        certprof.setExtendedKeyUsage(list);
        certificateProfileSession.addCertificateProfile(admin, "EXTKEYUSAGECERTPROFILE", certprof);
        final int fooCertProfile = certificateProfileSession.getCertificateProfileId(admin,"EXTKEYUSAGECERTPROFILE");

        endEntityProfileSession.removeEndEntityProfile(admin, "EXTKEYUSAGEEEPROFILE");
        final EndEntityProfile profile = new EndEntityProfile(true);
        profile.setValue(EndEntityProfile.AVAILCERTPROFILES,0,Integer.toString(fooCertProfile));
        endEntityProfileSession.addEndEntityProfile(admin, "EXTKEYUSAGEEEPROFILE", profile);
        final int fooEEProfile = endEntityProfileSession.getEndEntityProfileId(admin, "EXTKEYUSAGEEEPROFILE");

        createOrEditUser(fooCertProfile, fooEEProfile);
View Full Code Here

        certprof.setAllowKeyUsageOverride(true);
        certificateProfileSession.addCertificateProfile(admin, "FOOCERTPROFILE", certprof);
        final int fooCertProfile = certificateProfileSession.getCertificateProfileId(admin, "FOOCERTPROFILE");

        endEntityProfileSession.removeEndEntityProfile(admin, "FOOEEPROFILE");
        final EndEntityProfile profile = new EndEntityProfile(true);
        profile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, Integer.toString(fooCertProfile));
        endEntityProfileSession.addEndEntityProfile(admin, "FOOEEPROFILE", profile);
        final int fooEEProfile = endEntityProfileSession.getEndEntityProfileId(admin, "FOOEEPROFILE");

        // Make user that we know...
        if (!userAdminSession.existsUser(admin, "foo")) {
View Full Code Here

        log.trace(">test09TestMultipleAltNames()");

        // Create a good end entity profile (good enough), allowing multiple UPN
        // names
        endEntityProfileSession.removeEndEntityProfile(admin, "TESTMULALTNAME");
        EndEntityProfile profile = new EndEntityProfile();
        profile.addField(DnComponents.ORGANIZATION);
        profile.addField(DnComponents.COUNTRY);
        profile.addField(DnComponents.COMMONNAME);
        profile.addField(DnComponents.UNIFORMRESOURCEID);
        profile.addField(DnComponents.DNSNAME);
        profile.addField(DnComponents.DNSNAME);
        profile.addField(DnComponents.RFC822NAME);
        profile.addField(DnComponents.IPADDRESS);
        profile.addField(DnComponents.UPN);
        profile.addField(DnComponents.UPN);
        profile.setValue(EndEntityProfile.AVAILCAS, 0, Integer.toString(SecConst.ALLCAS));
        endEntityProfileSession.addEndEntityProfile(admin, "TESTMULALTNAME", profile);
        int eeprofile = endEntityProfileSession.getEndEntityProfileId(admin, "TESTMULALTNAME");

        // Change a user that we know...
        userAdminSession.changeUser(admin, "foo", "foo123", "C=SE,O=AnaTom,CN=foo",
View Full Code Here

       
       
        // 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);
View Full Code Here

        int cprofile = certificateProfileSession.getCertificateProfileId(admin, "TESTQC");

        // Create a good end entity profile (good enough), allowing multiple UPN
        // names
        endEntityProfileSession.removeEndEntityProfile(admin, "TESTQC");
        EndEntityProfile profile = new EndEntityProfile();
        profile.addField(DnComponents.COUNTRY);
        profile.addField(DnComponents.COMMONNAME);
        profile.setValue(EndEntityProfile.AVAILCAS, 0, Integer.toString(SecConst.ALLCAS));
        profile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, Integer.toString(cprofile));
        endEntityProfileSession.addEndEntityProfile(admin, "TESTQC", profile);
        int eeprofile = endEntityProfileSession.getEndEntityProfileId(admin, "TESTQC");

        // Change a user that we know...
        userAdminSession.changeUser(admin, "foo", "foo123", "C=SE,CN=qc", null, "foo@anatom.nu", false, eeprofile, cprofile, SecConst.USER_ENDUSER,
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.raadmin.EndEntityProfile

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.