Renamed packages from com.nubisware.* to org.gcube.*
This commit is contained in:
parent
a1921e4486
commit
1a1bae3d0d
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak;
|
||||
package org.gcube.oidc.keycloak;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak;
|
||||
package org.gcube.oidc.keycloak;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -169,6 +169,40 @@ public class KeycloakHelper {
|
|||
return realm.clients().get(realm.clients().findByClientId(encodedClientId).get(0).getId());
|
||||
}
|
||||
|
||||
|
||||
public ClientResource addPublicClient(RealmResource realm, String clientId, String name, String description,
|
||||
String rootUrl, String loginTheme) throws KeycloakResourceCreationException, UnsupportedEncodingException {
|
||||
|
||||
// Encoding clientId to be sure blocking chars are not used
|
||||
String encodedClientId = URLEncoder.encode(clientId, "UTF-8");
|
||||
if (realm.clients().findByClientId(encodedClientId).size() > 0) {
|
||||
throw new KeycloakResourceCreationException("Client with same clientId already exists: " + encodedClientId, null);
|
||||
}
|
||||
ClientRepresentation newClientRepresentation = new ClientRepresentation();
|
||||
newClientRepresentation.setClientId(encodedClientId);
|
||||
newClientRepresentation.setName(name);
|
||||
newClientRepresentation.setDescription(description);
|
||||
if (rootUrl != null) {
|
||||
newClientRepresentation.setRootUrl(rootUrl);
|
||||
}
|
||||
newClientRepresentation.setEnabled(true);
|
||||
newClientRepresentation.setServiceAccountsEnabled(true);
|
||||
newClientRepresentation.setStandardFlowEnabled(true);
|
||||
newClientRepresentation.setAuthorizationServicesEnabled(true);
|
||||
newClientRepresentation.setPublicClient(true);
|
||||
newClientRepresentation.setProtocol("openid-connect");
|
||||
if (loginTheme != null) {
|
||||
newClientRepresentation.getAttributes().put("login_theme", loginTheme);
|
||||
}
|
||||
newClientRepresentation.setAuthorizationSettings(new ResourceServerRepresentation());
|
||||
try (Response response = realm.clients().create(newClientRepresentation)) {
|
||||
if (!response.getStatusInfo().equals(Response.Status.CREATED)) {
|
||||
throw new KeycloakResourceCreationException("While creating new public client: " + clientId, response);
|
||||
}
|
||||
}
|
||||
return realm.clients().get(realm.clients().findByClientId(encodedClientId).get(0).getId());
|
||||
}
|
||||
|
||||
public ClientResource findClient(RealmResource realm, String clientId) throws UnsupportedEncodingException {
|
||||
String encodedClientId = URLEncoder.encode(clientId, "UTF-8");
|
||||
List<ClientRepresentation> clientsFound = realm.clients().findByClientId(encodedClientId);
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak;
|
||||
package org.gcube.oidc.keycloak;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.StatusType;
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak.gcube;
|
||||
package org.gcube.oidc.keycloak.d4science;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -14,6 +14,10 @@ import java.util.Set;
|
|||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.gcube.oidc.D4ScienceMappings.Role;
|
||||
import org.gcube.oidc.D4ScienceMappings.Scope;
|
||||
import org.gcube.oidc.keycloak.KeycloakHelper;
|
||||
import org.gcube.oidc.keycloak.KeycloakResourceCreationException;
|
||||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.admin.client.resource.PolicyResource;
|
||||
|
@ -27,11 +31,6 @@ import org.keycloak.representations.idm.authorization.ResourceRepresentation;
|
|||
import org.keycloak.representations.idm.authorization.ScopeRepresentation;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.nubisware.oidc.gcube.D4ScienceMappings.Role;
|
||||
import com.nubisware.oidc.gcube.D4ScienceMappings.Scope;
|
||||
import com.nubisware.oidc.keycloak.KeycloakHelper;
|
||||
import com.nubisware.oidc.keycloak.KeycloakResourceCreationException;
|
||||
|
||||
public class ClientsCreatorFromExport {
|
||||
|
||||
private KeycloakHelper kh;
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak.gcube;
|
||||
package org.gcube.oidc.keycloak.d4science;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak;
|
||||
package org.gcube.oidc.keycloak;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -11,6 +11,8 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.oidc.keycloak.KeycloakHelper;
|
||||
import org.gcube.oidc.keycloak.KeycloakResourceCreationException;
|
||||
import org.keycloak.admin.client.Keycloak;
|
||||
import org.keycloak.admin.client.resource.ClientResource;
|
||||
import org.keycloak.admin.client.resource.PolicyResource;
|
||||
|
@ -22,9 +24,6 @@ import org.keycloak.representations.idm.authorization.DecisionStrategy;
|
|||
import org.keycloak.representations.idm.authorization.Logic;
|
||||
import org.keycloak.representations.idm.authorization.ScopeRepresentation;
|
||||
|
||||
import com.nubisware.oidc.keycloak.KeycloakHelper;
|
||||
import com.nubisware.oidc.keycloak.KeycloakResourceCreationException;
|
||||
|
||||
public class UglyKeycloakHelperTest {
|
||||
|
||||
static String clientPrefix = "client";
|
|
@ -1,4 +1,4 @@
|
|||
package com.nubisware.oidc.keycloak.gcube;
|
||||
package org.gcube.oidc.keycloak.d4science;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.gcube.oidc.keycloak.d4science.ExportParser;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class ExportParserTest {
|
Loading…
Reference in New Issue