use of datawave.security.authorization.DatawaveUser in project datawave by NationalSecurityAgency.
the class AuthorizationsUtilTest method initialize.
@Before
public void initialize() {
System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson");
methodAuths = "A,C";
userAuths = new HashSet<>();
userAuths.add(Sets.newHashSet("A", "C", "D"));
userAuths.add(Sets.newHashSet("A", "B", "E"));
SubjectIssuerDNPair userDN = SubjectIssuerDNPair.of(USER_DN, ISSUER_DN);
SubjectIssuerDNPair p1dn = SubjectIssuerDNPair.of("entity1UserDN", "entity1IssuerDN");
SubjectIssuerDNPair p2dn = SubjectIssuerDNPair.of("entity2UserDN", "entity2IssuerDN");
SubjectIssuerDNPair p3dn = SubjectIssuerDNPair.of("entity3UserDN", "entity3IssuerDN");
DatawaveUser user = new DatawaveUser(userDN, UserType.USER, Sets.newHashSet("A", "C", "D"), null, null, System.currentTimeMillis());
DatawaveUser p1 = new DatawaveUser(p1dn, UserType.SERVER, Sets.newHashSet("A", "B", "E"), null, null, System.currentTimeMillis());
DatawaveUser p2 = new DatawaveUser(p2dn, UserType.SERVER, Sets.newHashSet("A", "F", "G"), null, null, System.currentTimeMillis());
DatawaveUser p3 = new DatawaveUser(p3dn, UserType.SERVER, Sets.newHashSet("A", "B", "G"), null, null, System.currentTimeMillis());
proxiedUserPrincipal = new DatawavePrincipal(Lists.newArrayList(user, p1, p2));
proxiedServerPrincipal1 = new DatawavePrincipal(Lists.newArrayList(p1, p3));
proxiedServerPrincipal2 = new DatawavePrincipal(Lists.newArrayList(p1, p2, p3));
}
use of datawave.security.authorization.DatawaveUser in project datawave by NationalSecurityAgency.
the class MapReduceBeanTest method setup.
@Before
public void setup() throws Exception {
System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson");
System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D");
DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "CN=ca, OU=acme"), UserType.USER, Arrays.asList(auths), Collections.singleton("AuthorizedUser"), null, 0L);
principal = new DatawavePrincipal(Collections.singletonList(user));
applicationContext = new ClassPathXmlApplicationContext("classpath:*datawave/mapreduce/MapReduceJobs.xml");
Whitebox.setInternalState(bean, MapReduceConfiguration.class, applicationContext.getBean(MapReduceConfiguration.class));
}
use of datawave.security.authorization.DatawaveUser in project datawave by NationalSecurityAgency.
the class MapReduceBeanTest method testInvalidUserAuthorization.
@Test(expected = UnauthorizedException.class)
public void testInvalidUserAuthorization() throws Exception {
// Create principal that does not have AuthorizedUser role
DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "CN=ca, OU=acme"), UserType.USER, Arrays.asList(auths), Collections.singleton("Administrator"), null, 0L);
DatawavePrincipal p = new DatawavePrincipal(Collections.singletonList(user));
expect(ctx.getCallerPrincipal()).andReturn(p);
replayAll();
bean.submit("TestJob", "queryId:1243");
verifyAll();
}
use of datawave.security.authorization.DatawaveUser in project datawave by NationalSecurityAgency.
the class MapReduceStatePersisterTest method testDontFindSomeoneElsesJob.
@Test
public void testDontFindSomeoneElsesJob() throws Exception {
// create some entries
testPersistentCreate();
PowerMock.resetAll();
DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of("CN=Gal Some Other sogal, OU=acme", "CN=ca, OU=acme"), UserType.USER, Arrays.asList(auths), null, null, 0L);
principal = new DatawavePrincipal(Collections.singletonList(user));
EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal);
HashMap<String, String> trackingMap = new HashMap<>();
expect(connectionFactory.getTrackingMap(EasyMock.anyObject())).andReturn(trackingMap);
expect(connectionFactory.getConnection(EasyMock.eq(AccumuloConnectionFactory.Priority.ADMIN), EasyMock.eq(trackingMap))).andReturn(connection);
connectionFactory.returnConnection(connection);
replayAll();
MapReduceInfoResponseList result = bean.findById(id);
verifyAll();
assertEquals(0, result.getResults().size());
}
use of datawave.security.authorization.DatawaveUser in project datawave by NationalSecurityAgency.
the class MapReduceStatePersisterTest method setup.
@Before
public void setup() throws Exception {
System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson");
System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D");
connection = instance.getConnector("root", new PasswordToken(""));
if (connection.tableOperations().exists(TABLE_NAME))
connection.tableOperations().delete(TABLE_NAME);
if (connection.tableOperations().exists(INDEX_TABLE_NAME))
connection.tableOperations().delete(INDEX_TABLE_NAME);
DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "CN=ca, OU=acme"), UserType.USER, Arrays.asList(auths), null, null, 0L);
principal = new DatawavePrincipal(Collections.singletonList(user));
connectionFactory = createMock(AccumuloConnectionFactory.class);
ctx = createStrictMock(EJBContext.class);
bean = new MapReduceStatePersisterBean();
field(MapReduceStatePersisterBean.class, "connectionFactory").set(bean, connectionFactory);
field(MapReduceStatePersisterBean.class, "ctx").set(bean, ctx);
Logger.getLogger(MapReduceStatePersisterBean.class).setLevel(Level.OFF);
}
Aggregations