@Override public KrbIdentity getPrincipal(String principalName) throws KrbException { KrbIdentity identity = backend.getIdentity(principalName); return identity; }
@Override public KrbIdentity getPrincipal(String principalName) throws KrbException { KrbIdentity identity = backend.getIdentity(principalName); return identity; }
public static void getTheTestIdentity( IdentityBackend backend) throws KrbException { KrbIdentity identity = backend.getIdentity(TEST_PRINCIPAL); if (identity == null) { throw new KrbException("Failed to get the test principal"); } }
public static void getTheTestIdentity( IdentityBackend backend) throws KrbException { KrbIdentity identity = backend.getIdentity(TEST_PRINCIPAL); if (identity == null) { throw new KrbException("Failed to get the test principal"); } }
@Override public void checkBuiltinPrincipals() throws KrbException { String tgsPrincipal = getTgsPrincipal(); String kadminPrincipal = getKadminPrincipal(); if (backend.getIdentity(tgsPrincipal) == null || backend.getIdentity(kadminPrincipal) == null) { String errorMsg = "The built-in principals do not exist in the backend," + " please run the kdcinit tool."; LOG.error(errorMsg); throw new KrbException(errorMsg); } }
@Override public void checkBuiltinPrincipals() throws KrbException { String tgsPrincipal = getTgsPrincipal(); String kadminPrincipal = getKadminPrincipal(); if (backend.getIdentity(tgsPrincipal) == null || backend.getIdentity(kadminPrincipal) == null) { String errorMsg = "The built-in principals do not exist in the backend," + " please run the kdcinit tool."; LOG.error(errorMsg); throw new KrbException(errorMsg); } }
protected void testDelete(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNotNull(); backend.deleteIdentity(TEST_PRINCIPAL); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNull(); }
protected void testDelete(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNotNull(); backend.deleteIdentity(TEST_PRINCIPAL); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isNull(); }
protected void testStore(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); KrbIdentity kid2 = backend.getIdentity(TEST_PRINCIPAL); assertThat(kid).isEqualTo(kid2); //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
protected void testStore(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); KrbIdentity kid2 = backend.getIdentity(TEST_PRINCIPAL); assertThat(kid).isEqualTo(kid2); //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
protected void testUpdate(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); kid.setDisabled(true); backend.updateIdentity(kid); // clear the identity cache. backend.release(); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isEqualTo(kid); //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
protected void testUpdate(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); kid.setDisabled(true); backend.updateIdentity(kid); // clear the identity cache. backend.release(); assertThat(backend.getIdentity(TEST_PRINCIPAL)).isEqualTo(kid); //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
@Override public void exportKeytab(File keytabFile) throws KrbException { Keytab keytab = AdminHelper.createOrLoadKeytab(keytabFile); Iterable<String> principals = backend.getIdentities(); for (String principal : principals) { KrbIdentity identity = backend.getIdentity(principal); if (identity != null) { AdminHelper.exportToKeytab(keytab, identity); } } AdminHelper.storeKeytab(keytab, keytabFile); }
public void createHttpPrincipal(LocalKadmin kadmin) throws HasException { String httpPrincipal = getHttpPrincipal(); IdentityBackend backend = kdcServer.getIdentityService(); try { if (backend.getIdentity(httpPrincipal) == null) { kadmin.addPrincipal(httpPrincipal); } else { LOG.info("The http principal already exists in backend."); } } catch (KrbException e) { throw new HasException("Failed to add principal, " + e.getMessage()); } }
public void createHttpPrincipal(LocalKadmin kadmin) throws HasException { String httpPrincipal = getHttpPrincipal(); IdentityBackend backend = kdcServer.getIdentityService(); try { if (backend.getIdentity(httpPrincipal) == null) { kadmin.addPrincipal(httpPrincipal); } else { LOG.info("The http principal already exists in backend."); } } catch (KrbException e) { throw new HasException("Failed to add principal, " + e.getMessage()); } }
@Override public void modifyPrincipal(String principal, KOptions kOptions) throws KrbException { principal = fixPrincipal(principal); KrbIdentity identity = backend.getIdentity(principal); if (identity == null) { throw new KrbException("Principal \"" + principal + "\" does not exist."); } AdminHelper.updateIdentity(identity, kOptions); backend.updateIdentity(identity); }
@Override public void exportKeytab(File keytabFile) throws KrbException { Keytab keytab = AdminHelper.createOrLoadKeytab(keytabFile); Iterable<String> principals = backend.getIdentities(); for (String principal : principals) { KrbIdentity identity = backend.getIdentity(principal); if (identity != null) { AdminHelper.exportToKeytab(keytab, identity); } } AdminHelper.storeKeytab(keytab, keytabFile); }
@Override public void modifyPrincipal(String principal, KOptions kOptions) throws KrbException { principal = fixPrincipal(principal); KrbIdentity identity = backend.getIdentity(principal); if (identity == null) { throw new KrbException("Principal \"" + principal + "\" does not exist."); } AdminHelper.updateIdentity(identity, kOptions); backend.updateIdentity(identity); }
@Override public void updateKeys(String principal) throws KrbException { principal = fixPrincipal(principal); KrbIdentity identity = backend.getIdentity(principal); if (identity == null) { throw new KrbException("Principal " + principal + "was not found. Please check the input and try again"); } List<EncryptionKey> keys = EncryptionUtil.generateKeys( getKdcConfig().getEncryptionTypes()); identity.addKeys(keys); backend.updateIdentity(identity); }
@Override public void changePassword(String principal, String newPassword) throws KrbException { principal = fixPrincipal(principal); KrbIdentity identity = backend.getIdentity(principal); if (identity == null) { throw new KrbException("Principal " + principal + " was not found. Please check the input and try again"); } List<EncryptionKey> keys = EncryptionUtil.generateKeys(principal, newPassword, getKdcConfig().getEncryptionTypes()); identity.addKeys(keys); backend.updateIdentity(identity); }