@XmlRootElement(name = "domains")
public class Domains {
- private List<Domain> domains = new ArrayList<Domain>();
+ private List<Domain> domains = new ArrayList<>();
public void setDomains(List<Domain> domains) {
this.domains = domains;
@XmlRootElement(name = "roles")
public class Roles {
- private List<Role> roles = new ArrayList<Role>();
+ private List<Role> roles = new ArrayList<>();
public void setRoles(List<Role> roles) {
this.roles = roles;
@XmlRootElement(name = "users")
public class Users {
- private List<User> users = new ArrayList<User>();
+ private List<User> users = new ArrayList<>();
public void setUsers(List<User> users) {
this.users = users;
if (!Strings.isNullOrEmpty(cert)) {
final GetNodeCertifcateOutput nodeCertOutput = new GetNodeCertifcateOutputBuilder().setNodeCert(cert)
.build();
- futureResult.set(RpcResultBuilder.<GetNodeCertifcateOutput>success(nodeCertOutput).build());
+ futureResult.set(RpcResultBuilder.success(nodeCertOutput).build());
} else {
futureResult.set(RpcResultBuilder.<GetNodeCertifcateOutput>failed().build());
}
final String cert = aaaCertProvider.getODLKeyStoreCertificate(false);
if (!Strings.isNullOrEmpty(cert)) {
final GetODLCertificateOutput odlCertOutput = new GetODLCertificateOutputBuilder().setOdlCert(cert).build();
- futureResult.set(RpcResultBuilder.<GetODLCertificateOutput>success(odlCertOutput).build());
+ futureResult.set(RpcResultBuilder.success(odlCertOutput).build());
} else {
futureResult.set(RpcResultBuilder.<GetODLCertificateOutput>failed().build());
}
if (!Strings.isNullOrEmpty(certReq)) {
final GetODLCertificateReqOutput odlCertReqOutput = new GetODLCertificateReqOutputBuilder()
.setOdlCertReq(certReq).build();
- futureResult.set(RpcResultBuilder.<GetODLCertificateReqOutput>success(odlCertReqOutput).build());
+ futureResult.set(RpcResultBuilder.success(odlCertReqOutput).build());
} else {
futureResult.set(RpcResultBuilder.<GetODLCertificateReqOutput>failed().build());
}
MediaType mediaType, MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException, WebApplicationException {
- InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
- try {
+ try (InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8")) {
return gson.fromJson(reader, type);
- } finally {
- reader.close();
}
}
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public void writeTo(T type, Class<?> theClass, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
- OutputStream entityStream) throws IOException, WebApplicationException {
+ OutputStream entityStream) throws WebApplicationException {
- PrintWriter printWriter = new PrintWriter(entityStream);
- try {
+ try (PrintWriter printWriter = new PrintWriter(entityStream)) {
String json;
if (ui.getQueryParameters().containsKey(PRETTY_PRINT)) {
json = prettyGson.toJson(type);
}
printWriter.write(json);
printWriter.flush();
- } finally {
- printWriter.close();
}
}
}
// adds a store for the default "sdn" domain
static {
claimCache.put(IIDMStore.DEFAULT_DOMAIN,
- new ConcurrentHashMap<PasswordCredentials, Claim>());
+ new ConcurrentHashMap<>());
}
private final IIDMStore idmStore;
}
// check create domain
- Map<String, String> domainData = new HashMap<String, String>();
+ Map<String, String> domainData = new HashMap<>();
domainData.put("name", "dom1");
domainData.put("description", "test dom");
domainData.put("enabled", "true");
assertTrue(domain.getName().equals("dom1Update"));
// check create grant
- Map<String, String> grantData = new HashMap<String, String>();
+ Map<String, String> grantData = new HashMap<>();
grantData.put("roleid", "1");
clientResponse = resource().path("/v1/domains/1/users/0/roles").type(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, grantData);
assertEquals(404, clientResponse.getStatus());
// check validate user (admin)
- Map<String, String> usrPwdData = new HashMap<String, String>();
+ Map<String, String> usrPwdData = new HashMap<>();
usrPwdData.put("username", "admin");
usrPwdData.put("userpwd", "admin");
clientResponse = resource().path("/v1/domains/0/users/roles").type(MediaType.APPLICATION_JSON)
public class IDMTestStore implements IIDMStore {
- private List<Domain> domains = new ArrayList<Domain>();
- private List<Grant> grants = new ArrayList<Grant>();
- private List<Role> roles = new ArrayList<Role>();
- private List<User> users = new ArrayList<User>();
+ private List<Domain> domains = new ArrayList<>();
+ private List<Grant> grants = new ArrayList<>();
+ private List<Role> roles = new ArrayList<>();
+ private List<User> users = new ArrayList<>();
public IDMTestStore() {
// TODO Auto-generated constructor stub
}
for (Grant grant : grants) {
if (grant.getUserid().equals(user.getUserid()) && grant.getDomainid().equals(domain.getDomainid())) {
- List<User> usrList = new ArrayList<User>();
+ List<User> usrList = new ArrayList<>();
usrList.add(user);
usrs.setUsers(usrList);
break;
@Override
public Grants getGrants(String domainid, String userid) throws IDMStoreException {
Grants usrGrants = new Grants();
- List<Grant> usrGrant = new ArrayList<Grant>();
+ List<Grant> usrGrant = new ArrayList<>();
for (Grant grant : grants) {
if (grant.getUserid().equals(userid) && grant.getDomainid().equals(domainid)) {
usrGrant.add(grant);
@Override
public Grants getGrants(String userid) throws IDMStoreException {
Grants usrGrants = new Grants();
- List<Grant> usrGrant = new ArrayList<Grant>();
+ List<Grant> usrGrant = new ArrayList<>();
for (Grant grant : grants) {
if (grant.getUserid().equals(userid)) {
usrGrant.add(grant);
}
// check create Role
- Map<String, String> roleData = new HashMap<String, String>();
+ Map<String, String> roleData = new HashMap<>();
roleData.put("name", "role1");
roleData.put("description", "test Role");
roleData.put("domainid", "0");
}
// Bug 8382: if a role id is specified, 400 is returned
- roleData = new HashMap<String, String>();
+ roleData = new HashMap<>();
roleData.put("name", "role1");
roleData.put("description", "test Role");
roleData.put("domainid", "0");
}
// check create user
- Map<String, String> usrData = new HashMap<String, String>();
+ Map<String, String> usrData = new HashMap<>();
usrData.put("name", "usr1");
usrData.put("description", "test user");
usrData.put("enabled", "true");
}
// Bug 8382: if a user id is specified, 400 is returned
- usrData = new HashMap<String, String>();
+ usrData = new HashMap<>();
usrData.put("name", "usr1");
usrData.put("description", "test user");
usrData.put("enabled", "true");
class TestPrincipalCollection implements PrincipalCollection {
private static final long serialVersionUID = -1236759619455574475L;
- Vector<String> collection = new Vector<String>();
+ Vector<String> collection = new Vector<>();
TestPrincipalCollection(String element) {
collection.add(element);
@Override
public Set<String> asSet() {
- HashSet<String> set = new HashSet<String>();
+ HashSet<String> set = new HashSet<>();
set.addAll(collection);
return set;
}
// emulates an ldap search and returns the mocked up test class
when(
ldapContext.search((String) any(), (String) any(),
- (SearchControls) any())).thenReturn(new TestNamingEnumeration());
+ any())).thenReturn(new TestNamingEnumeration());
LdapContextFactory ldapContextFactory = mock(LdapContextFactory.class);
when(ldapContextFactory.getSystemLdapContext()).thenReturn(ldapContext);
AuthorizationInfo authorizationInfo = new ODLJndiLdapRealm().queryForAuthorizationInfo(
@Test
public void testBuildAuthorizationInfo() {
assertNull(ODLJndiLdapRealm.buildAuthorizationInfo(null));
- Set<String> roleNames = new HashSet<String>();
+ Set<String> roleNames = new HashSet<>();
roleNames.add("engineering");
AuthorizationInfo authorizationInfo = ODLJndiLdapRealm.buildAuthorizationInfo(roleNames);
assertNotNull(authorizationInfo);
// emulates an ldap search and returns the mocked up test class
when(
ldapContext.search((String) any(), (String) any(),
- (SearchControls) any())).thenReturn(new TestNamingEnumeration());
+ any())).thenReturn(new TestNamingEnumeration());
// extracts the roles for "testuser" and ensures engineering is returned
Set<String> roles = ldapRealm.getRoleNamesForUser("testuser", ldapContext);