use of com.gw2auth.oauth2.server in project cobigen by devonfw.
the class OpenAPIInputReader method extractServers.
/**
* @param openApi document root
* @return list of {@link ServerDef}'s
*/
private List<ServerDef> extractServers(OpenApi3 openApi) {
List<ServerDef> servers = new LinkedList<>();
ServerDef serv;
for (Server server : openApi.getServers()) {
serv = new ServerDef();
serv.setDescription(server.getDescription());
serv.setURI(server.getUrl());
servers.add(serv);
}
return servers;
}
use of com.gw2auth.oauth2.server in project ChatSystem by Dofmor.
the class ServerDriver method main.
public static void main(String[] args) {
System.out.println("Enter an IP address: ");
Scanner input = new Scanner(System.in);
String ip = input.nextLine();
ip = ip.trim();
Server server = new Server(7777, "10.0.0.210");
server.run();
}
use of com.gw2auth.oauth2.server in project oauth2-server by gw2auth.
the class ApiTokenControllerTest method updateApiToken.
@WithGw2AuthLogin
public void updateApiToken(MockHttpSession session) throws Exception {
final long accountId = AuthenticationHelper.getUser(session).orElseThrow().getAccountId();
final UUID gw2AccountId = UUID.randomUUID();
final ApiTokenEntity apiToken = this.testHelper.createApiToken(accountId, gw2AccountId, Set.of(Gw2ApiPermission.ACCOUNT, Gw2ApiPermission.GUILDS), "TokenA");
// verified
this.testHelper.createAccountVerification(accountId, gw2AccountId);
// register 2 clients
final ClientRegistrationEntity clientRegistrationA = this.testHelper.createClientRegistration(accountId, "ClientA");
final ClientRegistrationEntity clientRegistrationB = this.testHelper.createClientRegistration(accountId, "ClientB");
// authorize 2 clients
final ClientConsentEntity clientConsentA = this.testHelper.createClientConsent(accountId, clientRegistrationA.id(), Set.of(Gw2ApiPermission.ACCOUNT.oauth2()));
final ClientConsentEntity clientConsentB = this.testHelper.createClientConsent(accountId, clientRegistrationB.id(), Set.of(Gw2ApiPermission.ACCOUNT.oauth2()));
final String authorizationIdA = this.testHelper.createClientAuthorization(accountId, clientConsentA.clientRegistrationId(), clientConsentA.authorizedScopes()).id();
final String authorizationIdB = this.testHelper.createClientAuthorization(accountId, clientConsentB.clientRegistrationId(), clientConsentB.authorizedScopes()).id();
// use this token in both clients
this.testHelper.createClientAuthorizationToken(accountId, authorizationIdA, gw2AccountId);
this.testHelper.createClientAuthorizationToken(accountId, authorizationIdB, gw2AccountId);
final String gw2ApiToken = TestHelper.randomRootToken();
// prepare the gw2 rest server
this.gw2RestServer.reset();
prepareGw2RestServerForTokenInfoRequest(gw2ApiToken, "Token Name", Set.of(Gw2ApiPermission.ACCOUNT));
preparedGw2RestServerForAccountRequest(gw2AccountId, gw2ApiToken, "Gw2AccountName.1234");
final String responseJson = this.mockMvc.perform(patch("/api/token/{gw2AccountId}", gw2AccountId).session(session).with(csrf()).queryParam("gw2ApiToken", gw2ApiToken).queryParam("displayName", "New Display Name")).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
final ObjectMapper mapper = new ObjectMapper();
final JsonNode apiTokenNode = mapper.readTree(responseJson);
assertExpectedApiToken(new ExpectedApiToken(apiToken, true, List.of(clientRegistrationA, clientRegistrationB)), // display name should be updated
"New Display Name", // api token should be updated
gw2ApiToken, // the new api token has less permissions than the original one
Set.of(Gw2ApiPermission.ACCOUNT.gw2()), apiTokenNode);
}
use of com.gw2auth.oauth2.server in project ets-ogcapi-features10 by opengeospatial.
the class OpenApiUtils method findBasePath.
private static String findBasePath(OpenApi3 apiModel, URI iut) {
String basePath = "/";
List<Server> serverUrls = apiModel.getServers();
for (Server serverUrl : serverUrls) {
Matcher matcher = Pattern.compile(serverUrl.getUrl()).matcher(iut.toString());
if (matcher.find()) {
String path = iut.toString().substring(matcher.end(), iut.toString().length());
if (!path.isEmpty()) {
basePath = path;
}
}
}
return basePath;
}
use of com.gw2auth.oauth2.server in project grpc-java by grpc.
the class ChannelzProtoUtil method toServer.
static Server toServer(InternalInstrumented<ServerStats> obj) {
ServerStats stats = getFuture(obj.getStats());
Server.Builder builder = Server.newBuilder().setRef(toServerRef(obj)).setData(toServerData(stats));
for (InternalInstrumented<SocketStats> listenSocket : stats.listenSockets) {
builder.addListenSocket(toSocketRef(listenSocket));
}
return builder.build();
}
Aggregations