use of org.xdi.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class EndSessionRestWebServiceImpl method getRpFrontchannelLogoutUris.
private Set<String> getRpFrontchannelLogoutUris(Pair<SessionState, AuthorizationGrant> pair) {
final Set<String> result = Sets.newHashSet();
SessionState sessionState = pair.getFirst();
AuthorizationGrant authorizationGrant = pair.getSecond();
if (sessionState == null) {
log.error("session_state is not passed to endpoint (as cookie or manually). Therefore unable to match clients for session_state." + "Http based html will contain no iframes.");
return result;
}
final Set<Client> clientsByDns = sessionState.getPermissionGrantedMap() != null ? clientService.getClient(sessionState.getPermissionGrantedMap().getClientIds(true), true) : Sets.<Client>newHashSet();
if (authorizationGrant != null) {
clientsByDns.add(authorizationGrant.getClient());
}
for (Client client : clientsByDns) {
String[] logoutUris = client.getFrontChannelLogoutUri();
if (logoutUris == null) {
continue;
}
for (String logoutUri : logoutUris) {
if (Util.isNullOrEmpty(logoutUri)) {
// skip client if logout_uri is blank
continue;
}
if (client.getFrontChannelLogoutSessionRequired() != null && client.getFrontChannelLogoutSessionRequired()) {
if (logoutUri.contains("?")) {
logoutUri = logoutUri + "&sid=" + sessionState.getId();
} else {
logoutUri = logoutUri + "?sid=" + sessionState.getId();
}
}
result.add(logoutUri);
}
}
return result;
}
use of org.xdi.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanUpClientTest method cleanUpClient.
@Test
@Parameters(value = "usedClients")
public void cleanUpClient(String usedClients) {
Assert.assertNotNull(usedClients);
List<String> usedClientsList = Arrays.asList(StringHelper.split(usedClients, ",", true, false));
output("Used clients: " + usedClientsList);
int clientsResultSetSize = 50;
int countResults = 0;
int countRemoved = 0;
boolean existsMoreClients = true;
while (existsMoreClients && countResults < 10000) {
List<Client> clients = clientService.getAllClients(new String[] { "inum" }, clientsResultSetSize);
existsMoreClients = clients.size() == clientsResultSetSize;
countResults += clients.size();
Assert.assertNotNull(clients);
output("Found clients: " + clients.size());
output("Total clients: " + countResults);
for (Client client : clients) {
String clientId = client.getClientId();
if (!usedClientsList.contains(clientId)) {
try {
clientService.remove(client);
} catch (EntryPersistenceException ex) {
output("Failed to remove client: " + ex.getMessage());
}
countRemoved++;
}
}
}
output("Removed clients: " + countRemoved);
}
use of org.xdi.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class AuthenticationService method configureSessionClient.
public void configureSessionClient() {
String clientInum = credentials.getUsername();
log.debug("ConfigureSessionClient: username: '{}', credentials: '{}'", clientInum, System.identityHashCode(credentials));
Client client = clientService.getClient(clientInum);
configureSessionClient(client);
}
use of org.xdi.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class CleanerTimer method processRegisteredClients.
private void processRegisteredClients() {
log.debug("Start Client clean up");
BatchOperation<Client> clientBatchService = new BatchOperation<Client>(ldapEntryManager) {
@Override
protected List<Client> getChunkOrNull(int chunkSize) {
return clientService.getClientsWithExpirationDate(this, chunkSize, chunkSize);
}
@Override
protected void performAction(List<Client> entries) {
for (Client client : entries) {
try {
GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
GregorianCalendar expirationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
expirationDate.setTime(client.getClientSecretExpiresAt());
if (expirationDate.before(now)) {
List<AuthorizationGrant> toRemove = authorizationGrantList.getAuthorizationGrant(client.getClientId());
authorizationGrantList.removeAuthorizationGrants(toRemove);
log.debug("Removing Client: {}, Expiration date: {}", client.getClientId(), client.getClientSecretExpiresAt());
clientService.remove(client);
}
} catch (Exception e) {
log.error("Failed to remove entry", e);
}
}
}
};
clientBatchService.iterateAllByChunks(BATCH_SIZE);
log.debug("End Client clean up");
}
use of org.xdi.oxauth.model.registration.Client in project oxAuth by GluuFederation.
the class ClientService method authenticate.
/**
* Authenticate client.
*
* @param clientId Client inum.
* @param password Client password.
* @return <code>true</code> if success, otherwise <code>false</code>.
*/
public boolean authenticate(String clientId, String password) {
log.debug("Authenticating Client with LDAP: clientId = {}", clientId);
boolean authenticated = false;
try {
Client client = getClient(clientId);
String decryptedClientSecret = decryptSecret(client.getClientSecret());
authenticated = client != null && decryptedClientSecret != null && decryptedClientSecret.equals(password);
} catch (StringEncrypter.EncryptionException e) {
log.error(e.getMessage(), e);
}
return authenticated;
}
Aggregations