protected final void assertGuid(Principal principal, String guid) { if (!principal.getGuid().equals(guid)) { throw new PrincipalNotFoundException("Principal '" + principal.getPrincipalName() + "' found but GUID does not match: expected = '" + principal.getGuid() + "' actual = '" + guid + "'"); } }
protected String replaceTokens(String str, Principal identity) { str = str.replace("${guid}", escapeString(identity.getGuid())); str = str.replace("${principalName}", escapeString(identity.getPrincipalName())); if (identity instanceof Identity) { Identity id = (Identity) identity; Map<String, String[]> attributes = id.getAttributes(); if (attributes != null) { for (Map.Entry<String, String[]> en : attributes.entrySet()) { str = replaceToken(str, "${" + en.getKey() + "}", escapeString(StringUtil.getValue(en.getValue()))); } } } return replaceTokens(str); }