Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions core/src/main/java/org/keycloak/RealmConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public class RealmConfiguration {
protected ResteasyClient client;
protected UriBuilder authUrl;
protected ResteasyWebTarget codeUrl;
protected String clientId;
protected Form credentials = new Form();
protected Form resourceCredentials = new Form();
protected boolean sslRequired = true;
protected String stateCookieName = "OAuth_Token_Request_State";

Expand Down Expand Up @@ -44,16 +43,8 @@ public void setAuthUrl(UriBuilder authUrl) {
this.authUrl = authUrl;
}

public String getClientId() {
return clientId;
}

public void setClientId(String clientId) {
this.clientId = clientId;
}

public Form getCredentials() {
return credentials;
public Form getResourceCredentials() {
return resourceCredentials;
}

public ResteasyWebTarget getCodeUrl() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/keycloak/ResourceMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* @version $Revision: 1 $
*/
public class ResourceMetadata {
protected String resourceName;
protected String realm;
protected String resourceName;
protected KeyStore clientKeystore;
protected String clientKeyPassword;
protected KeyStore truststore;
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/org/keycloak/TokenIdGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.keycloak;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class TokenIdGenerator {
private static final AtomicLong counter = new AtomicLong();
public static String generateId() {
return UUID.randomUUID().toString() + "-" + System.currentTimeMillis();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.keycloak.representations.idm;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class CredentialRepresentation {
protected String type;
protected String value;
protected boolean hashed;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public boolean isHashed() {
return hashed;
}

public void setHashed(boolean hashed) {
this.hashed = hashed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
public class ResourceRepresentation {
protected String self; // link
protected String name;
protected String adminUrl;
protected boolean surrogateAuthRequired;
protected boolean useRealmMappings;
protected List<CredentialRepresentation> credentials;
protected Set<String> roles;
protected List<RoleMappingRepresentation> roleMappings;
protected List<ScopeMappingRepresentation> scopeMappings;
Expand Down Expand Up @@ -79,5 +82,37 @@ public ScopeMappingRepresentation scopeMapping(String username) {
return mapping;
}

public String getAdminUrl() {
return adminUrl;
}

public void setAdminUrl(String adminUrl) {
this.adminUrl = adminUrl;
}

public List<CredentialRepresentation> getCredentials() {
return credentials;
}

public void setCredentials(List<CredentialRepresentation> credentials) {
this.credentials = credentials;
}

public ResourceRepresentation credential(String type, String value, boolean hashed) {
if (this.credentials == null) credentials = new ArrayList<CredentialRepresentation>();
CredentialRepresentation cred = new CredentialRepresentation();
cred.setType(type);
cred.setValue(value);
cred.setHashed(hashed);
credentials.add(cred);
return this;
}

public boolean isUseRealmMappings() {
return useRealmMappings;
}

public void setUseRealmMappings(boolean useRealmMappings) {
this.useRealmMappings = useRealmMappings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,12 @@
* @version $Revision: 1 $
*/
public class UserRepresentation {
public static class Credential {
protected String type;
protected String value;
protected boolean hashed;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public boolean isHashed() {
return hashed;
}

public void setHashed(boolean hashed) {
this.hashed = hashed;
}
}

protected String self; // link
protected String username;
protected boolean enabled;
protected Map<String, String> attributes;
protected List<Credential> credentials;
protected List<CredentialRepresentation> credentials;

public String getSelf() {
return self;
Expand All @@ -70,23 +41,23 @@ public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}

public List<Credential> getCredentials() {
return credentials;
}

public void setCredentials(List<Credential> credentials) {
this.credentials = credentials;
}

public UserRepresentation attribute(String name, String value) {
if (this.attributes == null) attributes = new HashMap<String, String>();
attributes.put(name, value);
return this;
}

public List<CredentialRepresentation> getCredentials() {
return credentials;
}

public void setCredentials(List<CredentialRepresentation> credentials) {
this.credentials = credentials;
}

public UserRepresentation credential(String type, String value, boolean hashed) {
if (this.credentials == null) credentials = new ArrayList<Credential>();
Credential cred = new Credential();
if (this.credentials == null) credentials = new ArrayList<CredentialRepresentation>();
CredentialRepresentation cred = new CredentialRepresentation();
cred.setType(type);
cred.setValue(value);
cred.setHashed(hashed);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.keycloak.representations.idm.admin;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

/**
* Posted to managed client from admin server.
*
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class AdminAction {
protected String id;
protected long expiration;
protected String resource;
protected String action;

public AdminAction() {
}

public AdminAction(String id, long expiration, String resource, String action) {
this.id = id;
this.expiration = expiration;
this.resource = resource;
this.action = action;
}

public String getId() {
return id;
}

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

public String getAction() {
return action;
}

public void setAction(String action) {
this.action = action;
}

@JsonIgnore
public boolean isExpired()
{
long time = System.currentTimeMillis() / 1000;
return time > expiration;
}

public long getExpiration() {
return expiration;
}

public void setExpiration(long expiration) {
this.expiration = expiration;
}

public String getResource() {
return resource;
}

public void setResource(String resource) {
this.resource = resource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.keycloak.representations.idm.admin;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class LogoutAction extends AdminAction {
public static final String LOGOUT_ACTION = "logout";
protected String user;

public LogoutAction() {
}

public LogoutAction(String id, long expiration, String resource, String user) {
super(id, expiration, resource, LOGOUT_ACTION);
this.user = user;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"realm" : "demo",
"resource" : "customer-portal",
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/login",
"code-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/access/codes",
"ssl-not-required" : true,
"client-id" : "customer-portal",
"client-credentials" : {
"credentials" : {
"password" : "password"
}
}
8 changes: 6 additions & 2 deletions examples/as7-eap-demo/customer-app/src/main/webapp/customers/view.jsp
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ page import="javax.ws.rs.core.*" language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Customer View Page</title>
</head>
<body bgcolor="#E3F6CE">
<p>Goto: <a href="https://localhost:8443/product-portal">products</a> | <a href="https://localhost:8443/auth-server/j_oauth_logout">logout</a></p>
<%
String logoutUri = UriBuilder.fromUri("http://localhost:8080/auth-server/rest/realms/demo/tokens/logout")
.queryParam("redirect_uri", "http://localhost:8080/customer-portal").build().toString();
%>
<p>Goto: <a href="http://localhost:8080/product-portal">products</a> | <a href="<%=logoutUri%>">logout</a></p>
User <b><%=request.getUserPrincipal().getName()%></b> made this request.
<h2>Customer Listing</h2>
<%
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"realm" : "demo",
"resource" : "database-service",
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB"
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"realm" : "demo",
"resource" : "product-portal",
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/login",
"code-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/access/codes",
"ssl-not-required" : true,
"client-id" : "product-portal",
"client-credentials" : {
"credentials" : {
"password" : "password"
}
}
9 changes: 7 additions & 2 deletions examples/as7-eap-demo/product-app/src/main/webapp/products/view.jsp
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ page import="javax.ws.rs.core.*" language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Product View Page</title>
</head>
<body bgcolor="#F5F6CE">
<p>Goto: <a href="https://localhost:8443/customer-portal">customers</a> | <a href="https://localhost:8443/auth-server/j_oauth_logout">logout</a></p>
<%
String logoutUri = UriBuilder.fromUri("http://localhost:8080/auth-server/rest/realms/demo/tokens/logout")
.queryParam("redirect_uri", "http://localhost:8080/product-portal").build().toString();
%>

<p>Goto: <a href="http://localhost:8080/customer-portal">customers</a> | <a href="<%=logoutUri%>">logout</a></p>
User <b><%=request.getUserPrincipal().getName()%></b> made this request.
<h2>Product Listing</h2>
<%
Expand Down
Loading