AutoRefactor: fix boolean usage
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Collection; |
| | |
| | | final Collection<? super ByteString> missingValues) { |
| | | final AttributeDescription attributeDescription = attribute.getAttributeDescription(); |
| | | if (attribute.isEmpty()) { |
| | | if (attributes.remove(attributeDescription) != null) { |
| | | return true; |
| | | } else if (attributeDescription.isPlaceHolder()) { |
| | | return attributes.remove(attributeDescription) != null |
| | | || (attributeDescription.isPlaceHolder() |
| | | // Fall-back to inefficient remove using place-holder. |
| | | return super.removeAttribute(attribute, missingValues); |
| | | } else { |
| | | return false; |
| | | } |
| | | && super.removeAttribute(attribute, missingValues)); |
| | | } else { |
| | | final Attribute oldAttribute = getAttribute(attributeDescription); |
| | | if (oldAttribute != null) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | @Override |
| | | public boolean isSubTypeOf(final Impl other) { |
| | | // Other must have no options or the same option. |
| | | if (other == ZERO_OPTION_IMPL) { |
| | | return true; |
| | | } else { |
| | | return equals(other); |
| | | } |
| | | return other == ZERO_OPTION_IMPL || equals(other); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public boolean isSubTypeOf(final AttributeDescription other) { |
| | | if (!attributeType.isSubTypeOf(other.attributeType)) { |
| | | return false; |
| | | } else { |
| | | return pimpl.isSubTypeOf(other.pimpl); |
| | | } |
| | | return attributeType.isSubTypeOf(other.attributeType) |
| | | && pimpl.isSubTypeOf(other.pimpl); |
| | | } |
| | | |
| | | /** |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public boolean isSuperTypeOf(final AttributeDescription other) { |
| | | if (!attributeType.isSuperTypeOf(other.attributeType)) { |
| | | return false; |
| | | } else { |
| | | return pimpl.isSuperTypeOf(other.pimpl); |
| | | } |
| | | return attributeType.isSuperTypeOf(other.attributeType) |
| | | && pimpl.isSuperTypeOf(other.pimpl); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | private boolean isXMLPackageDirectoryValid() { |
| | | if (isExtension) { |
| | | return new File(getXMLPackageDirectory()).isDirectory(); |
| | | } else { |
| | | // Not an extension, so always valid. |
| | | return true; |
| | | } |
| | | return !isExtension |
| | | || new File(getXMLPackageDirectory()).isDirectory(); |
| | | } |
| | | |
| | | private Templates loadStylesheet(final String stylesheet) |
| | |
| | | |
| | | private boolean protocolHasMonitoring(ConnectionHandlerDescriptor ch) |
| | | { |
| | | if (ch.getState() == State.DISABLED) |
| | | return false; |
| | | return ch.getProtocol() == Protocol.LDAP || |
| | | ch.getProtocol() == Protocol.LDAPS || |
| | | ch.getProtocol() == Protocol.LDAP_STARTTLS || |
| | | ch.getProtocol() == Protocol.OTHER; |
| | | return ch.getState() != State.DISABLED |
| | | && (ch.getProtocol() == Protocol.LDAP |
| | | || ch.getProtocol() == Protocol.LDAPS |
| | | || ch.getProtocol() == Protocol.LDAP_STARTTLS |
| | | || ch.getProtocol() == Protocol.OTHER); |
| | | } |
| | | |
| | | /** |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isCellEditable(int row, int col) { |
| | | if (col == 0) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | if (!isReadOnly) |
| | | { |
| | | return !schemaReadOnlyAttributesLowerCase.contains( |
| | | dataArray.get(row).attrName.toLowerCase()); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return col != 0 |
| | | && !isReadOnly |
| | | && !schemaReadOnlyAttributesLowerCase.contains(dataArray.get(row).attrName.toLowerCase()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | |
| | | */ |
| | | public final boolean mustChangePassword() |
| | | { |
| | | if (authenticationInfo == null) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return authenticationInfo.mustChangePassword(); |
| | | } |
| | | return authenticationInfo != null |
| | | && authenticationInfo.mustChangePassword(); |
| | | } |
| | | |
| | | |
| | |
| | | * needed to match ACI targets. |
| | | * @return True if this ACI targets are applicable or match. |
| | | */ |
| | | public static boolean |
| | | isApplicable(Aci aci, AciTargetMatchContext matchCtx) { |
| | | public static boolean isApplicable(Aci aci, AciTargetMatchContext matchCtx) { |
| | | if(matchCtx.hasRights(ACI_EXT_OP)) { |
| | | //Extended operation is being evaluated. |
| | | return AciTargets.isTargetApplicable(aci, matchCtx) && |
| | |
| | | //If an ACI has extOp or targetControl targets skip it because the |
| | | //matchCtx right does not contain either ACI_EXT_OP or ACI_CONTROL at |
| | | //this point. |
| | | if(aci.getTargets().getExtOp() != null |
| | | || aci.getTargets().getTargetControl() != null) { |
| | | return false; |
| | | return hasNoExtOpOrTargetControl(aci.getTargets()) |
| | | && haveSimilarRights(aci, matchCtx) |
| | | && AciTargets.isTargetApplicable(aci, matchCtx) |
| | | && AciTargets.isTargetFilterApplicable(aci, matchCtx) |
| | | && AciTargets.isTargAttrFiltersApplicable(aci, matchCtx) |
| | | && AciTargets.isTargetAttrApplicable(aci, matchCtx); |
| | | } |
| | | return haveSimilarRights(aci, matchCtx) && |
| | | AciTargets.isTargetApplicable(aci, matchCtx) && |
| | | AciTargets.isTargetFilterApplicable(aci, matchCtx) && |
| | | AciTargets.isTargAttrFiltersApplicable(aci, matchCtx) && |
| | | AciTargets.isTargetAttrApplicable(aci, matchCtx); |
| | | } |
| | | |
| | | private static boolean hasNoExtOpOrTargetControl(AciTargets aciTargets) |
| | | { |
| | | return aciTargets.getExtOp() == null |
| | | && aciTargets.getTargetControl() == null; |
| | | } |
| | | |
| | | private static boolean haveSimilarRights(Aci aci, |
| | |
| | | public boolean isConfigurationAddAcceptable( |
| | | ConnectionHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | if (configuration.isEnabled()) { |
| | | // It's enabled so always validate the class. |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } else { |
| | | // It's disabled so ignore it. |
| | | return true; |
| | | } |
| | | return !configuration.isEnabled() |
| | | || isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ConnectionHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | if (configuration.isEnabled()) { |
| | | // It's enabled so always validate the class. |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } else { |
| | | // It's disabled so ignore it. |
| | | return true; |
| | | } |
| | | return !configuration.isEnabled() |
| | | || isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | |
| | | ExtendedOperationHandlerCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | if (configuration.isEnabled()) { |
| | | // It's enabled so always validate the class. |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } else { |
| | | // It's disabled so ignore it. |
| | | return true; |
| | | } |
| | | return !configuration.isEnabled() |
| | | || isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | |
| | | SynchronizationProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | if (configuration.isEnabled()) |
| | | { |
| | | // It's enabled so always validate the class. |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } else |
| | | { |
| | | // It's disabled so ignore it. |
| | | return true; |
| | | } |
| | | return !configuration.isEnabled() |
| | | || isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | |
| | | SynchronizationProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | if (configuration.isEnabled()) |
| | | { |
| | | // It's enabled so always validate the class. |
| | | return isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } else |
| | | { |
| | | // It's disabled so ignore it. |
| | | return true; |
| | | } |
| | | return !configuration.isEnabled() |
| | | || isJavaClassAcceptable(configuration, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | Entry entry = DirectoryConfig.getEntry(userDN); |
| | | if (entry == null) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return isMember(entry); |
| | | } |
| | | return entry != null && isMember(entry); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private boolean filterRequest(final Operation operation) |
| | | { |
| | | // Check target DN. |
| | | if ((targetDNNotEqualTo.length > 0 || targetDNEqualTo.length > 0) |
| | | && !filterRequestTargetDN(operation)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | return (targetDNNotEqualTo.length == 0 && targetDNEqualTo.length == 0) |
| | | || filterRequestTargetDN(operation); |
| | | // TODO: check required controls. |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | // Check group membership. |
| | | if ((userIsNotMemberOf.length > 0 || userIsMemberOf.length > 0) |
| | | && !filterUserIsMemberOf(connection)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | return (userIsNotMemberOf.length == 0 && userIsMemberOf.length == 0) |
| | | || filterUserIsMemberOf(connection); |
| | | } |
| | | |
| | | |
| | |
| | | // Determines whether the provided operation should be logged. |
| | | private boolean isLoggable(Operation operation) |
| | | { |
| | | if (operation.getResultCode() != SUCCESS) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return isResponseLoggable(operation); |
| | | } |
| | | return operation.getResultCode() == SUCCESS |
| | | && isResponseLoggable(operation); |
| | | } |
| | | } |
| | |
| | | final Schema schema = DirectoryServer.getSchema(); |
| | | final ObjectClass sambaOc = schema |
| | | .getObjectClass(toLowerCase(SAMBA_SAM_ACCOUNT_OC_NAME)); |
| | | if (sambaOc == null) |
| | | { |
| | | // If the object class is not defined then presumably we're not syncing. |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return entry.hasObjectClass(sambaOc); |
| | | } |
| | | return sambaOc != null && entry.hasObjectClass(sambaOc); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | public static boolean isEncoded(ByteSequence value) |
| | | { |
| | | // If the value is null or empty, then it's not. |
| | | if ((value == null) || value.length() == 0) |
| | | if (value == null || value.length() == 0) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if ((closingBracePos < 0) || (closingBracePos == 1)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | return closingBracePos >= 0 |
| | | && closingBracePos != 1 |
| | | // The closing curly brace must not be the last character of the password. |
| | | if (closingBracePos == (value.length() - 1)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then it looks to be encoded. |
| | | return true; |
| | | && closingBracePos != value.length() - 1; |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public boolean matches(final Entry entry) |
| | | { |
| | | final ObjectClass oc = DirectoryServer |
| | | .getObjectClass(normalizedObjectClass); |
| | | |
| | | if (oc == null) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return entry.hasObjectClass(oc); |
| | | } |
| | | final ObjectClass oc = DirectoryServer.getObjectClass(normalizedObjectClass); |
| | | return oc != null && entry.hasObjectClass(oc); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean isWithinScope(final Entry entry) |
| | | { |
| | | |
| | | if (isDNWithinScope(entry.getName())) |
| | | { |
| | | if (refinements != null) |
| | | { |
| | | return refinements.matches(entry); |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | return isDNWithinScope(entry.getName()) |
| | | && (refinements == null || refinements.matches(entry)); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.server.core; |
| | | |
| | |
| | | return true; |
| | | } else if (obj instanceof DataProviderID) { |
| | | final DataProviderID other = (DataProviderID) obj; |
| | | if (isInternal != other.isInternal) { |
| | | return false; |
| | | } else { |
| | | return normalizedName.equals(other.normalizedName); |
| | | } |
| | | return isInternal == other.isInternal |
| | | && normalizedName.equals(other.normalizedName); |
| | | } else { |
| | | return false; |
| | | } |