private Attribute<?> getEmailAttributeFromRequest(
     RegistrationRequestState currentRequest, SqlSession sql) throws EngineException {
   List<Attribute<?>> attrs = currentRequest.getRequest().getAttributes();
   if (attrs == null) return null;
   AttributeType at =
       attributesHelper.getAttributeTypeWithSingeltonMetadata(
           ContactEmailMetadataProvider.NAME, sql);
   if (at == null) return null;
   for (Attribute<?> ap : attrs) {
     if (ap == null) continue;
     if (ap.getName().equals(at.getName()) && ap.getGroupPath().equals("/")) return ap;
   }
   return null;
 }
 private AttributeType getNameAT() {
   AttributeType nameAt = new AttributeType(CLIENT_NAME, new StringAttributeSyntax(), msg);
   nameAt.setFlags(AttributeType.TYPE_IMMUTABLE_FLAG);
   nameAt.setMinElements(1);
   nameAt.setMaxElements(1);
   nameAt.setUniqueValues(false);
   nameAt.setVisibility(AttributeVisibility.local);
   return nameAt;
 }
 private AttributeType getAllowedURIsAT() {
   AttributeType authorizationAt =
       new AttributeType(ALLOWED_RETURN_URI, new StringAttributeSyntax(), msg);
   authorizationAt.setFlags(AttributeType.TYPE_IMMUTABLE_FLAG);
   authorizationAt.setMinElements(1);
   authorizationAt.setMaxElements(5);
   authorizationAt.setUniqueValues(false);
   authorizationAt.setVisibility(AttributeVisibility.local);
   return authorizationAt;
 }
 private AttributeType getAllowedGrantFlowsAT() {
   Set<String> allowed = new HashSet<>();
   for (GrantFlow gf : GrantFlow.values()) allowed.add(gf.toString());
   AttributeType allowedGrantsAt =
       new AttributeType(ALLOWED_FLOWS, new EnumAttributeSyntax(allowed), msg);
   allowedGrantsAt.setFlags(AttributeType.TYPE_IMMUTABLE_FLAG);
   allowedGrantsAt.setMinElements(1);
   allowedGrantsAt.setMaxElements(5);
   allowedGrantsAt.setUniqueValues(true);
   allowedGrantsAt.setVisibility(AttributeVisibility.local);
   return allowedGrantsAt;
 }
 private AttributeType getLogoAT() {
   JpegImageAttributeSyntax syntax = new JpegImageAttributeSyntax();
   try {
     syntax.setMaxHeight(200);
     syntax.setMaxWidth(400);
     syntax.setMaxSize(4000000);
   } catch (WrongArgumentException e) {
     throw new IllegalArgumentException(e);
   }
   AttributeType logoAt = new AttributeType(CLIENT_LOGO, syntax, msg);
   logoAt.setFlags(AttributeType.TYPE_IMMUTABLE_FLAG);
   logoAt.setMinElements(1);
   logoAt.setMaxElements(1);
   logoAt.setUniqueValues(false);
   logoAt.setVisibility(AttributeVisibility.local);
   return logoAt;
 }
 @Override
 public List<AttributeType> convertSingle(LDAPAttributeType at) {
   AttributeValueSyntax<?> syntax = getSyntaxForOid(at.getSyntax());
   List<AttributeType> ret = new ArrayList<AttributeType>(at.getNames().size());
   for (String name : at.getNames()) {
     AttributeType converted = new AttributeType(name, syntax);
     if (at.isSingleValue()) {
       converted.setMaxElements(1);
       converted.setMinElements(1);
     } else {
       converted.setMinElements(0);
       converted.setMaxElements(256);
     }
     if (at.getDescription() != null)
       converted.setDescription(new I18nString(at.getDescription()));
     ret.add(converted);
   }
   return ret;
 }