target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testHashCodeTransitive() throws Exception { assertEquals( attributeValueItemA.hashCode(), attributeValueItemACopy.hashCode() ); assertEquals( attributeValueItemACopy.hashCode(), attributeValueItemB.hashCode() ); assertEquals( attributeValueItemA.hashCode(), attributeValueItemB.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( attributes != null ) { for ( Attribute attribute : attributes ) { hash = hash * 17 + attribute.hashCode(); } } return hash; } | AttributeValueItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( attributes != null ) { for ( Attribute attribute : attributes ) { hash = hash * 17 + attribute.hashCode(); } } return hash; } } | AttributeValueItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( attributes != null ) { for ( Attribute attribute : attributes ) { hash = hash * 17 + attribute.hashCode(); } } return hash; } AttributeValueItem( Set<Attribute> attributes ); } | AttributeValueItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( attributes != null ) { for ( Attribute attribute : attributes ) { hash = hash * 17 + attribute.hashCode(); } } return hash; } AttributeValueItem( Set<Attribute> attributes ); Iterator<Attribute> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | AttributeValueItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( attributes != null ) { for ( Attribute attribute : attributes ) { hash = hash * 17 + attribute.hashCode(); } } return hash; } AttributeValueItem( Set<Attribute> attributes ); Iterator<Attribute> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( attributeValueItemA.equals( attributeValueItemC ) ); assertFalse( attributeValueItemC.equals( attributeValueItemA ) ); assertFalse( attributeValueItemA.equals( attributeValueItemD ) ); assertFalse( attributeValueItemD.equals( attributeValueItemA ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof AttributeValueItem ) { AttributeValueItem that = ( AttributeValueItem ) o; if ( attributes != null ) { if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) ) { return false; } for ( Attribute attribute : attributes ) { if ( !that.attributes.contains( attribute ) ) { return false; } } return true; } else { return attributes == null; } } return false; } | AttributeValueItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof AttributeValueItem ) { AttributeValueItem that = ( AttributeValueItem ) o; if ( attributes != null ) { if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) ) { return false; } for ( Attribute attribute : attributes ) { if ( !that.attributes.contains( attribute ) ) { return false; } } return true; } else { return attributes == null; } } return false; } } | AttributeValueItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof AttributeValueItem ) { AttributeValueItem that = ( AttributeValueItem ) o; if ( attributes != null ) { if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) ) { return false; } for ( Attribute attribute : attributes ) { if ( !that.attributes.contains( attribute ) ) { return false; } } return true; } else { return attributes == null; } } return false; } AttributeValueItem( Set<Attribute> attributes ); } | AttributeValueItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof AttributeValueItem ) { AttributeValueItem that = ( AttributeValueItem ) o; if ( attributes != null ) { if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) ) { return false; } for ( Attribute attribute : attributes ) { if ( !that.attributes.contains( attribute ) ) { return false; } } return true; } else { return attributes == null; } } return false; } AttributeValueItem( Set<Attribute> attributes ); Iterator<Attribute> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | AttributeValueItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof AttributeValueItem ) { AttributeValueItem that = ( AttributeValueItem ) o; if ( attributes != null ) { if ( ( that.attributes == null ) || ( that.attributes.size() != attributes.size() ) ) { return false; } for ( Attribute attribute : attributes ) { if ( !that.attributes.contains( attribute ) ) { return false; } } return true; } else { return attributes == null; } } return false; } AttributeValueItem( Set<Attribute> attributes ); Iterator<Attribute> iterator(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testEqualsNotInstanceOf() throws Exception { assertFalse( classesItemA.equals( UndefinedNode.UNDEFINED_NODE ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testEqualsNull() throws Exception { assertFalse( classesItemA.equals( null ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeReflexive() throws Exception { assertEquals( classesItemA.hashCode(), classesItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeSymmetric() throws Exception { assertEquals( classesItemA.hashCode(), classesItemACopy.hashCode() ); assertEquals( classesItemACopy.hashCode(), classesItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeTransitive() throws Exception { assertEquals( classesItemA.hashCode(), classesItemACopy.hashCode() ); assertEquals( classesItemACopy.hashCode(), classesItemB.hashCode() ); assertEquals( classesItemA.hashCode(), classesItemB.hashCode() ); } | @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; if ( classes != null ) { hash = hash * 17 + classes.hashCode(); } else { hash = hash * 17 + getClass().getName().hashCode(); } return hash; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( classesItemA.equals( classesItemC ) ); assertFalse( classesItemC.equals( classesItemA ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | ClassesItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof ClassesItem ) { ClassesItem that = ( ClassesItem ) o; if ( classes == null ) { return that.classes == null; } return classes.equals( that.classes ); } return false; } ClassesItem( ExprNode classes ); ExprNode getClasses(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testEqualsNotInstanceOf() throws Exception { assertFalse( maxImmSubItemA.equals( UndefinedNode.UNDEFINED_NODE ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testYearMonthDayHourMinSecDotFractionZulu() throws ParseException { String gt = "20080102121314.987Z"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testEqualsNull() throws Exception { assertFalse( maxImmSubItemA.equals( null ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeReflexive() throws Exception { assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeSymmetric() throws Exception { assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemACopy.hashCode() ); assertEquals( maxImmSubItemACopy.hashCode(), maxImmSubItemA.hashCode() ); } | @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testHashCodeTransitive() throws Exception { assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemACopy.hashCode() ); assertEquals( maxImmSubItemACopy.hashCode(), maxImmSubItemB.hashCode() ); assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemB.hashCode() ); } | @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public int hashCode() { int hash = 37; hash = hash * 17 + value; return hash; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( maxImmSubItemA.equals( maxImmSubItemC ) ); assertFalse( maxImmSubItemC.equals( maxImmSubItemA ) ); } | @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } | MaxImmSubItem extends ProtectedItem { @Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o instanceof MaxImmSubItem ) { MaxImmSubItem that = ( MaxImmSubItem ) o; return this.value == that.value; } return false; } MaxImmSubItem( int value ); int getValue(); @Override int hashCode(); @Override boolean equals( Object o ); @Override String toString(); } |
@Test public void testLdapUrlNull() { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnEmpty() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnSimple() throws LdapURLEncodingException { assertEquals( "ldap: .toString() ); } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnWithMinus() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost1() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinSecDotFractionPlusHour() throws ParseException { String gt = "20080102121314.987+0100"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testDnBadHost2() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost3() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost4() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost5() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost6() throws LdapURLEncodingException { assertEquals( "ldap: new LdapUrl( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHost7() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnIPV4Host() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnIPV4HostPort() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHostIP1() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnBadHostIP2() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinSecDotFractionMinusHourMin() throws ParseException { String gt = "20080102121314.987-1030"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testDnBadHostIP3() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnNotAnIP() throws LdapURLEncodingException { assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnIPv6Host() throws LdapURLEncodingException { assertEquals( "ldap: assertEquals( "ldap: assertEquals( "ldap: assertEquals( "ldap: assertEquals( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnSimpleDN() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnSimpleDN2() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnSimpleDNEncoded() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnUniqueAttribute() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnAttributes() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnDuplicatedAttributes() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapNoDNAttributes() throws LdapURLEncodingException { assertEquals( "ldap: new LdapUrl( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinSecCommaFractionZulu() throws ParseException { String gt = "20080102121314,987Z"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testLdapRFC2255_1() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_2() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_3() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_4() throws LdapURLEncodingException { assertEquals( "ldap: new LdapUrl( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_5() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_6() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_7() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_8() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapRFC2255_9() throws LdapURLEncodingException { assertEquals( "ldap: "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testDnEmptyLdaps() throws LdapURLEncodingException { assertEquals( "ldaps: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinSecCommaFractionPlusHour() throws ParseException { String gt = "20080102121314,987+0100"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testDnSimpleLdaps() throws LdapURLEncodingException { assertEquals( "ldaps: .toString() ); } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoHostDN() throws LdapURLEncodingException { try { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } catch ( LdapURLEncodingException luee ) { fail(); } } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLHostNoPortDN() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDN() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrs() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScopeNoFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDN() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrs() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrs() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinSecCommaFractionMinusHourMin() throws ParseException { String gt = "20080102121314,987-1030"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testLdapURLNoDNNoAttrsScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeBase() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsDefaultScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNNoAttrsScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNNoAttrsScopeBase() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNNoAttrsDefaultScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsScopeBase() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsDefaultScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrsScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinZulu() throws ParseException { String gt = "200801021213Z"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testLdapURLDNAttrsScopeBase() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrsDefaultScope() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNNoAttrsNoScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsNoScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeBaseFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNAttrsScopeBaseFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNNoAttrsScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinPlusHour() throws ParseException { String gt = "200801021213+04"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void testLdapURLDNNoAttrsScopeBaseFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrsNoScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrsScopeFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLDNAttrsScopeBaseFilter() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScopeNoFilterNoExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScopeNoFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsNoScopeFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeNoFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeBaseNoFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testLdapURLNoDNNoAttrsScopeFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
@Test public void testYearMonthDayHourMinMinusHourMin() throws ParseException { String gt = "200801021213-1030"; GeneralizedTime generalizedTime = new GeneralizedTime( gt ); String result = generalizedTime.toGeneralizedTime(); assertEquals( gt, result ); } | public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } | GeneralizedTime implements Comparable<GeneralizedTime> { public String toGeneralizedTime() { return toGeneralizedTime( upFormat, upFractionDelimiter, upFractionLength, upTimeZoneFormat ); } GeneralizedTime( Date date ); GeneralizedTime( Calendar calendar ); GeneralizedTime( long timeInMillis ); GeneralizedTime( String generalizedTime ); String toGeneralizedTime(); String toGeneralizedTimeWithoutFraction(); String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
TimeZoneFormat timeZoneFormat ); Calendar getCalendar(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override int compareTo( GeneralizedTime other ); long getTime(); Date getDate(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinutes(); int getSeconds(); int getFraction(); static Date getDate( String zuluTime ); } |
@Test public void fromBytes() throws DecoderException { for ( int i = 0; i < 2; i++ ) { for ( int j = 0; j < 40; j++ ) { assertEquals( i + "." + j, Oid.fromBytes( new byte[] { ( byte ) ( i * 40 + j ) } ) .toString() ); } } assertEquals( "1.2.840.113554.1.2.2", Oid.fromBytes( new byte[] { 0x2A, ( byte ) 0x86, 0x48, ( byte ) 0x86, ( byte ) 0xF7, 0x12, 0x01, 0x02, 0x02 } ).toString() ); assertEquals( "2.123456", Oid.fromBytes( new byte[] { ( byte ) 0x87, ( byte ) 0xC5, 0x10 } ).toString() ); } | public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromString( String oidString ); int getEncodedLength(); @Override int hashCode(); static boolean isOid( String oidString ); byte[] toBytes(); @Override String toString(); void writeBytesTo( ByteBuffer buffer ); void writeBytesTo( OutputStream outputStream ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromString( String oidString ); int getEncodedLength(); @Override int hashCode(); static boolean isOid( String oidString ); byte[] toBytes(); @Override String toString(); void writeBytesTo( ByteBuffer buffer ); void writeBytesTo( OutputStream outputStream ); } |
@Test public void testLdapURLNoDNNoAttrsScopeBaseFilterExtension() throws LdapURLEncodingException { LdapUrl url = new LdapUrl( "ldap: assertEquals( "ldap: } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); } | LdapUrl { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( scheme ); if ( host != null ) { switch ( hostType ) { case IPV4: case REGULAR_NAME: sb.append( host ); break; case IPV6: case IPV_FUTURE: sb.append( '[' ).append( host ).append( ']' ); break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13012_UNEXPECTED_HOST_TYPE_ENUM, hostType ) ); } } if ( port != -1 ) { sb.append( ':' ).append( port ); } if ( dn != null ) { sb.append( '/' ).append( urlEncode( dn.getName(), false ) ); if ( !attributes.isEmpty() || forceScopeRendering || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) ) { sb.append( '?' ); boolean isFirst = true; for ( String attribute : attributes ) { if ( isFirst ) { isFirst = false; } else { sb.append( ',' ); } sb.append( urlEncode( attribute, false ) ); } } if ( forceScopeRendering ) { sb.append( '?' ); sb.append( scope.getLdapUrlValue() ); } else { if ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || !extensionList.isEmpty() ) { sb.append( '?' ); switch ( scope ) { case ONELEVEL: case SUBTREE: sb.append( scope.getLdapUrlValue() ); break; default: break; } if ( ( filter != null ) || ( !extensionList.isEmpty() ) ) { sb.append( "?" ); if ( filter != null ) { sb.append( urlEncode( filter, false ) ); } if ( !extensionList.isEmpty() ) { sb.append( '?' ); boolean isFirst = true; if ( !extensionList.isEmpty() ) { for ( Extension extension : extensionList ) { if ( !isFirst ) { sb.append( ',' ); } else { isFirst = false; } if ( extension.isCritical ) { sb.append( '!' ); } sb.append( urlEncode( extension.type, false ) ); if ( extension.value != null ) { sb.append( '=' ); sb.append( urlEncode( extension.value, true ) ); } } } } } } } } else { sb.append( '/' ); } return sb.toString(); } LdapUrl(); LdapUrl( String string ); boolean isValidInet4Address( String inet4Address ); boolean isValidInet6Address( String inet6Address ); static String urlEncode( String url, boolean doubleEncode ); @Override String toString(); List<String> getAttributes(); Dn getDn(); List<Extension> getExtensions(); Extension getExtension( String type ); String getExtensionValue( String type ); String getFilter(); String getHost(); int getPort(); SearchScope getScope(); String getScheme(); int getNbBytes(); byte[] getBytesReference(); byte[] getBytesCopy(); String getString(); @Override int hashCode(); @Override boolean equals( Object obj ); void setScheme( String scheme ); void setHost( String host ); void setPort( int port ); void setDn( Dn dn ); void setAttributes( List<String> attributes ); void setScope( int scope ); void setScope( SearchScope scope ); void setFilter( String filter ); void setForceScopeRendering( boolean forceScopeRendering ); static final String LDAPS_SCHEME; static final String LDAP_SCHEME; static final LdapUrl EMPTY_URL; } |
Subsets and Splits