/** * Utility function to add an attribute to the hash digest. * * @param a * the attribute to hash */ private static void hashAttribute(Attribute a, MessageDigest dig) { dig.update(a.getId().toString().getBytes()); dig.update(a.getType().toString().getBytes()); dig.update(a.getValue().encode().getBytes()); if (a.getIssuer() != null) { dig.update(a.getIssuer().getBytes()); } if (a.getIssueInstant() != null) { dig.update(a.getIssueInstant().encode().getBytes()); } }
protected List<Subject> wrapSubjects(String subjectLoginId) { logger.debug("wrapSubjectIdAsSubjects(): {}", subjectLoginId); StringAttribute stringAttribute = EMPTY_ATTRIBUTE; Attribute subjectAttribute = SUBJECT_ATTRIBUTE; logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); List<Attribute> subjectAttributes; if (subjectLoginId != null && !subjectLoginId.isEmpty()) { subjectAttributes = new ArrayList<Attribute>(2); subjectAttributes.add(subjectAttribute); stringAttribute = new StringAttribute(subjectLoginId); subjectAttribute = new SingletonAttribute(SUBJECT_ID_URI, null, null, stringAttribute); logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); subjectAttributes.add(subjectAttribute); } else { subjectAttributes = new ArrayList<Attribute>(1); subjectAttributes.add(subjectAttribute); } Subject singleSubject = new Subject(subjectAttributes); return Collections.singletonList(singleSubject); }
protected List<Subject> wrapSubjects(String subjectLoginId) { logger.debug("wrapSubjectIdAsSubjects(): {}", subjectLoginId); StringAttribute stringAttribute = EMPTY_ATTRIBUTE; Attribute subjectAttribute = SUBJECT_ATTRIBUTE; logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); List<Attribute> subjectAttributes; if (subjectLoginId != null && !subjectLoginId.isEmpty()) { subjectAttributes = new ArrayList<Attribute>(2); subjectAttributes.add(subjectAttribute); stringAttribute = new StringAttribute(subjectLoginId); subjectAttribute = new SingletonAttribute(SUBJECT_ID_URI, null, null, stringAttribute); logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); subjectAttributes.add(subjectAttribute); } else { subjectAttributes = new ArrayList<Attribute>(1); subjectAttributes.add(subjectAttribute); } Subject singleSubject = new Subject(subjectAttributes); return Collections.singletonList(singleSubject); }