Java Code Examples for org.keycloak.representations.idm.RealmRepresentation#setSslRequired()
The following examples show how to use
org.keycloak.representations.idm.RealmRepresentation#setSslRequired() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAdapterTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { addAdapterTestRealms(testRealms); for (RealmRepresentation tr : testRealms) { log.info("Setting redirect-uris in test realm '" + tr.getRealm() + "' as " + (isRelative() ? "" : "non-") + "relative"); modifyClientRedirectUris(tr, "http://localhost:8080", ""); modifyClientRedirectUris(tr, "^((?:/.*|)/\\*)", "http://localhost:" + System.getProperty("app.server.http.port", "8280") + "$1", "http://localhost:" + System.getProperty("auth.server.http.port", "8180") + "$1", "https://localhost:" + System.getProperty("app.server.https.port", "8643") + "$1", "https://localhost:" + System.getProperty("auth.server.http.port", "8543") + "$1"); modifyClientWebOrigins(tr, "http://localhost:8080", "http://localhost:" + System.getProperty("app.server.http.port", "8280"), "http://localhost:" + System.getProperty("auth.server.http.port", "8180"), "https://localhost:" + System.getProperty("app.server.https.port", "8643"), "https://localhost:" + System.getProperty("auth.server.http.port", "8543")); modifyClientUrls(tr, "http://localhost:8080", ""); modifySamlMasterURLs(tr, "http://localhost:8080", ""); modifySAMLClientsAttributes(tr, "http://localhost:8080", ""); if (isRelative()) { modifyClientUrls(tr, appServerContextRootPage.toString(), ""); modifySamlMasterURLs(tr, "/", "http://localhost:" + System.getProperty("auth.server.http.port", null) + "/"); modifySAMLClientsAttributes(tr, "8080", System.getProperty("auth.server.http.port", "8180")); } else { modifyClientUrls(tr, "^(/.*)", appServerContextRootPage.toString() + "$1"); modifySamlMasterURLs(tr, "^(/.*)", appServerContextRootPage.toString() + "$1"); modifySAMLClientsAttributes(tr, "^(/.*)", appServerContextRootPage.toString() + "$1"); modifyClientJWKSUrl(tr, "^(/.*)", appServerContextRootPage.toString() + "$1"); } if (AUTH_SERVER_SSL_REQUIRED) { tr.setSslRequired("all"); } } }
Example 2
Source File: RealmInvalidationClusterTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected RealmRepresentation testEntityUpdates(RealmRepresentation realm, boolean backendFailover) { // realm name String originalName = realm.getRealm(); realm.setRealm(realm.getRealm() + "_updated"); realm = updateEntity(originalName, realm, getCurrentFailNode()); verifyEntityUpdateDuringFailover(realm, backendFailover); // enabled realm.setEnabled(!realm.isEnabled()); realm = updateEntityOnCurrentFailNode(realm, "enabled"); verifyEntityUpdateDuringFailover(realm, backendFailover); // public key realm.setPublicKey("GENERATE"); realm = updateEntityOnCurrentFailNode(realm, "public key"); assertNotEquals("GENERATE", realm.getPublicKey()); verifyEntityUpdateDuringFailover(realm, backendFailover); // require ssl realm.setSslRequired("all"); realm = updateEntityOnCurrentFailNode(realm, "require ssl"); verifyEntityUpdateDuringFailover(realm, backendFailover); // brute force detection realm.setBruteForceProtected(!realm.isBruteForceProtected()); realm = updateEntityOnCurrentFailNode(realm, "brute force"); verifyEntityUpdateDuringFailover(realm, backendFailover); // brute force detection - failure factor realm.setBruteForceProtected(true); realm.setFailureFactor(realm.getFailureFactor() + 1); realm = updateEntityOnCurrentFailNode(realm, "brute force failure factor"); verifyEntityUpdateDuringFailover(realm, backendFailover); return realm; }
Example 3
Source File: RealmsConfigurationLoader.java From keycloak with Apache License 2.0 | 4 votes |
private static void readRealm(JsonParser p) throws IOException { // as soon as we encounter users, roles, clients we create a CreateRealmJob // TODO: if after that point in a realm we encounter realm attribute, we report a warning but continue boolean skip = false; try { RealmRepresentation r = new RealmRepresentation(); JsonToken t = p.nextToken(); outer: while (t != JsonToken.END_OBJECT && !skip) { //System.out.println(t + ", name: " + p.getCurrentName() + ", text: '" + p.getText() + "', value: " + p.getValueAsString()); switch (p.getCurrentName()) { case "realm": r.setRealm(getStringValue(p)); skip = !started && realmSkipped(r.getRealm()) ; if (skip) { break outer; } break; case "enabled": r.setEnabled(getBooleanValue(p)); break; case "accessTokenLifespan": r.setAccessCodeLifespan(getIntegerValue(p)); break; case "registrationAllowed": r.setRegistrationAllowed(getBooleanValue(p)); break; case "passwordPolicy": r.setPasswordPolicy(getStringValue(p)); break; case "sslRequired": r.setSslRequired(getStringValue(p)); break; case "users": ensureRealm(r); if (seekToStart()) { enqueueFetchRealmRoles(r); completePending(); } readUsers(r, p); break; case "roles": ensureRealm(r); readRoles(r, p); break; case "clients": ensureRealm(r); readClients(r, p); completePending(); if (seekToStart()) { enqueueFetchMissingClients(r); completePending(); } break; default: { // if we don't understand the field we ignore it - but report that log.warn("Realm attribute ignored: " + p.getCurrentName()); consumeAttribute(p); continue; // skip p.nextToken() at end of loop - consumeAttribute() already did it } } t = p.nextToken(); } if (skip) { log.info("Realm skipped: " + r.getRealm()); consumeParent(p); } } finally { // we wait for realm to complete completePending(); // reset realm specific cache realmCreated = false; clientIdMap.clear(); realmRoleIdMap.clear(); clientRoleIdMap.clear(); } }
Example 4
Source File: TLSTest.java From keycloak with Apache License 2.0 | 4 votes |
@Override public void configureTestRealm(RealmRepresentation testRealm) { testRealm.setSslRequired(SslRequired.NONE.toString()); }
Example 5
Source File: AbstractCliTest.java From keycloak with Apache License 2.0 | 4 votes |
@Override public void addTestRealms(List<RealmRepresentation> testRealms) { for (RealmRepresentation tr : testRealms) { tr.setSslRequired("external"); } }