Package org.ejbca.core.model.log

Examples of org.ejbca.core.model.log.Admin


    /**
     * @return the CA certificate
     */
    public Certificate getTestCACert(String caName) {
        Certificate cacert = null;
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        CAInfo cainfo = caAdminSessionRemote.getCAInfo(admin, getTestCAId(caName));
        Collection certs = cainfo.getCertificateChain();
        if (certs.size() > 0) {
            Iterator certiter = certs.iterator();
            cacert = (X509Certificate) certiter.next();
View Full Code Here


     *
     * @return true if successful
     */
    public boolean removeTestCA(String caName) {
        // Search for requested CA
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        try {
            final CAInfo caInfo = this.caAdminSessionRemote.getCAInfo(admin, caName);
            if (caInfo == null) {
                return true;
            }
View Full Code Here

                Query q = new Query(Query.TYPE_APPROVALQUERY);
                q.add(ApprovalMatch.MATCH_WITH_APPROVALID, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(approvalID));
                ApprovalDataVO approvalData = (ApprovalDataVO) (approvalSession.query(internalAdmin, q, 0, 1, "cAId=" + approvalCAID, "(endEntityProfileId="
                        + SecConst.EMPTY_ENDENTITYPROFILE + ")").get(0));
                Approval approval = new Approval("Approved during testing.");
                approvalExecutionSession.approve(approvingAdmin, approvalID, approval, globalConfigurationSession.getCachedGlobalConfiguration(new Admin(Admin.INTERNALCAID)));
                approvalData = (ApprovalDataVO) approvalSession.findApprovalDataVO(internalAdmin, approvalID).iterator().next();
                assertEquals(approvalData.getStatus(), ApprovalDataVO.STATUS_EXECUTED);
                CertificateStatus status = certificateStoreSession.getStatus(issuerDN, serialNumber);
                assertEquals(status.revocationReason, reason);
                approvalSession.removeApprovalRequest(internalAdmin, approvalData.getId());
View Full Code Here

            if (lev != null) {
                level = Integer.parseInt(lev);
            }
            // Root CA is level 0, next below root level 1 etc etc
            try {
                Admin admin = ejbcawebbean.getAdminObject();
                Certificate[] chain = (Certificate[]) signSession.getCertificateChain(admin, issuerdn.hashCode()).toArray(new Certificate[0]);
                                                           
                // chain.length-1 is last cert in chain (root CA)
                if ( (chain.length-1-level) < 0 ) {
                    PrintStream ps = new PrintStream(res.getOutputStream());
View Full Code Here

                userAdminSession.setClearTextPassword(administrator, username, password);
                userAdminSession.setUserStatus(administrator, username, UserDataConstants.STATUS_NEW);
                Certificate certificate = signSession.createCertificate(administrator, username, password, keys.getPublic());
                userAdminSession.revokeCert(administrator, CertTools.getSerialNumber(certificate), CertTools.getIssuerDN(certificate),
                        RevokedCertInfo.REVOCATION_REASON_UNSPECIFIED);
                storeSession.setArchivedStatus(new Admin(Admin.TYPE_INTERNALUSER), CertTools.getFingerprintAsString(certificate));
            }
            endEntityProfileSession.removeEndEntityProfile(administrator, endEntityProfileName);
            certificateProfileSession.removeCertificateProfile(administrator, certificateProfileName);
            if (i % 10 == 0) {
                log.debug("Created " + i + " users...");
View Full Code Here

     * @throws Exception
     *             error
     */
    public void testInitialize() throws Exception {
        int caid = "CN=TEST Authorization,O=PrimeKey,C=SE".hashCode();
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        // Initialize with a new CA
        adminGroupSession.init(admin, caid, DEFAULT_SUPERADMIN_CN);

        // Retrieve access rules and check that they were added
        AdminGroup ag = adminGroupSession.getAdminGroup(admin, AdminGroup.PUBLICWEBGROUPNAME);
View Full Code Here

    }

    public void testExistMethods() throws Exception {
        int caid = "CN=TEST Authorization,O=PrimeKey,C=SE".hashCode();
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        authorizationSession.existsCAInRules(admin, caid);

    }
View Full Code Here

        authorizationSession.existsCAInRules(admin, caid);

    }

    public void testIsAuthorizedInternalUserRegularApproveIdentity() {
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        assertTrue("Could not authorize internal user with AccessRulesConstants.REGULAR_APPROVEENDENTITY",
                authorizationSession.isAuthorized(admin, AccessRulesConstants.REGULAR_APPROVEENDENTITY));

    }
View Full Code Here

    }

    public void testIsAuthorizedCertUserRegularApproveIdentity() throws Exception {

        String adminusername = genRandomUserName();
        Admin intadmin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);

        int caid = getTestCAId();

        UserDataVO userdata = new UserDataVO(adminusername, "CN=" + adminusername, caid, null, null, 1, SecConst.EMPTY_ENDENTITYPROFILE,
                SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.TOKEN_SOFT_P12, 0, null);
        userdata.setPassword("foo123");

        userAdminSession.addUser(intadmin, userdata, true);

        File tmpfile = File.createTempFile("ejbca", "p12");
        BatchMakeP12 makep12 = new BatchMakeP12();
        makep12.setMainStoreDir(tmpfile.getParent());
        makep12.createAllNew();
        tmpfile.delete();

        List<AdminEntity> adminEntities = new ArrayList<AdminEntity>();
        adminEntities.add(new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASEINS, adminusername, caid));
        adminEntitySession.addAdminEntities(intadmin, AdminGroup.TEMPSUPERADMINGROUP, adminEntities);
        authorizationSession.forceRuleUpdate(intadmin);

        X509Certificate admincert = (X509Certificate) certificateStoreSession.findCertificatesByUsername(intadmin, adminusername).iterator().next();
        Admin admin = new Admin(admincert, adminusername, null);

        assertTrue("Could not authorize certificate user with AccessRulesConstants.REGULAR_APPROVEENDENTITY",
                authorizationSession.isAuthorized(admin, AccessRulesConstants.REGULAR_APPROVEENDENTITY));

    }
View Full Code Here

     * This test reproduces an error where the superadmin user was invalid.
     *
     * @throws AuthorizationDeniedException
     */
    public void testIsAuthorizedWithSuperAdminFromX509Certificate() throws AuthorizationDeniedException {
        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        Admin superadmin = new Admin((X509Certificate) certificateStoreSession.findCertificatesByUsername(admin, SUPER_ADMIN).iterator().next(),
                SUPER_ADMIN, null);
        assertTrue("Authorization for superadmin user failed. This probably means that your SuperAdmin user isn't feeling very well.",
                authorizationSession.isAuthorized(superadmin, AccessRulesConstants.REGULAR_APPROVEENDENTITY));

    }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.log.Admin

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.