private ServiceException createServiceException(
      final String attributeName, final String errorCode, final String errorMessage) {
    final ServiceExceptionType serviceExceptionType = new ServiceExceptionType();
    serviceExceptionType.setErrorId(errorCode);
    serviceExceptionType.setText(errorMessage);

    final AttributeType attribute = new AttributeType();
    attribute.setName(attributeName);
    attribute.setNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:basic");

    final AttributeStatementType attributeStatement = new AttributeStatementType();
    attributeStatement.getAttributeOrEncryptedAttribute().add(attribute);

    serviceExceptionType.setVariables(attributeStatement);

    return new ServiceException(errorCode, serviceExceptionType);
  }