Skip to content

Commit

Permalink
Partial fix for DIRSERVER-1728:core-jndi
Browse files Browse the repository at this point in the history
  • Loading branch information
elecharny committed Aug 20, 2024
1 parent 40e8051 commit ec60f0b
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public synchronized Context getInitialContext( Hashtable env ) throws NamingExce

if ( service == null )
{
throw new ConfigurationException( I18n.err( I18n.ERR_477, env ) );
throw new ConfigurationException( I18n.err( I18n.ERR_06014_CANNOT_FIND_DIRECTORY_SERVICE, env ) );
}

if ( !service.isStarted() )
Expand All @@ -74,7 +74,7 @@ public synchronized Context getInitialContext( Hashtable env ) throws NamingExce
}
catch ( LdapInvalidDnException lide )
{
throw new InvalidNameException( I18n.err( I18n.ERR_733, env ) );
throw new InvalidNameException( I18n.err( I18n.ERR_06016_PRINCIPAL_NOT_VALID, env ) );
}

ServerLdapContext ctx = null;
Expand Down Expand Up @@ -148,7 +148,7 @@ else if ( value instanceof byte[] )
}
else
{
throw new javax.naming.ConfigurationException( I18n.err( I18n.ERR_478, Context.SECURITY_CREDENTIALS ) );
throw new javax.naming.ConfigurationException( I18n.err( I18n.ERR_06015_CANNOT_CONVERT_TO_BYTES, Context.SECURITY_CREDENTIALS ) );
}

if ( credential != null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public boolean isSynchronous()

private void deliverNamingExceptionEvent( Exception e )
{
LOG.error( I18n.err( I18n.ERR_118 ), e );
LOG.error( I18n.err( I18n.ERR_06000_ERROR_WHILE_DELIVERING_NOTIFICATIONS ), e );
NamingExceptionEvent evt = null;

if ( e instanceof NamingException )
Expand All @@ -100,7 +100,7 @@ private void deliverNamingExceptionEvent( Exception e )
}
else
{
NamingException ne = new NamingException( I18n.err( I18n.ERR_119 ) );
NamingException ne = new NamingException( I18n.err( I18n.ERR_06001_EXCEPTION_DURING_EVENT_HANDLING ) );
ne.setRootCause( e );
evt = new NamingExceptionEvent( source, ne );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static Object deserialize( Entry serverEntry ) throws NamingException
}
catch ( LdapInvalidAttributeValueException liave )
{
NamingException ne = new NamingException( I18n.err( I18n.ERR_479, className, liave.getLocalizedMessage() ) );
NamingException ne = new NamingException( I18n.err( I18n.ERR_06017_INSTANCE_DESERIALIZATION_FAILED, className, liave.getLocalizedMessage() ) );
ne.setRootCause( liave );
throw ne;
}
Expand All @@ -106,7 +106,7 @@ static Object deserialize( Entry serverEntry ) throws NamingException
}
catch ( Exception e )
{
NamingException ne = new NamingException( I18n.err( I18n.ERR_479, className, e.getLocalizedMessage() ) );
NamingException ne = new NamingException( I18n.err( I18n.ERR_06017_INSTANCE_DESERIALIZATION_FAILED, className, e.getLocalizedMessage() ) );
ne.setRootCause( e );
throw ne;
}
Expand All @@ -132,7 +132,7 @@ static byte[] serialize( Object obj ) throws LdapException
}
catch ( Exception e )
{
throw new LdapException( I18n.err( I18n.ERR_481, obj, e.getLocalizedMessage() ) );
throw new LdapException( I18n.err( I18n.ERR_06018_SERIALIZATION_FAILED, obj, e.getLocalizedMessage() ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static AuthenticationLevel getAuthenticationLevel( Hashtable env ) throws
}
else if ( !( authentication instanceof String ) )
{
throw new ConfigurationException( I18n.err( I18n.ERR_483, authentication.getClass(),
throw new ConfigurationException( I18n.err( I18n.ERR_06002_DONT_KNOW_HOW_TO_INTERPRET, authentication.getClass(),
Context.SECURITY_AUTHENTICATION ) );
}
else
Expand Down Expand Up @@ -116,15 +116,15 @@ public static LdapJndiProperties getLdapJndiProperties( Hashtable env ) throws N

if ( !env.containsKey( Context.PROVIDER_URL ) )
{
String msg = I18n.err( I18n.ERR_484, Context.PROVIDER_URL );
String msg = I18n.err( I18n.ERR_06003_EXPECTED_PROPERTY, Context.PROVIDER_URL );
throw new ConfigurationException( msg );
}

String url = ( String ) env.get( Context.PROVIDER_URL );

if ( url == null )
{
String msg = I18n.err( I18n.ERR_485, Context.PROVIDER_URL );
String msg = I18n.err( I18n.ERR_06004_PROPERTY_SET_TO_NULL, Context.PROVIDER_URL );
throw new ConfigurationException( msg );
}

Expand All @@ -140,7 +140,7 @@ public static LdapJndiProperties getLdapJndiProperties( Hashtable env ) throws N
}
catch ( LdapInvalidDnException lide )
{
String msg = I18n.err( I18n.ERR_733, url );
String msg = I18n.err( I18n.ERR_06016_PRINCIPAL_NOT_VALID, url );
throw new ConfigurationException( msg );
}
}
Expand All @@ -163,7 +163,7 @@ public static LdapJndiProperties getLdapJndiProperties( Hashtable env ) throws N
}
else if ( !( authentication instanceof String ) )
{
throw new ConfigurationException( I18n.err( I18n.ERR_483, authentication.getClass(),
throw new ConfigurationException( I18n.err( I18n.ERR_06002_DONT_KNOW_HOW_TO_INTERPRET, authentication.getClass(),
Context.SECURITY_AUTHENTICATION ) );
}
else
Expand All @@ -189,15 +189,15 @@ else if ( AuthenticationLevel.SIMPLE.toString().equals( authentication ) )

if ( principal == null && props.level == AuthenticationLevel.SIMPLE )
{
throw new ConfigurationException( I18n.err( I18n.ERR_487, Context.SECURITY_PRINCIPAL ) );
throw new ConfigurationException( I18n.err( I18n.ERR_06005_CANNOT_BE_NULL, Context.SECURITY_PRINCIPAL ) );
}
else if ( principal == null && props.level == AuthenticationLevel.NONE )
{
props.bindDn = Dn.EMPTY_DN;
}
else if ( !( principal instanceof String ) )
{
throw new ConfigurationException( I18n.err( I18n.ERR_483, principal.getClass(), Context.SECURITY_PRINCIPAL ) );
throw new ConfigurationException( I18n.err( I18n.ERR_06002_DONT_KNOW_HOW_TO_INTERPRET, principal.getClass(), Context.SECURITY_PRINCIPAL ) );
}
else if ( ( ( String ) principal ).trim().equals( "" ) )
{
Expand All @@ -211,7 +211,7 @@ else if ( ( ( String ) principal ).trim().equals( "" ) )
}
catch ( LdapInvalidDnException lide )
{
String msg = I18n.err( I18n.ERR_733, principal );
String msg = I18n.err( I18n.ERR_06016_PRINCIPAL_NOT_VALID, principal );
throw new ConfigurationException( msg );
}

Expand All @@ -226,7 +226,7 @@ else if ( ( ( String ) principal ).trim().equals( "" ) )
}
else
{
throw new ConfigurationException( I18n.err( I18n.ERR_483, obj.getClass(), SASL_AUTHID ) );
throw new ConfigurationException( I18n.err( I18n.ERR_06002_DONT_KNOW_HOW_TO_INTERPRET, obj.getClass(), SASL_AUTHID ) );
}
props.saslAuthId = ( String ) principal;
}
Expand All @@ -237,7 +237,7 @@ else if ( ( ( String ) principal ).trim().equals( "" ) )

if ( props.level == AuthenticationLevel.SIMPLE && credobj == null )
{
throw new ConfigurationException( I18n.err( I18n.ERR_489 ) );
throw new ConfigurationException( I18n.err( I18n.ERR_06006_CANT_SPECIFY_SIMPLE_AUTHENTICATION ) );
}
else if ( credobj != null )
{
Expand All @@ -251,7 +251,7 @@ else if ( credobj instanceof byte[] )
}
else
{
throw new ConfigurationException( I18n.err( I18n.ERR_483, credobj.getClass(),
throw new ConfigurationException( I18n.err( I18n.ERR_06002_DONT_KNOW_HOW_TO_INTERPRET, credobj.getClass(),
Context.SECURITY_CREDENTIALS ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected ServerContext( DirectoryService service, Hashtable<String, Object> env

if ( !operationManager.hasEntry( hasEntryContext ) )
{
throw new NameNotFoundException( I18n.err( I18n.ERR_490, dn ) );
throw new NameNotFoundException( I18n.err( I18n.ERR_06007_ELEMENT_DOES_NOT_EXIST, dn ) );
}

schemaManager = service.getSchemaManager();
Expand Down Expand Up @@ -245,7 +245,7 @@ public ServerContext( DirectoryService service, LdapPrincipal principal, Name na

if ( !operationManager.hasEntry( hasEntryContext ) )
{
throw new NameNotFoundException( I18n.err( I18n.ERR_490, dn ) );
throw new NameNotFoundException( I18n.err( I18n.ERR_06007_ELEMENT_DOES_NOT_EXIST, dn ) );
}

schemaManager = service.getSchemaManager();
Expand All @@ -269,7 +269,7 @@ public ServerContext( DirectoryService service, CoreSession session, Name name )

if ( !operationManager.hasEntry( hasEntryContext ) )
{
throw new NameNotFoundException( I18n.err( I18n.ERR_490, dn ) );
throw new NameNotFoundException( I18n.err( I18n.ERR_06007_ELEMENT_DOES_NOT_EXIST, dn ) );
}

schemaManager = service.getSchemaManager();
Expand Down Expand Up @@ -915,7 +915,7 @@ public Context createSubcontext( Name name ) throws NamingException
}
catch ( LdapException le )
{
throw new SchemaViolationException( I18n.err( I18n.ERR_491, name ) );
throw new SchemaViolationException( I18n.err( I18n.ERR_06008_CN_ATTRIBUTE_MISSING_FOR_JAVA_CONTAINER, name ) );
}

// Now add the CN attribute, which is mandatory
Expand All @@ -930,13 +930,13 @@ public Context createSubcontext( Name name ) throws NamingException
else
{
// No CN in the rdn, this is an error
throw new SchemaViolationException( I18n.err( I18n.ERR_491, name ) );
throw new SchemaViolationException( I18n.err( I18n.ERR_06008_CN_ATTRIBUTE_MISSING_FOR_JAVA_CONTAINER, name ) );
}
}
else
{
// No CN in the rdn, this is an error
throw new SchemaViolationException( I18n.err( I18n.ERR_491, name ) );
throw new SchemaViolationException( I18n.err( I18n.ERR_06008_CN_ATTRIBUTE_MISSING_FOR_JAVA_CONTAINER, name ) );
}

/*
Expand Down Expand Up @@ -988,7 +988,7 @@ public void destroySubcontext( Name name ) throws NamingException

if ( target.size() == 0 )
{
throw new NoPermissionException( I18n.err( I18n.ERR_492 ) );
throw new NoPermissionException( I18n.err( I18n.ERR_06009_CANT_DELETE_ROOT_DSE ) );
}

try
Expand Down Expand Up @@ -1050,7 +1050,7 @@ public void bind( Name name, Object obj ) throws NamingException
}
catch ( LdapInvalidAttributeTypeException liate )
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}

if ( outServerEntry != null )
Expand Down Expand Up @@ -1082,13 +1082,13 @@ public void bind( Name name, Object obj ) throws NamingException
// Check for Referenceable
else if ( obj instanceof Referenceable )
{
throw new NamingException( I18n.err( I18n.ERR_493 ) );
throw new NamingException( I18n.err( I18n.ERR_06010_CANT_STORE_REFERENCEABLE ) );
}
// Store different formats
else if ( obj instanceof Reference )
{
// Store as ref and add outAttrs
throw new NamingException( I18n.err( I18n.ERR_494 ) );
throw new NamingException( I18n.err( I18n.ERR_06011_CANT_STORE_REFERENCE ) );
}
else if ( obj instanceof Serializable )
{
Expand All @@ -1101,7 +1101,7 @@ else if ( obj instanceof Serializable )
}
catch ( LdapException le )
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}

// Get target and inject all rdn attributes into entry
Expand All @@ -1114,7 +1114,7 @@ else if ( obj instanceof Serializable )
}
catch ( LdapException le )
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}

try
Expand All @@ -1138,7 +1138,7 @@ else if ( obj instanceof DirContext )
}
catch ( LdapInvalidAttributeTypeException liate )
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}

injectRdnAttributeValues( target, serverEntry );
Expand All @@ -1154,7 +1154,7 @@ else if ( obj instanceof DirContext )
}
else
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}
}

Expand Down Expand Up @@ -1361,7 +1361,7 @@ public Object lookup( Name name ) throws NamingException
}
catch ( Exception e )
{
String msg = I18n.err( I18n.ERR_497, target );
String msg = I18n.err( I18n.ERR_06013_CANNOT_CREATE_OBJECT_WITH_FACTORY, target );
NamingException ne = new NamingException( msg );
ne.setRootCause( e );
throw ne;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void bind( Name name, Object obj, Attributes attrs ) throws NamingExcepti
{
if ( ( null == obj ) && ( null == attrs ) )
{
throw new NamingException( I18n.err( I18n.ERR_499 ) );
throw new NamingException( I18n.err( I18n.ERR_06019_ABJ_AND_ATTRS_ARGS_ARE_NULL ) );
}

// A null attrs defaults this to the Context.bind() operation
Expand Down Expand Up @@ -421,14 +421,14 @@ public void bind( Name name, Object obj, Attributes attrs ) throws NamingExcepti
// Check for Referenceable
if ( obj instanceof Referenceable )
{
throw new NamingException( I18n.err( I18n.ERR_493 ) );
throw new NamingException( I18n.err( I18n.ERR_06010_CANT_STORE_REFERENCEABLE ) );
}

// Store different formats
if ( obj instanceof Reference )
{
// Store as ref and add outAttrs
throw new NamingException( I18n.err( I18n.ERR_494 ) );
throw new NamingException( I18n.err( I18n.ERR_06011_CANT_STORE_REFERENCE ) );
}
else if ( obj instanceof Serializable )
{
Expand Down Expand Up @@ -505,7 +505,7 @@ else if ( obj instanceof DirContext )
}
else
{
throw new NamingException( I18n.err( I18n.ERR_495, obj ) );
throw new NamingException( I18n.err( I18n.ERR_06012_CANT_BIND, obj ) );
}
}

Expand Down Expand Up @@ -854,7 +854,7 @@ public NamingEnumeration<SearchResult> search( Name name, String filter, SearchC
}
catch ( ParseException pe )
{
InvalidSearchFilterException isfe = new InvalidSearchFilterException( I18n.err( I18n.ERR_500, filter ) );
InvalidSearchFilterException isfe = new InvalidSearchFilterException( I18n.err( I18n.ERR_06020_PARSE_EXCEPTION_ENCOUNTERED, filter ) );
isfe.setRootCause( pe );
throw isfe;
}
Expand Down Expand Up @@ -970,7 +970,7 @@ public void addNamingListener( Name name, String filterStr, SearchControls searc
}
catch ( Exception e )
{
NamingException e2 = new NamingException( I18n.err( I18n.ERR_501, filterStr ) );
NamingException e2 = new NamingException( I18n.err( I18n.ERR_06021_COULD_NOT_PARSE_FILTER, filterStr ) );
e2.setRootCause( e );
throw e2;
}
Expand Down
Loading

0 comments on commit ec60f0b

Please sign in to comment.