use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class AccountBrokerTest method displayEnabledIdentityProviders.
@Test
public void displayEnabledIdentityProviders() {
identityPage.realm(KcOidcBrokerConfiguration.INSTANCE.consumerRealmName());
identityPage.open();
loginPage.login("accountbrokertest", "password");
Assert.assertTrue(identityPage.isCurrent());
List<AccountFederatedIdentityPage.FederatedIdentity> identities = identityPage.getIdentities();
Assert.assertEquals(1, identities.size());
// Disable the identity provider
RealmResource realm = adminClient.realm(bc.consumerRealmName());
IdentityProviderResource providerResource = realm.identityProviders().get(bc.getIDPAlias());
IdentityProviderRepresentation provider = providerResource.toRepresentation();
provider.setEnabled(false);
providerResource.update(provider);
// Reload federated identities page
identityPage.open();
Assert.assertTrue(identityPage.isCurrent());
identities = identityPage.getIdentities();
Assert.assertEquals(0, identities.size());
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class AbstractUiTest method createIdentityProviderRepresentation.
protected IdentityProviderRepresentation createIdentityProviderRepresentation(String alias, String providerId) {
IdentityProviderRepresentation idpRep = new IdentityProviderRepresentation();
idpRep.setProviderId(providerId);
idpRep.setAlias(alias);
idpRep.setConfig(new HashMap<>());
return idpRep;
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class LinkedAccountsTest method addTestRealms.
@Override
public void addTestRealms(List<RealmRepresentation> testRealms) {
super.addTestRealms(testRealms);
RealmRepresentation realm1 = testRealms.get(0);
realm1.addIdentityProvider(createIdentityProviderRepresentation(SOCIAL_IDP_ALIAS, GoogleIdentityProviderFactory.PROVIDER_ID));
String oidcRoot = getAuthServerRoot() + "realms/" + REALM2_NAME + "/protocol/openid-connect/";
IdentityProviderRepresentation systemIdp = createIdentityProviderRepresentation(SYSTEM_IDP_ALIAS, OIDCIdentityProviderFactory.PROVIDER_ID);
systemIdp.getConfig().put("clientId", CLIENT_ID);
systemIdp.getConfig().put("clientSecret", CLIENT_SECRET);
systemIdp.getConfig().put("clientAuthMethod", OIDCLoginProtocol.CLIENT_SECRET_POST);
systemIdp.getConfig().put("authorizationUrl", oidcRoot + "auth");
systemIdp.getConfig().put("tokenUrl", oidcRoot + "token");
realm1.addIdentityProvider(systemIdp);
ClientRepresentation client = ClientBuilder.create().clientId(CLIENT_ID).secret(CLIENT_SECRET).redirectUris(getAuthServerRoot() + "realms/" + TEST + "/broker/" + SYSTEM_IDP_ALIAS + "/endpoint").build();
// using REALM2 as an identity provider
RealmRepresentation realm2 = new RealmRepresentation();
realm2.setId(REALM2_NAME);
realm2.setRealm(REALM2_NAME);
realm2.setEnabled(true);
realm2.setClients(Collections.singletonList(client));
realm2.setUsers(Collections.singletonList(homerUser));
testRealms.add(realm2);
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class IdentityProviderResource method getIdentityProvider.
/**
* Get the identity provider
*
* @return
*/
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public IdentityProviderRepresentation getIdentityProvider() {
this.auth.realm().requireViewIdentityProviders();
if (identityProviderModel == null) {
throw new javax.ws.rs.NotFoundException();
}
IdentityProviderRepresentation rep = ModelToRepresentation.toRepresentation(realm, this.identityProviderModel);
return StripSecretsUtils.strip(rep);
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class IdentityProviderTest method testSamlExportSignatureOn.
@Test
public void testSamlExportSignatureOn() throws URISyntaxException, IOException, ConfigurationException, ParsingException, ProcessingException {
// Use import-config to convert IDPSSODescriptor file into key value pairs
// to use when creating a SAML Identity Provider
MultipartFormDataOutput form = new MultipartFormDataOutput();
form.addFormData("providerId", "saml", MediaType.TEXT_PLAIN_TYPE);
URL idpMeta = getClass().getClassLoader().getResource("admin-test/saml-idp-metadata.xml");
byte[] content = Files.readAllBytes(Paths.get(idpMeta.toURI()));
String body = new String(content, Charset.forName("utf-8"));
form.addFormData("file", body, MediaType.APPLICATION_XML_TYPE, "saml-idp-metadata.xml");
Map<String, String> result = realm.identityProviders().importFrom(form);
// Explicitly enable SP Metadata Signature
result.put(SAMLIdentityProviderConfig.SIGN_SP_METADATA, "true");
// Create new SAML identity provider using configuration retrieved from import-config
IdentityProviderRepresentation idpRep = createRep("saml", "saml", true, result);
create(idpRep);
// Perform export, and make sure some of the values are like they're supposed to be
Response response = realm.identityProviders().get("saml").export("xml");
Assert.assertEquals(200, response.getStatus());
body = response.readEntity(String.class);
response.close();
Document document = DocumentUtil.getDocument(body);
Element signatureElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), XMLDSIG_NSURI.get(), "Signature");
Assert.assertNotNull(signatureElement);
}
Aggregations