List of usage examples for org.apache.commons.lang StringUtils upperCase
public static String upperCase(String str)
Converts a String to upper case as per String#toUpperCase() .
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
/** * {@inheritDoc}/*from w w w. ja va 2s . c om*/ */ public Uid addAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToAdd, OperationOptions options) { log.info("addAttributeValues::begin"); validate(objectClass); try { if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) { DummyAccount account; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { account = resource.getAccountByUsername(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { account = resource.getAccountById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (account == null) { throw new UnknownUidException("Account with UID " + uid + " does not exist on resource"); } // we could change the description here, but don't do that not to collide with ADD operation // TODO add the functionality if needed for (Attribute attr : valuesToAdd) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { if (account.getPassword() != null) { throw new IllegalArgumentException( "Attempt to add value for password while password is already set"); } changePassword(account, attr); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to add value for enable attribute"); } else { String name = attr.getName(); try { account.addAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) { DummyGroup group; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { group = resource.getGroupByName(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { group = resource.getGroupById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (group == null) { throw new UnknownUidException("Group with UID " + uid + " does not exist on resource"); } for (Attribute attr : valuesToAdd) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new IllegalArgumentException("Attempt to change password on group"); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to add value for enable attribute"); } else { String name = attr.getName(); List<Object> values = attr.getValue(); if (attr.is(DummyGroup.ATTR_MEMBERS_NAME) && values != null && configuration.getUpCaseName()) { List<Object> newValues = new ArrayList<Object>(values.size()); for (Object val : values) { newValues.add(StringUtils.upperCase((String) val)); } values = newValues; } try { group.addAttributeValues(name, values); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) { DummyPrivilege priv; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { priv = resource.getPrivilegeByName(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { priv = resource.getPrivilegeById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (priv == null) { throw new UnknownUidException("Privilege with UID " + uid + " does not exist on resource"); } for (Attribute attr : valuesToAdd) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new IllegalArgumentException("Attempt to change password on privilege"); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to add value for enable attribute"); } else { String name = attr.getName(); try { priv.addAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else { throw new ConnectorException("Unknown object class " + objectClass); } } catch (ConnectException e) { log.info("addAttributeValues::exception " + e); throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { log.info("addAttributeValues::exception " + e); throw new ConnectorIOException(e.getMessage(), e); } log.info("addAttributeValues::end"); return uid; }
From source file:adalid.core.programmers.AbstractSqlProgrammer.java
private String getArtifactFixedCaseName(Artifact artifact) { String name = artifact.getName(); String NAME = StringUtils.upperCase(name); return StringUtils.equals(name, NAME) ? StringUtils.lowerCase(name) : name; }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
/** * {@inheritDoc}/*from w ww . j a v a2 s . co m*/ */ public Uid removeAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToRemove, OperationOptions options) { log.info("removeAttributeValues::begin"); validate(objectClass); try { if (ObjectClass.ACCOUNT.is(objectClass.getObjectClassValue())) { DummyAccount account; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { account = resource.getAccountByUsername(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { account = resource.getAccountById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (account == null) { throw new UnknownUidException("Account with UID " + uid + " does not exist on resource"); } // we could change the description here, but don't do that not to collide with REMOVE operation // TODO add the functionality if needed for (Attribute attr : valuesToRemove) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new UnsupportedOperationException("Removing password value is not supported"); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to remove value from enable attribute"); } else { String name = attr.getName(); try { account.removeAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else if (ObjectClass.GROUP.is(objectClass.getObjectClassValue())) { DummyGroup group; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { group = resource.getGroupByName(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { group = resource.getGroupById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (group == null) { throw new UnknownUidException("Group with UID " + uid + " does not exist on resource"); } for (Attribute attr : valuesToRemove) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new IllegalArgumentException("Attempt to change password on group"); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to remove value from enable attribute"); } else { String name = attr.getName(); List<Object> values = attr.getValue(); if (attr.is(DummyGroup.ATTR_MEMBERS_NAME) && values != null && configuration.getUpCaseName()) { List<Object> newValues = new ArrayList<Object>(values.size()); for (Object val : values) { newValues.add(StringUtils.upperCase((String) val)); } values = newValues; } try { group.removeAttributeValues(name, values); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else if (objectClass.is(OBJECTCLASS_PRIVILEGE_NAME)) { DummyPrivilege priv; if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) { priv = resource.getPrivilegeByName(uid.getUidValue()); } else if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_UUID)) { priv = resource.getPrivilegeById(uid.getUidValue()); } else { throw new IllegalStateException("Unknown UID mode " + configuration.getUidMode()); } if (priv == null) { throw new UnknownUidException("Privilege with UID " + uid + " does not exist on resource"); } for (Attribute attr : valuesToRemove) { if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new IllegalArgumentException("Attempt to change password on privilege"); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { throw new IllegalArgumentException("Attempt to remove value from enable attribute"); } else { String name = attr.getName(); try { priv.removeAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } } else { throw new ConnectorException("Unknown object class " + objectClass); } } catch (ConnectException e) { log.info("removeAttributeValues::exception " + e); throw new ConnectionFailedException(e.getMessage(), e); } catch (FileNotFoundException e) { log.info("removeAttributeValues::exception " + e); throw new ConnectorIOException(e.getMessage(), e); } log.info("removeAttributeValues::end"); return uid; }
From source file:com.example.app.support.address.AddressParser.java
private static String designatorConfusingCitiesCorrection(Map<AddressComponent, String> parsedLocation, String input) {/*from ww w. java 2s . c om*/ String street = parsedLocation.get(STREET); String type = parsedLocation.get(TYPE); String line2 = parsedLocation.get(LINE2); if (street == null || type == null || line2 != null || street.split(" ").length < 2) { return null; } Matcher m = STREET_DESIGNATOR_CHECK.matcher(street); if (m.find()) { String parsedstate = parsedLocation.get(STATE); if (parsedstate == null) { String parsedcity = parsedLocation.get(CITY); if (parsedcity != null && parsedcity.length() == 2) { parsedstate = parsedcity; } } String normalizedState = AddressStandardizer.normalizeState(StringUtils.upperCase(parsedstate)); String inputUpper = input.toUpperCase(); String ret = null; Set<String> stateSet = new HashSet<>(); if (normalizedState != null) { stateSet.add(normalizedState); } else { //if no state in put, this needs to work much harder stateSet.addAll(SpecialData.C_MAP.keySet()); } int stateIdx = parsedstate == null ? input.length() : input.lastIndexOf(parsedstate); for (String state : stateSet) { for (String s : SpecialData.C_MAP.get(state)) { int idx = -1; if ((idx = inputUpper.lastIndexOf(s)) != -1) { //and the input has one of the city names that can confuse the parser //this almost guaranteed to break the parser, help the parser by putting a comma separator before the city if (idx + s.length() >= stateIdx - 2) { return input.substring(0, idx) + ',' + input.substring(idx); } } } } return ret; } return null; }
From source file:eu.eidas.auth.engine.SamlEngine.java
/** * Gets the country from X.509 Certificate. * * @param keyInfo the key info/*from ww w . j a v a2s . co m*/ * @return the country */ private String getCountry(KeyInfo keyInfo) { LOG.trace("Recover country information."); try { org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo.getX509Datas().get(0).getX509Certificates() .get(0); // Transform the KeyInfo to X509Certificate. X509Certificate cert = CertificateUtil.toCertificate(xmlCert.getValue()); String distName = cert.getSubjectDN().toString(); distName = StringUtils.deleteWhitespace(StringUtils.upperCase(distName)); String countryCode = "C="; int init = distName.indexOf(countryCode); String result = ""; if (init > StringUtils.INDEX_NOT_FOUND) { // Exist country code. int end = distName.indexOf(',', init); if (end <= StringUtils.INDEX_NOT_FOUND) { end = distName.length(); } if (init < end && end > StringUtils.INDEX_NOT_FOUND) { result = distName.substring(init + countryCode.length(), end); //It must be a two characters value if (result.length() > 2) { result = result.substring(0, 2); } } } return result.trim(); } catch (EIDASSAMLEngineException e) { LOG.error(SAML_EXCHANGE, "BUSINESS EXCEPTION : Procces getCountry from certificate: " + e.getMessage(), e); throw new EIDASSAMLEngineRuntimeException(e); } }
From source file:gov.nih.nci.cabig.caaers.domain.AdverseEventReportingPeriod.java
/** * verifies whether the reporting period has same core attributes * related to CAAERS-7414//from w w w. j a va 2 s. c o m * * @param otherCycleNumber, reporting period cycle number * @param otherStartDate, reporting start date * @param treatmentAssignment, treatment assignment * @return true, if successful */ public boolean hasSameCoreAttributes(Integer otherCycleNumber, Date otherStartDate, String otherTAC) { // if thisTAC or otherTAC are null assign them the value 'OTHER' String thisTAC = this.getTreatmentAssignment() != null && this.getTreatmentAssignment().getCode() != null ? StringUtils.upperCase(this.getTreatmentAssignment().getCode()) : "OTHER"; String thatTAC = otherTAC != null ? StringUtils.upperCase(otherTAC) : "OTHER"; if (!ObjectUtils.equals(thisTAC, thatTAC)) { return false; } // if at least one of the start dates is not null, compare them if ((this.getStartDate() != null || otherStartDate != null) && (DateUtils.compareDate(this.startDate, otherStartDate) != 0)) return false; // if at least one of the cycle numbers is not null, compare them if ((this.getCycleNumber() != null || otherCycleNumber != null) && (!ObjectUtils.equals(this.getCycleNumber(), otherCycleNumber))) return false; return true; }
From source file:eu.eidas.auth.engine.EIDASSAMLEngine.java
/** * Gets the country from X.509 Certificate. * //w ww . j a va2 s.co m * @param keyInfo the key info * * @return the country */ private String getCountry(final KeyInfo keyInfo) { LOG.trace("Recover country information."); String result = ""; try { final org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo.getX509Datas().get(0) .getX509Certificates().get(0); // Transform the KeyInfo to X509Certificate. CertificateFactory certFact; certFact = CertificateFactory.getInstance("X.509"); final ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(xmlCert.getValue())); final X509Certificate cert = (X509Certificate) certFact.generateCertificate(bis); String distName = cert.getSubjectDN().toString(); distName = StringUtils.deleteWhitespace(StringUtils.upperCase(distName)); final String countryCode = "C="; final int init = distName.indexOf(countryCode); if (init > StringUtils.INDEX_NOT_FOUND) { // Exist country code. int end = distName.indexOf(',', init); if (end <= StringUtils.INDEX_NOT_FOUND) { end = distName.length(); } if (init < end && end > StringUtils.INDEX_NOT_FOUND) { result = distName.substring(init + countryCode.length(), end); //It must be a two characters value if (result.length() > 2) { result = result.substring(0, 2); } } } } catch (CertificateException e) { LOG.info(SAML_EXCHANGE, "BUSINESS EXCEPTION : Procces getCountry from certificate. {}", e.getMessage()); LOG.debug(SAML_EXCHANGE, "BUSINESS EXCEPTION : Procces getCountry from certificate. {}", e); } return result.trim(); }
From source file:eu.europa.esig.dss.validation.SignedDocumentValidator.java
/** * This method deals with the signature policy. The retrieved information is transformed to the JAXB object. * * @param signature//from w w w. ja v a 2 s. c o m * Signature to be validated (can be XAdES, CAdES, PAdES). * @param xmlSignature * The JAXB object containing all diagnostic data pertaining to the signature */ private void dealPolicy(final AdvancedSignature signature, final XmlSignature xmlSignature) { SignaturePolicy signaturePolicy = null; try { signaturePolicy = signature.getPolicyId(); } catch (Exception e) { final String msg = "Error when extracting the signature policy: " + e.getMessage(); LOG.warn(msg, e); addErrorMessage(xmlSignature, msg); } if (signaturePolicy == null) { return; } final XmlPolicy xmlPolicy = DIAGNOSTIC_DATA_OBJECT_FACTORY.createXmlPolicy(); xmlSignature.setPolicy(xmlPolicy); final String policyId = signaturePolicy.getIdentifier(); xmlPolicy.setId(policyId); final String policyUrl = signaturePolicy.getUrl(); xmlPolicy.setUrl(policyUrl); final String notice = signaturePolicy.getNotice(); xmlPolicy.setNotice(notice); final String policyDigestValueFromSignature = StringUtils.upperCase(signaturePolicy.getDigestValue()); final DigestAlgorithm signPolicyHashAlgFromSignature = signaturePolicy.getDigestAlgorithm(); XmlDigestAlgAndValueType xmlDigestAlgAndValue = DIAGNOSTIC_DATA_OBJECT_FACTORY .createXmlDigestAlgAndValueType(); xmlDigestAlgAndValue.setDigestMethod( signPolicyHashAlgFromSignature == null ? "" : signPolicyHashAlgFromSignature.getName()); xmlDigestAlgAndValue.setDigestValue(policyDigestValueFromSignature); xmlPolicy.setDigestAlgAndValue(xmlDigestAlgAndValue); /** * ETSI 102 853: * 3) Obtain the digest of the resulting document against which the digest value present in the property/attribute will be checked: */ if ((policyDocument == null) && StringUtils.isEmpty(policyUrl)) { xmlPolicy.setIdentified(false); if (policyId.isEmpty()) { xmlPolicy.setStatus(true); } else { xmlPolicy.setStatus(false); } return; } xmlPolicy.setIdentified(true); byte[] policyBytes = null; try { if (policyDocument == null) { final DataLoader dataLoader = certificateVerifier.getDataLoader(); policyBytes = dataLoader.get(policyUrl); } else { policyBytes = DSSUtils.toByteArray(policyDocument); } } catch (Exception e) { // When any error (communication) we just set the status to false xmlPolicy.setStatus(false); xmlPolicy.setProcessingError(e.getMessage()); //Do nothing LOG.warn(e.getMessage(), e); return; } boolean isAsn1Processable; ASN1Sequence asn1Sequence = null; try { asn1Sequence = DSSASN1Utils.toASN1Primitive(policyBytes); isAsn1Processable = true; } catch (Exception e) { LOG.info("Policy bytes are not asn1 processable : " + e.getMessage()); isAsn1Processable = false; } xmlPolicy.setAsn1Processable(isAsn1Processable); try { if (isAsn1Processable) { /** * a) * If the resulting document is based on TR 102 272 [i.2] (ESI: ASN.1 format for signature policies), use the digest value present in the * SignPolicyDigest element from the resulting document. Check that the digest algorithm indicated * in the SignPolicyDigestAlg from the resulting document is equal to the digest algorithm indicated in the property. */ final ASN1Sequence signPolicyHashAlgObject = (ASN1Sequence) asn1Sequence.getObjectAt(0); final AlgorithmIdentifier signPolicyHashAlgIdentifier = AlgorithmIdentifier .getInstance(signPolicyHashAlgObject); DigestAlgorithm signPolicyHashAlgFromPolicy = DigestAlgorithm .forOID(signPolicyHashAlgIdentifier.getAlgorithm().getId()); /** * b) * If the resulting document is based on TR 102 038 [i.3] ((ESI) XML format for signature policies), use the digest value present in * signPolicyHash element from the resulting document. Check that the digest * algorithm indicated in the signPolicyHashAlg from the resulting document is equal to the digest algorithm indicated in the attribute. */ /** * The use of a zero-sigPolicyHash value is to ensure backwards compatibility with earlier versions of the * current document. If sigPolicyHash is zero, then the hash value should not be checked against the * calculated hash value of the signature policy. */ if (!signPolicyHashAlgFromPolicy.equals(signPolicyHashAlgFromSignature)) { xmlPolicy.setProcessingError( "The digest algorithm indicated in the SignPolicyHashAlg from the resulting document (" + signPolicyHashAlgFromPolicy + ") is not equal to the digest " + "algorithm (" + signPolicyHashAlgFromSignature + ")."); xmlPolicy.setDigestAlgorithmsEqual(false); xmlPolicy.setStatus(false); return; } else { xmlPolicy.setDigestAlgorithmsEqual(true); } byte[] recalculatedDigestValue = DSSASN1Utils .getAsn1SignaturePolicyDigest(signPolicyHashAlgFromPolicy, policyBytes); String recalculatedDigestHexValue = DSSUtils.toHex(recalculatedDigestValue); boolean equal = policyDigestValueFromSignature.equals(recalculatedDigestHexValue); xmlPolicy.setStatus(equal); if (!equal) { xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature + ") does not match the re-calculated digest value (" + recalculatedDigestHexValue + ")."); return; } final ASN1OctetString signPolicyHash = (ASN1OctetString) asn1Sequence.getObjectAt(2); final byte[] policyDigestValueFromPolicy = signPolicyHash.getOctets(); String policyDigestHexValueFromPolicy = DSSUtils.toHex(policyDigestValueFromPolicy); equal = policyDigestValueFromSignature.equals(policyDigestHexValueFromPolicy); xmlPolicy.setStatus(equal); if (!equal) { xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature + ") does not match the digest value from the policy file (" + policyDigestHexValueFromPolicy + ")."); } } else { /** * c) * In all other cases, compute the digest using the digesting algorithm indicated in the children of the property/attribute. */ byte[] recalculatedDigestValue = DSSUtils.digest(signPolicyHashAlgFromSignature, policyBytes); String recalculatedDigestHexValue = DSSUtils.toHex(recalculatedDigestValue); boolean equal = policyDigestValueFromSignature.equals(recalculatedDigestHexValue); xmlPolicy.setStatus(equal); if (!equal) { xmlPolicy.setProcessingError("The policy digest value (" + policyDigestValueFromSignature + ") does not match the re-calculated digest value (" + recalculatedDigestHexValue + ")."); return; } } } catch (RuntimeException e) { // When any error (communication) we just set the status to false xmlPolicy.setStatus(false); xmlPolicy.setProcessingError(e.getMessage()); //Do nothing LOG.warn(e.getMessage(), e); } }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
private DummyAccount convertToAccount(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException { log.ok("Create attributes: {0}", createAttributes); String userName = Utils.getMandatoryStringAttribute(createAttributes, Name.NAME); if (configuration.getUpCaseName()) { userName = StringUtils.upperCase(userName); }/* w ww . j ava2 s.c o m*/ log.ok("Username {0}", userName); final DummyAccount newAccount = new DummyAccount(userName); Boolean enabled = null; for (Attribute attr : createAttributes) { if (attr.is(Uid.NAME)) { throw new IllegalArgumentException("UID explicitly specified in the account attributes"); } else if (attr.is(Name.NAME)) { // Skip, already processed } else if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { changePassword(newAccount, attr); } else if (attr.is(OperationalAttributeInfos.ENABLE.getName())) { enabled = getBoolean(attr); newAccount.setEnabled(enabled); } else if (attr.is(OperationalAttributeInfos.ENABLE_DATE.getName())) { if (configuration.getSupportValidity()) { newAccount.setValidFrom(getDate(attr)); } else { throw new IllegalArgumentException( "ENABLE_DATE specified in the account attributes while not supporting it"); } } else if (attr.is(OperationalAttributeInfos.DISABLE_DATE.getName())) { if (configuration.getSupportValidity()) { newAccount.setValidTo(getDate(attr)); } else { throw new IllegalArgumentException( "DISABLE_DATE specified in the account attributes while not supporting it"); } } else if (attr.is(OperationalAttributeInfos.LOCK_OUT.getName())) { Boolean lockout = getBoolean(attr); newAccount.setLockout(lockout); } else { String name = attr.getName(); try { newAccount.replaceAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { // we cannot throw checked exceptions. But this one looks suitable. // Note: let's do the bad thing and add exception loaded by this classloader as inner exception here // The framework should deal with it ... somehow throw new IllegalArgumentException(e.getMessage(), e); } } } if (configuration.getRequireExplicitEnable() && enabled == null) { throw new IllegalArgumentException( "Explicit value for ENABLE attribute was not provided and the connector is set to require it"); } return newAccount; }
From source file:com.evolveum.icf.dummy.connector.DummyConnector.java
private DummyGroup convertToGroup(Set<Attribute> createAttributes) throws ConnectException, FileNotFoundException { String icfName = Utils.getMandatoryStringAttribute(createAttributes, Name.NAME); if (configuration.getUpCaseName()) { icfName = StringUtils.upperCase(icfName); }/* w w w . j a v a2 s .com*/ final DummyGroup newGroup = new DummyGroup(icfName); Boolean enabled = null; for (Attribute attr : createAttributes) { if (attr.is(Uid.NAME)) { throw new IllegalArgumentException("UID explicitly specified in the group attributes"); } else if (attr.is(Name.NAME)) { // Skip, already processed } else if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) { throw new IllegalArgumentException("Password specified for a group"); } else if (attr.is(OperationalAttributeInfos.ENABLE.getName())) { enabled = getBoolean(attr); newGroup.setEnabled(enabled); } else if (attr.is(OperationalAttributeInfos.ENABLE_DATE.getName())) { if (configuration.getSupportValidity()) { newGroup.setValidFrom(getDate(attr)); } else { throw new IllegalArgumentException( "ENABLE_DATE specified in the group attributes while not supporting it"); } } else if (attr.is(OperationalAttributeInfos.DISABLE_DATE.getName())) { if (configuration.getSupportValidity()) { newGroup.setValidTo(getDate(attr)); } else { throw new IllegalArgumentException( "DISABLE_DATE specified in the group attributes while not supporting it"); } } else { String name = attr.getName(); try { newGroup.replaceAttributeValues(name, attr.getValue()); } catch (SchemaViolationException e) { throw new IllegalArgumentException(e.getMessage(), e); } } } return newGroup; }