use of ddf.security.Subject in project ddf by codice.
the class SecurityPluginTest method testSubjectExists.
@Test
public void testSubjectExists() throws Exception {
Subject mockSubject = mock(Subject.class);
CreateRequest request = new MockCreateRequest();
request.getProperties().put(SecurityConstants.SECURITY_SUBJECT, mockSubject);
SecurityPlugin plugin = new SecurityPlugin();
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
}
use of ddf.security.Subject in project ddf by codice.
the class SecurityPluginTest method testNominalCaseResource.
@Test
public void testNominalCaseResource() throws Exception {
Subject mockSubject = mock(Subject.class);
ThreadContext.bind(mockSubject);
ResourceRequest request = new MockResourceRequest();
SecurityPlugin plugin = new SecurityPlugin();
request = plugin.processPreResource(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
}
use of ddf.security.Subject in project ddf by codice.
the class SecurityPluginTest method testNominalCaseCreateWithEmailAndResourceTag.
@Test
public void testNominalCaseCreateWithEmailAndResourceTag() throws Exception {
Subject mockSubject = setupMockSubject();
ThreadContext.bind(mockSubject);
MetacardImpl metacardWithTags = new MetacardImpl();
Set<String> setOfTags = new HashSet<String>();
setOfTags.add("resource");
metacardWithTags.setTags(setOfTags);
CreateRequest request = new CreateRequestImpl(metacardWithTags);
SecurityPlugin plugin = new SecurityPlugin();
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
assertThat(request.getMetacards().size(), is(1));
assertThat(request.getMetacards().get(0).getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(TEST_USER));
}
use of ddf.security.Subject in project ddf by codice.
the class SecurityPluginTest method testNominalCaseDelete.
@Test
public void testNominalCaseDelete() throws Exception {
Subject mockSubject = mock(Subject.class);
ThreadContext.bind(mockSubject);
DeleteRequest request = new MockDeleteRequest();
SecurityPlugin plugin = new SecurityPlugin();
request = plugin.processPreDelete(request);
request = plugin.processPreDelete(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
}
use of ddf.security.Subject in project ddf by codice.
the class FtpRequestHandler method onRenameStart.
@Override
public FtpletResult onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
FtpFile fromFtpFile = session.getRenameFrom();
String toFilename = request.getArgument();
if (isDotFile(fromFtpFile.getName())) {
Optional<TemporaryFileBackedOutputStream> tfbosOpt = findTempFileInSession(session, fromFtpFile.getAbsolutePath());
if (!tfbosOpt.isPresent()) {
session.write(new DefaultFtpReply(FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "file not found: " + fromFtpFile.getAbsolutePath()));
return FtpletResult.SKIP;
}
try (TemporaryFileBackedOutputStream tfbos = tfbosOpt.get()) {
Subject shiroSubject = (Subject) session.getAttribute(SUBJECT);
if (shiroSubject == null) {
return FtpletResult.DISCONNECT;
}
CreateStorageRequest createRequest = getCreateStorageRequest(toFilename, tfbos);
storeObject(shiroSubject, toFilename, createRequest);
} finally {
removeTempFileFromSession(session, fromFtpFile.getAbsolutePath());
}
}
session.write(new DefaultFtpReply(FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "RNTO successful"));
return FtpletResult.SKIP;
}
Aggregations