public static OAuthClientRepresentation toRepresentation(OAuthClientModel model) { OAuthClientRepresentation rep = new OAuthClientRepresentation(); rep.setId(model.getId()); rep.setName(model.getClientId()); rep.setEnabled(model.isEnabled()); rep.setPublicClient(model.isPublicClient()); Set<String> redirectUris = model.getRedirectUris(); if (redirectUris != null) { rep.setRedirectUris(new LinkedList<String>(redirectUris)); } Set<String> webOrigins = model.getWebOrigins(); if (webOrigins != null) { rep.setWebOrigins(new LinkedList<String>(webOrigins)); } rep.setNotBefore(model.getNotBefore()); return rep; }
@GET @Produces(MediaType.APPLICATION_JSON) @NoCache public List<OAuthClientRepresentation> getOAuthClients() { List<OAuthClientRepresentation> rep = new ArrayList<OAuthClientRepresentation>(); List<OAuthClientModel> oauthModels = realm.getOAuthClients(); boolean view = auth.hasView(); for (OAuthClientModel oauth : oauthModels) { if (view) { rep.add(OAuthClientManager.toRepresentation(oauth)); } else { OAuthClientRepresentation client = new OAuthClientRepresentation(); client.setName(oauth.getClientId()); rep.add(client); } } return rep; }
public InstallationAdapterConfig toInstallationRepresentation( RealmModel realmModel, OAuthClientModel model, URI baseUri) { InstallationAdapterConfig rep = new InstallationAdapterConfig(); rep.setRealm(realmModel.getName()); rep.setRealmKey(realmModel.getPublicKeyPem()); rep.setSslNotRequired(realmModel.isSslNotRequired()); rep.setAuthServerUrl(baseUri.toString()); if (model.isPublicClient()) rep.setPublicClient(true); rep.setResource(model.getClientId()); if (!model.isPublicClient()) { Map<String, String> creds = new HashMap<String, String>(); creds.put(CredentialRepresentation.SECRET, model.getSecret()); rep.setCredentials(creds); } return rep; }