use of com.aliyun.dysmsapi20170525.Client in project ORCID-Source by ORCID.
the class JpaJaxbClientAdapterTest method getClient.
private Client getClient() {
Client client = new Client();
client.setAllowAutoDeprecate(true);
client.setPersistentTokensEnabled(true);
client.setClientType(ClientType.CREATOR);
client.setDescription("description");
client.setGroupProfileId("group-profile-id");
client.setId("id");
client.setName("client-name");
client.setWebsite("client-website");
client.setAuthenticationProviderId("authentication-provider-id");
Set<ClientRedirectUri> clientRedirectUris = new HashSet<ClientRedirectUri>();
ClientRedirectUri rUri1 = new ClientRedirectUri();
Set<ScopePathType> scopes1 = new HashSet<ScopePathType>();
scopes1.add(ScopePathType.ACTIVITIES_READ_LIMITED);
rUri1.setPredefinedClientScopes(scopes1);
rUri1.setRedirectUri("redirect-uri-1");
rUri1.setRedirectUriType("type-1");
rUri1.setUriActType("uri-act-type-1");
rUri1.setUriGeoArea("uri-geo-area-1");
ClientRedirectUri rUri2 = new ClientRedirectUri();
Set<ScopePathType> scopes2 = new HashSet<ScopePathType>();
scopes2.add(ScopePathType.ACTIVITIES_UPDATE);
rUri2.setPredefinedClientScopes(scopes2);
rUri2.setRedirectUri("redirect-uri-2");
rUri2.setRedirectUriType("type-2");
rUri2.setUriActType("uri-act-type-2");
rUri2.setUriGeoArea("uri-geo-area-2");
ClientRedirectUri rUri3 = new ClientRedirectUri();
Set<ScopePathType> scopes3 = new HashSet<ScopePathType>();
scopes3.add(ScopePathType.AFFILIATIONS_CREATE);
rUri3.setPredefinedClientScopes(scopes3);
rUri3.setRedirectUri("redirect-uri-3");
rUri3.setRedirectUriType("type-3");
rUri3.setUriActType("uri-act-type-3");
rUri3.setUriGeoArea("uri-geo-area-3");
clientRedirectUris.add(rUri1);
clientRedirectUris.add(rUri2);
clientRedirectUris.add(rUri3);
client.setClientRedirectUris(clientRedirectUris);
return client;
}
use of com.aliyun.dysmsapi20170525.Client in project ORCID-Source by ORCID.
the class ClientManagerReadOnlyTest method getClientsTest.
@Test
public void getClientsTest() {
String seed1 = RandomStringUtils.randomAlphanumeric(30);
String seed2 = RandomStringUtils.randomAlphanumeric(30);
String seed3 = RandomStringUtils.randomAlphanumeric(30);
List<ClientDetailsEntity> clients = new ArrayList<ClientDetailsEntity>();
clients.add(getClientDetailsEntity(seed1));
clients.add(getClientDetailsEntity(seed2));
clients.add(getClientDetailsEntity(seed3));
when(daoMock.findByGroupId(anyString())).thenReturn(clients);
Set<Client> results = clientManagerReadOnly.getClients("anything");
assertEquals(3, results.size());
for (Client client : results) {
if (client.getId().equals(seed1)) {
assertEquals(getClient(seed1), client);
} else if (client.getId().equals(seed2)) {
assertEquals(getClient(seed2), client);
} else if (client.getId().equals(seed3)) {
assertEquals(getClient(seed3), client);
} else {
fail("Unknown id " + client.getId());
}
}
}
use of com.aliyun.dysmsapi20170525.Client in project ORCID-Source by ORCID.
the class ClientManagerTest method resetClientSecret.
@Test
public void resetClientSecret() {
String clientId = "APP-5555555555555556";
// Get an existing client
Client client = clientManagerReadOnly.get(clientId);
assertNotNull(client);
assertNotNull(client.getDecryptedSecret());
assertFalse(PojoUtil.isEmpty(client.getDecryptedSecret()));
assertTrue(client.getDecryptedSecret().length() > 1);
String secret1 = client.getDecryptedSecret();
// Reset it one time
clientManager.resetClientSecret(clientId);
client = clientManagerReadOnly.get(clientId);
assertFalse(PojoUtil.isEmpty(client.getDecryptedSecret()));
assertTrue(client.getDecryptedSecret().length() > 1);
assertNotEquals(secret1, client.getDecryptedSecret());
String secret2 = client.getDecryptedSecret();
// Reset it the second time
clientManager.resetClientSecret(clientId);
client = clientManagerReadOnly.get(clientId);
assertFalse(PojoUtil.isEmpty(client.getDecryptedSecret()));
assertTrue(client.getDecryptedSecret().length() > 1);
assertNotEquals(secret1, client.getDecryptedSecret());
assertNotEquals(secret2, client.getDecryptedSecret());
String secret3 = client.getDecryptedSecret();
// Update the client and fetch secret again to confirm it doesn't changed
client.setName("Updated name");
clientManager.edit(client, false);
client = clientManagerReadOnly.get(clientId);
assertEquals("Updated name", client.getName());
assertFalse(PojoUtil.isEmpty(client.getDecryptedSecret()));
assertTrue(client.getDecryptedSecret().length() > 1);
assertEquals(secret3, client.getDecryptedSecret());
}
use of com.aliyun.dysmsapi20170525.Client in project ORCID-Source by ORCID.
the class ClientManagerTest method getClient.
private Client getClient(String randomString, String memberId) {
Client client = new Client();
client.setAllowAutoDeprecate(true);
client.setAuthenticationProviderId("authentication-provider-id " + randomString);
client.setClientType(ClientType.CREATOR);
client.setDescription("description " + randomString);
client.setEmailAccessReason("email-access-reason " + randomString);
client.setGroupProfileId(memberId);
client.setId(randomString);
client.setName("client-name " + randomString);
client.setPersistentTokensEnabled(true);
client.setWebsite("client-website " + randomString);
Set<ClientRedirectUri> clientRedirectUris = new HashSet<ClientRedirectUri>();
ClientRedirectUri rUri1 = new ClientRedirectUri();
Set<ScopePathType> scopes1 = new HashSet<ScopePathType>();
scopes1.add(ScopePathType.ACTIVITIES_READ_LIMITED);
rUri1.setPredefinedClientScopes(scopes1);
rUri1.setRedirectUri("redirect-uri-1 " + randomString);
rUri1.setRedirectUriType("type-1 " + randomString);
rUri1.setUriActType("uri-act-type-1 " + randomString);
rUri1.setUriGeoArea("uri-geo-area-1 " + randomString);
ClientRedirectUri rUri2 = new ClientRedirectUri();
Set<ScopePathType> scopes2 = new HashSet<ScopePathType>();
scopes2.add(ScopePathType.ACTIVITIES_UPDATE);
rUri2.setPredefinedClientScopes(scopes2);
rUri2.setRedirectUri("redirect-uri-2 " + randomString);
rUri2.setRedirectUriType("type-2 " + randomString);
rUri2.setUriActType("uri-act-type-2 " + randomString);
rUri2.setUriGeoArea("uri-geo-area-2 " + randomString);
ClientRedirectUri rUri3 = new ClientRedirectUri();
Set<ScopePathType> scopes3 = new HashSet<ScopePathType>();
scopes3.add(ScopePathType.AFFILIATIONS_CREATE);
rUri3.setPredefinedClientScopes(scopes3);
rUri3.setRedirectUri("redirect-uri-3 " + randomString);
rUri3.setRedirectUriType("type-3 " + randomString);
rUri3.setUriActType("uri-act-type-3 " + randomString);
rUri3.setUriGeoArea("uri-geo-area-3 " + randomString);
clientRedirectUris.add(rUri1);
clientRedirectUris.add(rUri2);
clientRedirectUris.add(rUri3);
client.setClientRedirectUris(clientRedirectUris);
return client;
}
use of com.aliyun.dysmsapi20170525.Client in project service-proxy by membrane.
the class RefreshTokenFlow method processWithParameters.
@Override
protected Response processWithParameters() throws Exception {
if (!verifyClientThroughParams())
return OAuth2Util.createParameterizedJsonErrorResponse(exc, jsonGen, "error", "unauthorized_client");
String username;
try {
username = authServer.getRefreshTokenGenerator().getUsername(getRefreshToken());
} catch (NoSuchElementException ex) {
return OAuth2Util.createParameterizedJsonErrorResponse(exc, jsonGen, "error", "invalid_request");
}
params.put(ParamNames.USERNAME, username);
try {
authServer.getRefreshTokenGenerator().invalidateToken(getRefreshToken(), getClientId(), getClientSecret());
} catch (NoSuchElementException ex) {
return OAuth2Util.createParameterizedJsonErrorResponse(exc, jsonGen, "error", "invalid_grant");
}
// TODO check if scope is "narrower" than before
Client client;
try {
synchronized (authServer.getClientList()) {
client = authServer.getClientList().getClient(getClientId());
}
} catch (Exception e) {
return OAuth2Util.createParameterizedJsonErrorResponse(exc, jsonGen, "error", "invalid_client");
}
String grantTypes = client.getGrantTypes();
if (!grantTypes.contains(getGrantType())) {
return OAuth2Util.createParameterizedJsonErrorResponse(exc, jsonGen, "error", "invalid_grant_type");
}
scope = getScope();
token = authServer.getTokenGenerator().getToken(getUsername(), getClientId(), getClientSecret());
refreshToken = authServer.getRefreshTokenGenerator().getToken(getUsername(), getClientId(), getClientSecret());
SessionManager.Session session = getSessionForAuthorizedUserWithParams();
synchronized (session) {
session.getUserAttributes().put(ACCESS_TOKEN, token);
}
authServer.getSessionFinder().addSessionForToken(token, session);
if (OAuth2Util.isOpenIdScope(scope)) {
idToken = createSignedIdToken(session, username, client);
}
return new NoResponse();
}
Aggregations