use of org.apereo.cas.configuration.model.support.gua.GraphicalUserAuthenticationProperties in project cas by apereo.
the class LdapUserGraphicalAuthenticationRepository method getGraphics.
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Response<SearchResult> response = searchForId(username);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(gua.getLdap().getImageAttribute());
if (attribute != null && attribute.isBinary()) {
return ByteSource.wrap(attribute.getBinaryValue());
}
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
use of org.apereo.cas.configuration.model.support.gua.GraphicalUserAuthenticationProperties in project cas by apereo.
the class LdapUserGraphicalAuthenticationRepository method searchForId.
private Response<SearchResult> searchForId(final String id) throws LdapException {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final SearchFilter filter = Beans.newLdaptiveSearchFilter(gua.getLdap().getUserFilter(), Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, Arrays.asList(id));
return LdapUtils.executeSearchOperation(Beans.newLdaptiveConnectionFactory(gua.getLdap()), gua.getLdap().getBaseDn(), filter, new String[] { gua.getLdap().getImageAttribute() }, ReturnAttributes.NONE.value());
}
use of org.apereo.cas.configuration.model.support.gua.GraphicalUserAuthenticationProperties in project cas by apereo.
the class StaticUserGraphicalAuthenticationRepository method getGraphics.
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Resource resource = resourceLoader.getResource(gua.getResource().getLocation());
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(resource.getInputStream(), bos);
return ByteSource.wrap(bos.toByteArray());
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
Aggregations