diff --git a/core/src/main/java/org/keycloak/AbstractOAuthClient.java b/core/src/main/java/org/keycloak/AbstractOAuthClient.java index 955f9df1b0..592ddab405 100755 --- a/core/src/main/java/org/keycloak/AbstractOAuthClient.java +++ b/core/src/main/java/org/keycloak/AbstractOAuthClient.java @@ -111,7 +111,7 @@ public class AbstractOAuthClient { .param("grant_type", "authorization_code") .param("code", code) .param("client_id", clientId) - .param("Password", password) + .param("password", password) .param("redirect_uri", redirectUri); Response res = client.target(codeUrl).request().header(HttpHeaders.AUTHORIZATION, authHeader).post(Entity.form(codeForm)); try { diff --git a/core/src/main/java/org/keycloak/representations/idm/ResourceRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/ApplicationRepresentation.java similarity index 91% rename from core/src/main/java/org/keycloak/representations/idm/ResourceRepresentation.java rename to core/src/main/java/org/keycloak/representations/idm/ApplicationRepresentation.java index 6cf9de6a79..0e83bb658e 100755 --- a/core/src/main/java/org/keycloak/representations/idm/ResourceRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/ApplicationRepresentation.java @@ -1,15 +1,13 @@ package org.keycloak.representations.idm; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; /** * @author Bill Burke * @version $Revision: 1 $ */ -public class ResourceRepresentation { +public class ApplicationRepresentation { protected String self; // link protected String id; protected String name; @@ -70,14 +68,14 @@ public class ResourceRepresentation { this.roles = roles; } - public ResourceRepresentation role(RoleRepresentation role) { + public ApplicationRepresentation role(RoleRepresentation role) { if (this.roles == null) this.roles = new ArrayList(); this.roles.add(role); return this; } - public ResourceRepresentation role(String role, String description) { + public ApplicationRepresentation role(String role, String description) { if (this.roles == null) this.roles = new ArrayList(); this.roles.add(new RoleRepresentation(role, description)); return this; @@ -123,12 +121,11 @@ public class ResourceRepresentation { this.credentials = credentials; } - public ResourceRepresentation credential(String type, String value, boolean hashed) { + public ApplicationRepresentation credential(String type, String value) { if (this.credentials == null) credentials = new ArrayList(); CredentialRepresentation cred = new CredentialRepresentation(); cred.setType(type); cred.setValue(value); - cred.setHashed(hashed); credentials.add(cred); return this; } diff --git a/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java index 22593171e7..af9b292c47 100755 --- a/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java @@ -5,9 +5,13 @@ package org.keycloak.representations.idm; * @version $Revision: 1 $ */ public class CredentialRepresentation { + public static final String PASSWORD = "password"; + public static final String TOTP = "totp"; + public static final String CLIENT_CERT = "cert"; + protected String type; protected String value; - protected boolean hashed; + protected String device; public String getType() { return type; @@ -25,11 +29,11 @@ public class CredentialRepresentation { this.value = value; } - public boolean isHashed() { - return hashed; + public String getDevice() { + return device; } - public void setHashed(boolean hashed) { - this.hashed = hashed; + public void setDevice(String device) { + this.device = device; } } diff --git a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java index 896c1c9ab8..8ef7c4ac55 100755 --- a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java @@ -17,16 +17,18 @@ public class RealmRepresentation { protected boolean enabled; protected boolean sslNotRequired; protected boolean cookieLoginAllowed; + protected boolean registrationAllowed; + protected boolean social; protected String privateKey; protected String publicKey; protected List roles; - protected List requiredCredentials; - protected List requiredResourceCredentials; - protected List requiredOAuthClientCredentials; + protected Set requiredCredentials; + protected Set requiredApplicationCredentials; + protected Set requiredOAuthClientCredentials; protected List users; protected List roleMappings; protected List scopeMappings; - protected List resources; + protected List applications; public String getSelf() { @@ -57,14 +59,14 @@ public class RealmRepresentation { return users; } - public List getResources() { - return resources; + public List getApplications() { + return applications; } - public ResourceRepresentation resource(String name) { - ResourceRepresentation resource = new ResourceRepresentation(); - if (resources == null) resources = new ArrayList(); - resources.add(resource); + public ApplicationRepresentation resource(String name) { + ApplicationRepresentation resource = new ApplicationRepresentation(); + if (applications == null) applications = new ArrayList(); + applications.add(resource); resource.setName(name); return resource; } @@ -81,8 +83,8 @@ public class RealmRepresentation { return user; } - public void setResources(List resources) { - this.resources = resources; + public void setApplications(List applications) { + this.applications = applications; } public boolean isEnabled() { @@ -141,27 +143,27 @@ public class RealmRepresentation { return mapping; } - public List getRequiredCredentials() { + public Set getRequiredCredentials() { return requiredCredentials; } - public void setRequiredCredentials(List requiredCredentials) { + public void setRequiredCredentials(Set requiredCredentials) { this.requiredCredentials = requiredCredentials; } - public List getRequiredResourceCredentials() { - return requiredResourceCredentials; + public Set getRequiredApplicationCredentials() { + return requiredApplicationCredentials; } - public void setRequiredResourceCredentials(List requiredResourceCredentials) { - this.requiredResourceCredentials = requiredResourceCredentials; + public void setRequiredApplicationCredentials(Set requiredApplicationCredentials) { + this.requiredApplicationCredentials = requiredApplicationCredentials; } - public List getRequiredOAuthClientCredentials() { + public Set getRequiredOAuthClientCredentials() { return requiredOAuthClientCredentials; } - public void setRequiredOAuthClientCredentials(List requiredOAuthClientCredentials) { + public void setRequiredOAuthClientCredentials(Set requiredOAuthClientCredentials) { this.requiredOAuthClientCredentials = requiredOAuthClientCredentials; } @@ -196,4 +198,20 @@ public class RealmRepresentation { public void setPublicKey(String publicKey) { this.publicKey = publicKey; } + + public boolean isRegistrationAllowed() { + return registrationAllowed; + } + + public void setRegistrationAllowed(boolean registrationAllowed) { + this.registrationAllowed = registrationAllowed; + } + + public boolean isSocial() { + return social; + } + + public void setSocial(boolean social) { + this.social = social; + } } diff --git a/core/src/main/java/org/keycloak/representations/idm/RequiredCredentialRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RequiredCredentialRepresentation.java deleted file mode 100755 index 7a9eaecb13..0000000000 --- a/core/src/main/java/org/keycloak/representations/idm/RequiredCredentialRepresentation.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.keycloak.representations.idm; - -/** - * @author Bill Burke - * @version $Revision: 1 $ - */ -public class RequiredCredentialRepresentation { - public static final String PASSWORD = "Password"; - public static final String TOTP = "TOTP"; - public static final String CLIENT_CERT = "CLIENT_CERT"; - public static final String CALLER_PRINCIPAL = "CALLER_PRINCIPAL"; - protected String type; - protected boolean input; - protected boolean secret; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public boolean isInput() { - return input; - } - - public void setInput(boolean input) { - this.input = input; - } - - public boolean isSecret() { - return secret; - } - - public void setSecret(boolean secret) { - this.secret = secret; - } -} diff --git a/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java index cbbff891cb..2b3d02cf87 100755 --- a/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java @@ -14,6 +14,9 @@ public class UserRepresentation { protected String self; // link protected String username; protected boolean enabled; + protected String firstName; + protected String lastName; + protected String email; protected Map attributes; protected List credentials; @@ -25,6 +28,30 @@ public class UserRepresentation { this.self = self; } + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + public String getUsername() { return username; } @@ -55,12 +82,11 @@ public class UserRepresentation { this.credentials = credentials; } - public UserRepresentation credential(String type, String value, boolean hashed) { + public UserRepresentation credential(String type, String value) { if (this.credentials == null) credentials = new ArrayList(); CredentialRepresentation cred = new CredentialRepresentation(); cred.setType(type); cred.setValue(value); - cred.setHashed(hashed); credentials.add(cred); return this; } diff --git a/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java b/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java index eab7b1e78c..faf899e60b 100755 --- a/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java +++ b/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java @@ -1,6 +1,7 @@ package org.keycloak.example.demo; import org.jboss.resteasy.jwt.JsonSerialization; +import org.keycloak.representations.idm.CredentialRepresentation; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.KeycloakSession; @@ -40,7 +41,7 @@ public class DemoApplication extends KeycloakApplication { defaultRealm.setCookieLoginAllowed(true); defaultRealm.setRegistrationAllowed(true); manager.generateRealmKeys(defaultRealm); - defaultRealm.addRequiredCredential(RequiredCredentialModel.PASSWORD); + defaultRealm.addRequiredCredential(CredentialRepresentation.PASSWORD); defaultRealm.addRole(SaasService.REALM_CREATOR_ROLE); RealmRepresentation rep = loadJson("META-INF/testrealm.json"); diff --git a/examples/as7-eap-demo/server/src/main/resources/META-INF/persistence.xml b/examples/as7-eap-demo/server/src/main/resources/META-INF/persistence.xml index e0dc722aba..ad40046847 100755 --- a/examples/as7-eap-demo/server/src/main/resources/META-INF/persistence.xml +++ b/examples/as7-eap-demo/server/src/main/resources/META-INF/persistence.xml @@ -19,7 +19,7 @@ org.picketlink.idm.jpa.model.sample.simple.OTPCredentialTypeEntity org.picketlink.idm.jpa.model.sample.simple.AttributeTypeEntity org.keycloak.services.models.picketlink.mappings.RealmEntity - org.keycloak.services.models.picketlink.mappings.ResourceEntity + org.keycloak.services.models.picketlink.mappings.ApplicationEntity true diff --git a/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json b/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json index b333aab903..2fa8a91bab 100755 --- a/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json +++ b/examples/as7-eap-demo/server/src/main/resources/META-INF/testrealm.json @@ -1,94 +1,86 @@ { - "realm" : "demo", - "enabled" : true, - "tokenLifespan" : 10, - "accessCodeLifespan" : 10, - "sslNotRequired" : true, - "cookieLoginAllowed" : true, - "privateKey" : "MIICXAIBAAKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQABAoGAfmO8gVhyBxdqlxmIuglbz8bcjQbhXJLR2EoS8ngTXmN1bo2L90M0mUKSdc7qF10LgETBzqL8jYlQIbt+e6TH8fcEpKCjUlyq0Mf/vVbfZSNaVycY13nTzo27iPyWQHK5NLuJzn1xvxxrUeXI6A2WFpGEBLbHjwpx5WQG9A+2scECQQDvdn9NE75HPTVPxBqsEd2z10TKkl9CZxu10Qby3iQQmWLEJ9LNmy3acvKrE3gMiYNWb6xHPKiIqOR1as7L24aTAkEAtyvQOlCvr5kAjVqrEKXalj0Tzewjweuxc0pskvArTI2Oo070h65GpoIKLc9jf+UA69cRtquwP93aZKtW06U8dQJAF2Y44ks/mK5+eyDqik3koCI08qaC8HYq2wVl7G2QkJ6sbAaILtcvD92ToOvyGyeE0flvmDZxMYlvaZnaQ0lcSQJBAKZU6umJi3/xeEbkJqMfeLclD27XGEFoPeNrmdx0q10Azp4NfJAY+Z8KRyQCR2BEG+oNitBOZ+YXF9KCpH3cdmECQHEigJhYg+ykOvr1aiZUMFT72HU0jnmQe2FVekuG+LJUt2Tm7GtMjTFoGpf0JwrVuZN39fOYAlo+nTixgeW7X8Y=", - "publicKey" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB", - "requiredCredentials" : [ + "realm": "demo", + "enabled": true, + "tokenLifespan": 300, + "accessCodeLifespan": 10, + "sslNotRequired": true, + "cookieLoginAllowed": true, + "privateKey": "MIICXAIBAAKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQABAoGAfmO8gVhyBxdqlxmIuglbz8bcjQbhXJLR2EoS8ngTXmN1bo2L90M0mUKSdc7qF10LgETBzqL8jYlQIbt+e6TH8fcEpKCjUlyq0Mf/vVbfZSNaVycY13nTzo27iPyWQHK5NLuJzn1xvxxrUeXI6A2WFpGEBLbHjwpx5WQG9A+2scECQQDvdn9NE75HPTVPxBqsEd2z10TKkl9CZxu10Qby3iQQmWLEJ9LNmy3acvKrE3gMiYNWb6xHPKiIqOR1as7L24aTAkEAtyvQOlCvr5kAjVqrEKXalj0Tzewjweuxc0pskvArTI2Oo070h65GpoIKLc9jf+UA69cRtquwP93aZKtW06U8dQJAF2Y44ks/mK5+eyDqik3koCI08qaC8HYq2wVl7G2QkJ6sbAaILtcvD92ToOvyGyeE0flvmDZxMYlvaZnaQ0lcSQJBAKZU6umJi3/xeEbkJqMfeLclD27XGEFoPeNrmdx0q10Azp4NfJAY+Z8KRyQCR2BEG+oNitBOZ+YXF9KCpH3cdmECQHEigJhYg+ykOvr1aiZUMFT72HU0jnmQe2FVekuG+LJUt2Tm7GtMjTFoGpf0JwrVuZN39fOYAlo+nTixgeW7X8Y=", + "publicKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB", + "requiredCredentials": [ "password" ], + "requiredApplicationCredentials": [ "password" ], + "requiredOAuthClientCredentials": [ "password" ], + "users" : [ { - "type" : "Password", - "input" : true, - "secret" : true - } - ], - "requiredResourceCredentials" : [ - { - "type" : "Password", - "input" : true, - "secret" : true - } - ], - "requiredOAuthClientCredentials" : [ - { - "type" : "Password", - "input" : true, - "secret" : true - } - ], - "users" : [ - { "username" : "bburke@redhat.com", "enabled" : true, "attributes" : { "email" : "bburke@redhat.com" }, "credentials" : [ - { "type" : "Password", - "value" : "password" } + { "type" : "password", + "value" : "password" } ] - }, - { + }, + { "username" : "third-party", "enabled" : true, "credentials" : [ - { "type" : "Password", - "value" : "password" } + { "type" : "password", + "value" : "password" } ] - } - ], - "roles" : [ - { "name" : "user", "description" : "Have User privileges" }, - { "name" : "admin", "description" : "Have Administrator privileges" } - ], - "roleMappings" : [ - { - "username" : "bburke@redhat.com", - "roles" : ["user"] - }, - { - "username" : "third-party", - "roles" : ["KEYCLOAK_IDENTITY_REQUESTER"] - } - ], - "scopeMappings" : [ - { - "username" : "third-party", - "roles" : ["user"] - } - ], - "resources" : [ - { - "name" : "customer-portal", - "enabled" : true, - "adminUrl" : "http://localhost:8080/customer-portal/j_admin_request", - "useRealmMappings" : true, - "credentials" : [ - { "type" : "Password", - "value" : "password" } - ] - }, - { - "name" : "product-portal", - "enabled" : true, - "adminUrl" : "http://localhost:8080/product-portal/j_admin_request", - "useRealmMappings" : true, - "credentials" : [ - { "type" : "Password", - "value" : "password" } - ] - } - ] + } + ], + "roles": [ + { + "name": "user", + "description": "Have User privileges" + }, + { + "name": "admin", + "description": "Have Administrator privileges" + } + ], + "roleMappings": [ + { + "username": "bburke@redhat.com", + "roles": ["user"] + }, + { + "username": "third-party", + "roles": ["KEYCLOAK_IDENTITY_REQUESTER"] + } + ], + "scopeMappings": [ + { + "username": "third-party", + "roles": ["user"] + } + ], + "applications": [ + { + "name": "customer-portal", + "enabled": true, + "adminUrl": "http://localhost:8080/customer-portal/j_admin_request", + "useRealmMappings": true, + "credentials": [ + { + "type": "password", + "value": "password" + } + ] + }, + { + "name": "product-portal", + "enabled": true, + "adminUrl": "http://localhost:8080/product-portal/j_admin_request", + "useRealmMappings": true, + "credentials": [ + { + "type": "password", + "value": "password" + } + ] + } + ] } \ No newline at end of file diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/index.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/index.html index d792b3013e..ad1a87e78f 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/index.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/index.html @@ -15,13 +15,20 @@ + + + + + + + @@ -57,9 +64,6 @@ - - -