@Test public void testCreatePrincipalNonEmptyPrincipalAndKeytab() throws IOException { MockClientContext mockClientContext = new MockClientContext(DEFAULT_JOB_NAME); RunJobParameters parameters = mock(RunJobParameters.class); when(parameters.getPrincipal()).thenReturn("principal"); when(parameters.getKeytab()).thenReturn("keytab"); FileSystemOperations fsOperations = new FileSystemOperations(mockClientContext); KerberosPrincipal result = KerberosPrincipalFactory.create(fsOperations, mockClientContext.getRemoteDirectoryManager(), parameters); assertNotNull(result); assertEquals("file: assertEquals("principal", result.getPrincipalName()); }
public static KerberosPrincipal create(FileSystemOperations fsOperations, RemoteDirectoryManager remoteDirectoryManager, RunJobParameters parameters) throws IOException { Objects.requireNonNull(fsOperations, "FileSystemOperations must not be null!"); Objects.requireNonNull(remoteDirectoryManager, "RemoteDirectoryManager must not be null!"); Objects.requireNonNull(parameters, "Parameters must not be null!"); if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils .isNotBlank(parameters.getPrincipal())) { String keytab = parameters.getKeytab(); String principal = parameters.getPrincipal(); if (parameters.isDistributeKeytab()) { return handleDistributedKeytab(fsOperations, remoteDirectoryManager, parameters, keytab, principal); } else { return handleNormalKeytab(keytab, principal); } } LOG.debug("Principal and keytab was null or empty, " + "returning null KerberosPrincipal!"); return null; }
KerberosPrincipalFactory { public static KerberosPrincipal create(FileSystemOperations fsOperations, RemoteDirectoryManager remoteDirectoryManager, RunJobParameters parameters) throws IOException { Objects.requireNonNull(fsOperations, "FileSystemOperations must not be null!"); Objects.requireNonNull(remoteDirectoryManager, "RemoteDirectoryManager must not be null!"); Objects.requireNonNull(parameters, "Parameters must not be null!"); if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils .isNotBlank(parameters.getPrincipal())) { String keytab = parameters.getKeytab(); String principal = parameters.getPrincipal(); if (parameters.isDistributeKeytab()) { return handleDistributedKeytab(fsOperations, remoteDirectoryManager, parameters, keytab, principal); } else { return handleNormalKeytab(keytab, principal); } } LOG.debug("Principal and keytab was null or empty, " + "returning null KerberosPrincipal!"); return null; } }
KerberosPrincipalFactory { public static KerberosPrincipal create(FileSystemOperations fsOperations, RemoteDirectoryManager remoteDirectoryManager, RunJobParameters parameters) throws IOException { Objects.requireNonNull(fsOperations, "FileSystemOperations must not be null!"); Objects.requireNonNull(remoteDirectoryManager, "RemoteDirectoryManager must not be null!"); Objects.requireNonNull(parameters, "Parameters must not be null!"); if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils .isNotBlank(parameters.getPrincipal())) { String keytab = parameters.getKeytab(); String principal = parameters.getPrincipal(); if (parameters.isDistributeKeytab()) { return handleDistributedKeytab(fsOperations, remoteDirectoryManager, parameters, keytab, principal); } else { return handleNormalKeytab(keytab, principal); } } LOG.debug("Principal and keytab was null or empty, " + "returning null KerberosPrincipal!"); return null; } private  KerberosPrincipalFactory(); }
KerberosPrincipalFactory { public static KerberosPrincipal create(FileSystemOperations fsOperations, RemoteDirectoryManager remoteDirectoryManager, RunJobParameters parameters) throws IOException { Objects.requireNonNull(fsOperations, "FileSystemOperations must not be null!"); Objects.requireNonNull(remoteDirectoryManager, "RemoteDirectoryManager must not be null!"); Objects.requireNonNull(parameters, "Parameters must not be null!"); if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils .isNotBlank(parameters.getPrincipal())) { String keytab = parameters.getKeytab(); String principal = parameters.getPrincipal(); if (parameters.isDistributeKeytab()) { return handleDistributedKeytab(fsOperations, remoteDirectoryManager, parameters, keytab, principal); } else { return handleNormalKeytab(keytab, principal); } } LOG.debug("Principal and keytab was null or empty, " + "returning null KerberosPrincipal!"); return null; } private  KerberosPrincipalFactory(); static KerberosPrincipal create(FileSystemOperations fsOperations,
                                         RemoteDirectoryManager remoteDirectoryManager,
                                         RunJobParameters parameters); }
KerberosPrincipalFactory { public static KerberosPrincipal create(FileSystemOperations fsOperations, RemoteDirectoryManager remoteDirectoryManager, RunJobParameters parameters) throws IOException { Objects.requireNonNull(fsOperations, "FileSystemOperations must not be null!"); Objects.requireNonNull(remoteDirectoryManager, "RemoteDirectoryManager must not be null!"); Objects.requireNonNull(parameters, "Parameters must not be null!"); if (StringUtils.isNotBlank(parameters.getKeytab()) && StringUtils .isNotBlank(parameters.getPrincipal())) { String keytab = parameters.getKeytab(); String principal = parameters.getPrincipal(); if (parameters.isDistributeKeytab()) { return handleDistributedKeytab(fsOperations, remoteDirectoryManager, parameters, keytab, principal); } else { return handleNormalKeytab(keytab, principal); } } LOG.debug("Principal and keytab was null or empty, " + "returning null KerberosPrincipal!"); return null; } private  KerberosPrincipalFactory(); static KerberosPrincipal create(FileSystemOperations fsOperations,
                                         RemoteDirectoryManager remoteDirectoryManager,
                                         RunJobParameters parameters);  }