Skip to content

Commit

Permalink
installation provider
Browse files Browse the repository at this point in the history
  • Loading branch information
patriot1burke committed Jan 6, 2016
1 parent 1cbe5c4 commit 64de96d
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.keycloak.representations.info;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class ClientInstallationRepresentation {
protected String id;
protected String protocol;
protected boolean downloadOnly;
protected String displayType;
protected String helpText;
protected String filename;
protected String mediaType;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

public boolean isDownloadOnly() {
return downloadOnly;
}

public void setDownloadOnly(boolean downloadOnly) {
this.downloadOnly = downloadOnly;
}

public String getDisplayType() {
return displayType;
}

public void setDisplayType(String displayType) {
this.displayType = displayType;
}

public String getHelpText() {
return helpText;
}

public void setHelpText(String helpText) {
this.helpText = helpText;
}

public String getFilename() {
return filename;
}

public void setFilename(String filename) {
this.filename = filename;
}

public String getMediaType() {
return mediaType;
}

public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
}
9 changes: 9 additions & 0 deletions core/src/main/java/org/keycloak/representations/info/ServerInfoRepresentation.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ServerInfoRepresentation {

private Map<String, List<ProtocolMapperTypeRepresentation>> protocolMapperTypes;
private Map<String, List<ProtocolMapperRepresentation>> builtinProtocolMappers;
private Map<String, List<ClientInstallationRepresentation>> clientInstallations;

private Map<String, List<String>> enums;

Expand Down Expand Up @@ -105,4 +106,12 @@ public Map<String, List<String>> getEnums() {
public void setEnums(Map<String, List<String>> enums) {
this.enums = enums;
}

public Map<String, List<ClientInstallationRepresentation>> getClientInstallations() {
return clientInstallations;
}

public void setClientInstallations(Map<String, List<ClientInstallationRepresentation>> clientInstallations) {
this.clientInstallations = clientInstallations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ module.config([ '$routeProvider', function($routeProvider) {
},
client : function(ClientLoader) {
return ClientLoader();
},
serverInfo : function(ServerInfoLoader) {
return ServerInfoLoader();
}
},
controller : 'ClientInstallationCtrl'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,19 +685,33 @@ module.controller('ClientListCtrl', function($scope, realm, clients, Client, ser
};
});

module.controller('ClientInstallationCtrl', function($scope, realm, client, ClientInstallation,ClientInstallationJBoss, $http, $routeParams) {
module.controller('ClientInstallationCtrl', function($scope, realm, client, serverInfo, ClientInstallation,$http, $routeParams) {
$scope.realm = realm;
$scope.client = client;
$scope.installation = null;
$scope.download = null;
$scope.configFormat = null;
$scope.filename = null;

$scope.configFormats = [
"Keycloak JSON",
"Wildfly/EAP Subsystem XML"
];
var protocol = client.protocol;
if (!protocol) protocol = 'openid-connect';
$scope.configFormats = serverInfo.clientInstallations[protocol];
console.log('configFormats.length: ' + $scope.configFormats.length);

$scope.changeFormat = function() {
var url = ClientInstallation.url({ realm: $routeParams.realm, client: $routeParams.client, provider: $scope.configFormat.id });
$http.get(url).success(function(data) {
var installation = data;
if ($scope.configFormat.mediaType == 'application/json') {
installation = angular.fromJson(data);
installation = angular.toJson(installation, true);
}
$scope.installation = installation;
})
};


/*
$scope.changeFormat = function() {
if ($scope.configFormat == "Keycloak JSON") {
$scope.filename = 'keycloak.json';
Expand All @@ -720,9 +734,10 @@ module.controller('ClientInstallationCtrl', function($scope, realm, client, Clie
console.debug($scope.filename);
};
*/

$scope.download = function() {
saveAs(new Blob([$scope.installation], { type: $scope.type }), $scope.filename);
saveAs(new Blob([$scope.installation], { type: $scope.configFormat.mediaType }), $scope.configFormat.filename);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,6 @@ module.factory('ClientClaimsLoader', function(Loader, ClientClaims, $route, $q)
});
});

module.factory('ClientInstallationLoader', function(Loader, ClientInstallation, $route, $q) {
return Loader.get(ClientInstallation, function() {
return {
realm : $route.current.params.realm,
client : $route.current.params.client
}
});
});

module.factory('ClientRoleListLoader', function(Loader, ClientRole, $route, $q) {
return Loader.query(ClientRole, function() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,16 +1044,28 @@ module.factory('ClientDescriptionConverter', function($resource) {
});
});

/*
module.factory('ClientInstallation', function($resource) {
return $resource(authUrl + '/admin/realms/:realm/clients/:client/installation/providers/:provider', {
realm : '@realm',
client : '@client',
provider : '@provider'
});
});
*/



module.factory('ClientInstallation', function($resource) {
var url = authUrl + '/admin/realms/:realm/clients/:client/installation/json';
var url = authUrl + '/admin/realms/:realm/clients/:client/installation/providers/:provider';
return {
url : function(parameters)
{
return url.replace(':realm', parameters.realm).replace(':client', parameters.client);
return url.replace(':realm', parameters.realm).replace(':client', parameters.client).replace(':provider', parameters.provider);
}
}
});

module.factory('ClientInstallationJBoss', function($resource) {
var url = authUrl + '/admin/realms/:realm/clients/:client/installation/jboss';
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="col-md-6">
<div class="input-group">
<div>
<select class="form-control" id="configFormats" name="configFormats" ng-change="changeFormat()" ng-model="configFormat" ng-options="a for a in configFormats">
<select class="form-control" id="configFormats" name="configFormats" ng-change="changeFormat()" ng-model="configFormat" ng-options="a.displayType for a in configFormats">
<option value="" selected> {{:: 'select-a-format' | translate}} </option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.keycloak.protocol;

import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderFactory;

import javax.ws.rs.core.Response;
import java.net.URI;

/**
* Provides a template/sample client config adapter file. For example keycloak.json for our OIDC adapter. keycloak-saml.xml for our SAML client adapter
*
*
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public interface ClientInstallationProvider extends Provider, ProviderFactory<ClientInstallationProvider> {
Response generateInstallation(KeycloakSession session, RealmModel realm, ClientModel client, URI serverBaseUri);
String getProtocol();
String getDisplayType();
String getHelpText();
String getFilename();
String getMediaType();
boolean isDownloadOnly();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.keycloak.protocol;

import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderFactory;
import org.keycloak.provider.Spi;

/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/
public class ClientInstallationSpi implements Spi {

@Override
public boolean isInternal() {
return true;
}

@Override
public String getName() {
return "client-installation";
}

@Override
public Class<? extends Provider> getProviderClass() {
return ClientInstallationProvider.class;
}

@Override
public Class<? extends ProviderFactory> getProviderFactoryClass() {
return ClientInstallationProvider.class;
}

}
Loading

0 comments on commit 64de96d

Please sign in to comment.