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
Showing
24 changed files
with
936 additions
and
11 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
...providers/src/main/java/org/keycloak/testsuite/domainextension/CompanyRepresentation.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,51 @@ | |||
/* | |||
* 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.testsuite.domainextension; | |||
|
|||
|
|||
import org.keycloak.testsuite.domainextension.jpa.Company; | |||
|
|||
public class CompanyRepresentation { | |||
|
|||
private String id; | |||
private String name; | |||
|
|||
public CompanyRepresentation() { | |||
} | |||
|
|||
public CompanyRepresentation(Company company) { | |||
id = company.getId(); | |||
name = company.getName(); | |||
} | |||
|
|||
public String getId() { | |||
return id; | |||
} | |||
|
|||
public String getName() { | |||
return name; | |||
} | |||
|
|||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
|
|||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
} |
66 changes: 66 additions & 0 deletions
66
...testsuite-providers/src/main/java/org/keycloak/testsuite/domainextension/jpa/Company.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,66 @@ | |||
/* | |||
* 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.testsuite.domainextension.jpa; | |||
|
|||
|
|||
import javax.persistence.Column; | |||
import javax.persistence.Entity; | |||
import javax.persistence.Id; | |||
import javax.persistence.NamedQueries; | |||
import javax.persistence.NamedQuery; | |||
import javax.persistence.Table; | |||
|
|||
@Entity | |||
@Table(name = "EXAMPLE_COMPANY") | |||
@NamedQueries({ @NamedQuery(name = "findByRealm", query = "from Company where realmId = :realmId") }) | |||
public class Company { | |||
|
|||
@Id | |||
@Column(name = "ID") | |||
private String id; | |||
|
|||
@Column(name = "NAME", nullable = false) | |||
private String name; | |||
|
|||
@Column(name = "REALM_ID", nullable = false) | |||
private String realmId; | |||
|
|||
public String getId() { | |||
return id; | |||
} | |||
|
|||
public String getRealmId() { | |||
return realmId; | |||
} | |||
|
|||
public String getName() { | |||
return name; | |||
} | |||
|
|||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
|
|||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
|
|||
public void setRealmId(String realmId) { | |||
this.realmId = realmId; | |||
} | |||
} |
50 changes: 50 additions & 0 deletions
50
...rs/src/main/java/org/keycloak/testsuite/domainextension/jpa/ExampleJpaEntityProvider.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,50 @@ | |||
/* | |||
* 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.testsuite.domainextension.jpa; | |||
|
|||
import java.util.Collections; | |||
import java.util.List; | |||
|
|||
import org.keycloak.connections.jpa.entityprovider.JpaEntityProvider; | |||
|
|||
/** | |||
* @author <a href="mailto:erik.mulder@docdatapayments.com">Erik Mulder</a> | |||
* | |||
* Example JpaEntityProvider. | |||
*/ | |||
public class ExampleJpaEntityProvider implements JpaEntityProvider { | |||
|
|||
@Override | |||
public List<Class<?>> getEntities() { | |||
return Collections.<Class<?>>singletonList(Company.class); | |||
} | |||
|
|||
@Override | |||
public String getChangelogLocation() { | |||
return "META-INF/example-changelog.xml"; | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
} | |||
|
|||
@Override | |||
public String getFactoryId() { | |||
return ExampleJpaEntityProviderFactory.ID; | |||
} | |||
} |
57 changes: 57 additions & 0 deletions
57
...main/java/org/keycloak/testsuite/domainextension/jpa/ExampleJpaEntityProviderFactory.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.testsuite.domainextension.jpa; | |||
|
|||
import org.keycloak.Config.Scope; | |||
import org.keycloak.connections.jpa.entityprovider.JpaEntityProvider; | |||
import org.keycloak.connections.jpa.entityprovider.JpaEntityProviderFactory; | |||
import org.keycloak.models.KeycloakSession; | |||
import org.keycloak.models.KeycloakSessionFactory; | |||
|
|||
/** | |||
* @author <a href="mailto:erik.mulder@docdatapayments.com">Erik Mulder</a> | |||
* | |||
* Example JpaEntityProviderFactory. | |||
*/ | |||
public class ExampleJpaEntityProviderFactory implements JpaEntityProviderFactory { | |||
|
|||
protected static final String ID = "example-entity-provider"; | |||
|
|||
@Override | |||
public JpaEntityProvider create(KeycloakSession session) { | |||
return new ExampleJpaEntityProvider(); | |||
} | |||
|
|||
@Override | |||
public String getId() { | |||
return ID; | |||
} | |||
|
|||
@Override | |||
public void init(Scope config) { | |||
} | |||
|
|||
@Override | |||
public void postInit(KeycloakSessionFactory factory) { | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
} | |||
|
|||
} |
77 changes: 77 additions & 0 deletions
77
...-providers/src/main/java/org/keycloak/testsuite/domainextension/rest/CompanyResource.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,77 @@ | |||
/* | |||
* 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.testsuite.domainextension.rest; | |||
|
|||
import java.util.List; | |||
|
|||
import javax.ws.rs.Consumes; | |||
import javax.ws.rs.DELETE; | |||
import javax.ws.rs.GET; | |||
import javax.ws.rs.POST; | |||
import javax.ws.rs.Path; | |||
import javax.ws.rs.PathParam; | |||
import javax.ws.rs.Produces; | |||
import javax.ws.rs.core.MediaType; | |||
import javax.ws.rs.core.Response; | |||
|
|||
import org.jboss.resteasy.annotations.cache.NoCache; | |||
import org.keycloak.models.KeycloakSession; | |||
import org.keycloak.testsuite.domainextension.CompanyRepresentation; | |||
import org.keycloak.testsuite.domainextension.spi.ExampleService; | |||
|
|||
public class CompanyResource { | |||
|
|||
private final KeycloakSession session; | |||
|
|||
public CompanyResource(KeycloakSession session) { | |||
this.session = session; | |||
} | |||
|
|||
@GET | |||
@Path("") | |||
@NoCache | |||
@Produces(MediaType.APPLICATION_JSON) | |||
public List<CompanyRepresentation> getCompanies() { | |||
return session.getProvider(ExampleService.class).listCompanies(); | |||
} | |||
|
|||
@DELETE | |||
@Path("") | |||
@NoCache | |||
public void deleteAllCompanies() { | |||
session.getProvider(ExampleService.class).deleteAllCompanies(); | |||
} | |||
|
|||
@POST | |||
@Path("") | |||
@NoCache | |||
@Consumes(MediaType.APPLICATION_JSON) | |||
public Response createCompany(CompanyRepresentation rep) { | |||
session.getProvider(ExampleService.class).addCompany(rep); | |||
return Response.created(session.getContext().getUri().getAbsolutePathBuilder().path(rep.getId()).build()).build(); | |||
} | |||
|
|||
@GET | |||
@NoCache | |||
@Path("{id}") | |||
@Produces(MediaType.APPLICATION_JSON) | |||
public CompanyRepresentation getCompany(@PathParam("id") final String id) { | |||
return session.getProvider(ExampleService.class).findCompany(id); | |||
} | |||
|
|||
} |
40 changes: 40 additions & 0 deletions
40
...c/main/java/org/keycloak/testsuite/domainextension/rest/ExampleRealmResourceProvider.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,40 @@ | |||
/* | |||
* 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.testsuite.domainextension.rest; | |||
|
|||
import org.keycloak.models.KeycloakSession; | |||
import org.keycloak.services.resource.RealmResourceProvider; | |||
|
|||
public class ExampleRealmResourceProvider implements RealmResourceProvider { | |||
|
|||
private KeycloakSession session; | |||
|
|||
public ExampleRealmResourceProvider(KeycloakSession session) { | |||
this.session = session; | |||
} | |||
|
|||
@Override | |||
public Object getResource() { | |||
return new ExampleRestResource(session); | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
} | |||
|
|||
} |
Oops, something went wrong.