Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd499e1
commit 91a267a
Showing
92 changed files
with
2,080 additions
and
1,027 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
core/src/main/java/org/keycloak/representations/idm/ComponentRepresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,101 @@ | |||
/* | |||
* Copyright 2016 Red Hat, Inc. and/or its affiliates | |||
* and other contributors as indicated by the @author tags. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.keycloak.representations.idm; | |||
|
|||
import org.keycloak.common.util.MultivaluedHashMap; | |||
|
|||
import java.util.List; | |||
import java.util.Map; | |||
|
|||
/** | |||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | |||
*/ | |||
public class ComponentRepresentation { | |||
|
|||
private String id; | |||
private String name; | |||
private String providerId; | |||
private String providerType; | |||
private String parentId; | |||
private MultivaluedHashMap<String, String> config; | |||
|
|||
public String getId() { | |||
return id; | |||
} | |||
|
|||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
|
|||
public String getName() { | |||
return name; | |||
} | |||
|
|||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
|
|||
public String getProviderId() { | |||
return providerId; | |||
} | |||
|
|||
public void setProviderId(String providerId) { | |||
this.providerId = providerId; | |||
} | |||
|
|||
public String getProviderType() { | |||
return providerType; | |||
} | |||
|
|||
public void setProviderType(String providerType) { | |||
this.providerType = providerType; | |||
} | |||
|
|||
public String getParentId() { | |||
return parentId; | |||
} | |||
|
|||
public void setParentId(String parentId) { | |||
this.parentId = parentId; | |||
} | |||
|
|||
public MultivaluedHashMap<String, String> getConfig() { | |||
return config; | |||
} | |||
|
|||
public void setConfig(MultivaluedHashMap<String, String> config) { | |||
this.config = config; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) return true; | |||
if (o == null || getClass() != o.getClass()) return false; | |||
|
|||
ComponentRepresentation that = (ComponentRepresentation) o; | |||
|
|||
if (!id.equals(that.id)) return false; | |||
|
|||
return true; | |||
} | |||
|
|||
@Override | |||
public int hashCode() { | |||
return id.hashCode(); | |||
} | |||
} |
57 changes: 57 additions & 0 deletions
57
core/src/main/java/org/keycloak/representations/idm/ComponentTypeRepresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
/* | |||
* Copyright 2016 Red Hat, Inc. and/or its affiliates | |||
* and other contributors as indicated by the @author tags. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.keycloak.representations.idm; | |||
|
|||
import java.util.HashMap; | |||
import java.util.LinkedList; | |||
import java.util.List; | |||
import java.util.Map; | |||
|
|||
/** | |||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | |||
*/ | |||
public class ComponentTypeRepresentation { | |||
protected String id; | |||
protected String helpText; | |||
protected List<ConfigPropertyRepresentation> properties; | |||
|
|||
|
|||
public String getId() { | |||
return id; | |||
} | |||
|
|||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
|
|||
public String getHelpText() { | |||
return helpText; | |||
} | |||
|
|||
public void setHelpText(String helpText) { | |||
this.helpText = helpText; | |||
} | |||
|
|||
public List<ConfigPropertyRepresentation> getProperties() { | |||
return properties; | |||
} | |||
|
|||
public void setProperties(List<ConfigPropertyRepresentation> properties) { | |||
this.properties = properties; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...rage-jpa/src/main/java/org/keycloak/examples/storage/user/ExampleUserStorageProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,118 @@ | |||
/* | |||
* Copyright 2016 Red Hat, Inc. and/or its affiliates | |||
* and other contributors as indicated by the @author tags. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
package org.keycloak.examples.storage.user; | |||
|
|||
import org.keycloak.component.ComponentModel; | |||
import org.keycloak.models.GroupModel; | |||
import org.keycloak.models.KeycloakSession; | |||
import org.keycloak.models.RealmModel; | |||
import org.keycloak.models.RoleModel; | |||
import org.keycloak.models.UserModel; | |||
import org.keycloak.models.utils.KeycloakModelUtils; | |||
import org.keycloak.storage.StorageId; | |||
import org.keycloak.storage.UserStorageProvider; | |||
import org.keycloak.storage.user.UserLookupProvider; | |||
import org.keycloak.storage.user.UserRegistrationProvider; | |||
|
|||
import javax.persistence.EntityManager; | |||
import javax.persistence.TypedQuery; | |||
import java.util.List; | |||
|
|||
/** | |||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | |||
* @version $Revision: 1 $ | |||
*/ | |||
public class ExampleUserStorageProvider implements UserStorageProvider, UserLookupProvider, UserRegistrationProvider { | |||
protected EntityManager em; | |||
protected ComponentModel model; | |||
protected KeycloakSession session; | |||
|
|||
public ExampleUserStorageProvider(EntityManager em, ComponentModel model, KeycloakSession session) { | |||
this.em = em; | |||
this.model = model; | |||
this.session = session; | |||
} | |||
|
|||
@Override | |||
public void preRemove(RealmModel realm) { | |||
|
|||
} | |||
|
|||
@Override | |||
public void preRemove(RealmModel realm, GroupModel group) { | |||
|
|||
} | |||
|
|||
@Override | |||
public void preRemove(RealmModel realm, RoleModel role) { | |||
|
|||
} | |||
|
|||
@Override | |||
public void close() { | |||
em.close(); | |||
} | |||
|
|||
@Override | |||
public UserModel getUserById(String id, RealmModel realm) { | |||
String persistenceId = StorageId.externalId(id); | |||
UserEntity entity = em.find(UserEntity.class, persistenceId); | |||
if (entity == null) return null; | |||
return new UserAdapter(session, realm, model, entity); | |||
} | |||
|
|||
@Override | |||
public UserModel getUserByUsername(String username, RealmModel realm) { | |||
TypedQuery<UserEntity> query = em.createNamedQuery("getUserByUsername", UserEntity.class); | |||
query.setParameter("username", username); | |||
List<UserEntity> result = query.getResultList(); | |||
if (result.isEmpty()) return null; | |||
return new UserAdapter(session, realm, model, result.get(0)); | |||
} | |||
|
|||
@Override | |||
public UserModel getUserByEmail(String email, RealmModel realm) { | |||
TypedQuery<UserEntity> query = em.createNamedQuery("getUserByEmail", UserEntity.class); | |||
query.setParameter("email", email); | |||
List<UserEntity> result = query.getResultList(); | |||
if (result.isEmpty()) return null; | |||
return new UserAdapter(session, realm, model, result.get(0)); | |||
} | |||
|
|||
@Override | |||
public UserModel addUser(RealmModel realm, String username) { | |||
UserEntity entity = new UserEntity(); | |||
entity.setId(KeycloakModelUtils.generateId()); | |||
entity.setUsername(username); | |||
em.persist(entity); | |||
return new UserAdapter(session, realm, model, entity); | |||
} | |||
|
|||
@Override | |||
public boolean removeUser(RealmModel realm, UserModel user) { | |||
String persistenceId = StorageId.externalId(user.getId()); | |||
UserEntity entity = em.find(UserEntity.class, persistenceId); | |||
if (entity == null) return false; | |||
em.remove(entity); | |||
return true; | |||
} | |||
|
|||
@Override | |||
public void grantToAllUsers(RealmModel realm, RoleModel role) { | |||
|
|||
} | |||
} |
Oops, something went wrong.