private String toCamelCase(EventType event){ StringBuilder sb = new StringBuilder("event"); for(String s : event.name().toString().toLowerCase().split("_")){ sb.append(ObjectUtil.capitalize(s)); } return sb.toString(); }
@Override default String getConsentScreenText() { String consentScreenText = ClientScopeModel.super.getConsentScreenText(); if (ObjectUtil.isBlank(consentScreenText)) { consentScreenText = getClientId(); } return consentScreenText; } }
@Override public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("user", new ProfileBean(user)); attributes.put("link", link); attributes.put("linkExpiration", expirationInMinutes); attributes.put("realmName", getRealmName()); BrokeredIdentityContext brokerContext = (BrokeredIdentityContext) this.attributes.get(IDENTITY_PROVIDER_BROKER_CONTEXT); String idpAlias = brokerContext.getIdpConfig().getAlias(); idpAlias = ObjectUtil.capitalize(idpAlias); attributes.put("identityProviderContext", brokerContext); attributes.put("identityProviderAlias", idpAlias); List<Object> subjectAttrs = Arrays.<Object>asList(idpAlias); send("identityProviderLinkSubject", subjectAttrs, "identity-provider-link.ftl", attributes); }
default String getConsentScreenText() { String consentScreenText = getAttribute(CONSENT_SCREEN_TEXT); if (ObjectUtil.isBlank(consentScreenText)) { consentScreenText = getName(); } return consentScreenText; }
private String getRealmName() { if (realm.getDisplayName() != null) { return realm.getDisplayName(); } else { return ObjectUtil.capitalize(realm.getName()); } }
public static String getAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String returnAttrName) { String resourceUrl = composeResourceUrl(rootUrl, realm, resourceEndpoint); resourceUrl = HttpUtil.addQueryParamsToUri(resourceUrl, attrName, attrValue, "first", "0", "max", "2"); List<ObjectNode> users = doGetJSON(RoleOperations.LIST_OF_NODES.class, resourceUrl, auth); ObjectNode user; try { user = new LocalSearch(users).exactMatchOne(attrValue, attrName); } catch (Exception e) { throw new RuntimeException("Multiple " + resourceEndpoint + " found for " + attrName + ": " + attrValue, e); } String typeName = singularize(resourceEndpoint); if (user == null) { throw new RuntimeException(capitalize(typeName) + " not found for " + attrName + ": " + attrValue); } JsonNode attr = user.get(returnAttrName); if (attr == null) { throw new RuntimeException("Returned " + typeName + " info has no '" + returnAttrName + "' attribute"); } return attr.asText(); }
public static String getAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String returnAttrName) { String resourceUrl = composeResourceUrl(rootUrl, realm, resourceEndpoint); resourceUrl = HttpUtil.addQueryParamsToUri(resourceUrl, attrName, attrValue, "first", "0", "max", "2"); List<ObjectNode> users = doGetJSON(RoleOperations.LIST_OF_NODES.class, resourceUrl, auth); ObjectNode user; try { user = new LocalSearch(users).exactMatchOne(attrValue, attrName); } catch (Exception e) { throw new RuntimeException("Multiple " + resourceEndpoint + " found for " + attrName + ": " + attrValue, e); } String typeName = singularize(resourceEndpoint); if (user == null) { throw new RuntimeException(capitalize(typeName) + " not found for " + attrName + ": " + attrValue); } JsonNode attr = user.get(returnAttrName); if (attr == null) { throw new RuntimeException("Returned " + typeName + " info has no '" + returnAttrName + "' attribute"); } return attr.asText(); }