List of usage examples for javax.naming.ldap Control getID
public String getID();
From source file:org.apache.directory.studio.connection.core.io.jndi.LdifSearchLogger.java
/** * {@inheritDoc}//ww w .ja va2 s. c om */ public void logSearchRequest(Connection connection, String searchBase, String filter, SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod, Control[] controls, long requestNum, NamingException ex) { if (!isSearchRequestLogEnabled()) { return; } String scopeAsString = searchControls.getSearchScope() == SearchControls.SUBTREE_SCOPE ? "wholeSubtree (2)" //$NON-NLS-1$ : searchControls.getSearchScope() == SearchControls.ONELEVEL_SCOPE ? "singleLevel (1)" //$NON-NLS-1$ : "baseObject (0)"; //$NON-NLS-1$ String attributesAsString = searchControls.getReturningAttributes() == null ? "*" //$NON-NLS-1$ : searchControls.getReturningAttributes().length == 0 ? "1.1" //$NON-NLS-1$ : StringUtils.join(searchControls.getReturningAttributes(), " "); String aliasAsString = aliasesDereferencingMethod == AliasDereferencingMethod.ALWAYS ? "derefAlways (3)" //$NON-NLS-1$ : aliasesDereferencingMethod == AliasDereferencingMethod.FINDING ? "derefFindingBaseObj (2)" //$NON-NLS-1$ : aliasesDereferencingMethod == AliasDereferencingMethod.SEARCH ? "derefInSearching (1)" //$NON-NLS-1$ : "neverDerefAliases (0)"; //$NON-NLS-1$ // build LDAP URL LdapUrl url = Utils.getLdapURL(connection, searchBase, searchControls.getSearchScope(), filter, searchControls.getReturningAttributes()); // build command line String cmdLine = Utils.getLdapSearchCommandLine(connection, searchBase, searchControls.getSearchScope(), aliasesDereferencingMethod, searchControls.getCountLimit(), searchControls.getTimeLimit(), filter, searchControls.getReturningAttributes()); // build Collection<LdifLineBase> lines = new ArrayList<LdifLineBase>(); lines.add(LdifCommentLine.create("# LDAP URL : " + url.toString())); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# command line : " + cmdLine.toString())); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# baseObject : " + searchBase)); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# scope : " + scopeAsString)); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# derefAliases : " + aliasAsString)); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# sizeLimit : " + searchControls.getCountLimit())); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# timeLimit : " + searchControls.getTimeLimit())); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# typesOnly : " + "False")); //$NON-NLS-1$ //$NON-NLS-2$ lines.add(LdifCommentLine.create("# filter : " + filter)); //$NON-NLS-1$ lines.add(LdifCommentLine.create("# attributes : " + attributesAsString)); //$NON-NLS-1$ if (controls != null) { for (Control control : controls) { lines.add(LdifCommentLine.create("# control : " + control.getID())); //$NON-NLS-1$ } } lines.add(LdifSepLine.create()); String formattedString = ""; //$NON-NLS-1$ for (LdifLineBase line : lines) { formattedString += line.toFormattedString(LdifFormatParameters.DEFAULT); } log(formattedString, "SEARCH REQUEST (" + requestNum + ")", ex, connection); //$NON-NLS-1$ //$NON-NLS-2$ }
From source file:org.atricore.idbus.idojos.ldapidentitystore.LDAPBindIdentityStore.java
protected PasswordPolicyResponseControl decodePasswordPolicyControl(Control[] ldapControls) throws DecoderException { if (ldapControls == null) return null; for (Control ldapControl : ldapControls) { if (ldapControl.getID().equals(PasswordPolicyResponseControl.CONTROL_OID)) { PasswordPolicyControlContainer container = new PasswordPolicyControlContainer(); container.setPasswordPolicyResponseControl(new PasswordPolicyResponseControl()); ControlDecoder decoder = container.getPasswordPolicyControl().getDecoder(); decoder.decode(ldapControl.getEncodedValue(), container.getPasswordPolicyControl()); PasswordPolicyResponseControl ctrl = container.getPasswordPolicyControl(); if (logger.isDebugEnabled()) logger.debug("Password Policy Control : " + ctrl.toString()); return ctrl; }//from ww w .j av a 2s. co m } logger.warn("No LDAP Control found for " + PasswordPolicyResponseControl.CONTROL_OID); return null; }
From source file:org.springframework.ldap.core.RequestControlMatcher.java
private boolean controlMatches(Control expected, Control actual) { // Compare SortControl return StringUtils.equals(expected.getID(), actual.getID()) && expected.isCritical() == actual.isCritical() && ArrayUtils.isEquals(expected.getEncodedValue(), actual.getEncodedValue()); }