use of ddf.security.claims.impl.ClaimImpl in project ddf by codice.
the class PKIRealmTest method setup.
@Before
public void setup() {
List<ClaimsHandler> claimsHandlers = new ArrayList<>();
claimsHandlers.add(mock(ClaimsHandler.class));
claimsHandlers.add(mock(ClaimsHandler.class));
ClaimsCollection claims1 = new ClaimsCollectionImpl();
ClaimImpl email1 = new ClaimImpl("email");
email1.addValue("test@example.com");
claims1.add(email1);
ClaimsCollection claims2 = new ClaimsCollectionImpl();
ClaimImpl email2 = new ClaimImpl("email");
email2.addValue("tester@example.com");
claims2.add(email2);
when(claimsHandlers.get(0).retrieveClaims(any())).thenReturn(claims1);
when(claimsHandlers.get(1).retrieveClaims(any())).thenReturn(claims2);
pkiRealm.setClaimsHandlers(claimsHandlers);
}
use of ddf.security.claims.impl.ClaimImpl in project ddf by codice.
the class UsernamePasswordRealmTest method setup.
@Before
public void setup() {
List<ClaimsHandler> claimsHandlers = new ArrayList<>();
claimsHandlers.add(mock(ClaimsHandler.class));
claimsHandlers.add(mock(ClaimsHandler.class));
ClaimsCollection claims1 = new ClaimsCollectionImpl();
ClaimImpl email1 = new ClaimImpl("email");
email1.addValue("test@example.com");
claims1.add(email1);
ClaimsCollection claims2 = new ClaimsCollectionImpl();
ClaimImpl email2 = new ClaimImpl("email");
email2.addValue("tester@example.com");
claims2.add(email2);
when(claimsHandlers.get(0).retrieveClaims(any())).thenReturn(claims1);
when(claimsHandlers.get(1).retrieveClaims(any())).thenReturn(claims2);
upRealm.setClaimsHandlers(claimsHandlers);
JaasRealm jaasRealm = mock(JaasRealm.class);
when(jaasRealm.getName()).thenReturn("realm");
upRealm.realmList.add(jaasRealm);
}
use of ddf.security.claims.impl.ClaimImpl in project ddf by codice.
the class AttributeQueryClaimsHandler method createSingleValuedClaim.
/**
* Creates a single valued claim.
*
* @param claimType The claim type.
* @param claimValue The claim value.
* @return The claim.
* @throws URISyntaxException
*/
protected Claim createSingleValuedClaim(String claimType, String claimValue) {
Claim claim = new ClaimImpl(claimType);
claim.addValue(claimValue);
LOGGER.debug("Created claim with type [{}] and value [{}].", claimType, claimValue);
return claim;
}
use of ddf.security.claims.impl.ClaimImpl in project ddf by codice.
the class PropertyFileClaimsHandler method retrieveClaims.
@Override
public ClaimsCollection retrieveClaims(ClaimsParameters parameters) {
ClaimsCollection claimsColl = new ClaimsCollectionImpl();
Principal principal = parameters.getPrincipal();
String user = getUser(principal);
if (user == null) {
LOGGER.info("Could not determine user name, possible authentication error. Returning no claims.");
return claimsColl;
}
String userAttributes = userMapping.get(user);
if (userAttributes != null) {
String[] attributes = userAttributes.split(",");
Claim c = new ClaimImpl(roleClaimType);
for (int i = 1; i < attributes.length; i++) {
c.addValue(attributes[i]);
}
claimsColl.add(c);
}
Claim idClaim = new ClaimImpl(idClaimType);
idClaim.addValue(user);
claimsColl.add(idClaim);
return claimsColl;
}
use of ddf.security.claims.impl.ClaimImpl in project ddf by codice.
the class UsersAttributesFileClaimsHandler method retrieveClaims.
@Override
public ClaimsCollection retrieveClaims(ClaimsParameters claimsParameters) {
ClaimsCollection claimsColl = new ClaimsCollectionImpl();
Principal principal = claimsParameters.getPrincipal();
if (principal == null) {
return claimsColl;
}
String name;
if (principal instanceof X500Principal) {
name = subjectOperations.getCommonName((X500Principal) principal);
} else {
name = principal.getName();
}
Map<String, Set<String>> userMap = json.get(name);
if (userMap == null) {
userMap = attemptToFindAMatchingRegexFormatUserEntry(principal, json);
}
if (userMap == null) {
return claimsColl;
}
for (Map.Entry<String, Set<String>> claimEntry : userMap.entrySet()) {
Set<String> attributeValue = claimEntry.getValue();
Claim c = new ClaimImpl(claimEntry.getKey());
if (attributeValue != null) {
attributeValue.forEach(c::addValue);
claimsColl.add(c);
}
}
return claimsColl;
}
Aggregations