本文整理汇总了Java中org.apache.directory.server.i18n.I18n类的典型用法代码示例。如果您正苦于以下问题:Java I18n类的具体用法?Java I18n怎么用?Java I18n使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
I18n类属于org.apache.directory.server.i18n包,在下文中一共展示了I18n类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Deal with a received BindRequest
*
* @param ldapSession The current session
* @param bindRequest The received BindRequest
* @throws Exception If the authentication cannot be handled
*/
public void handle( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
LOG.debug( "Received: {}", bindRequest );
// Guard clause: LDAP version 3
if ( !bindRequest.getVersion3() )
{
LOG.error( I18n.err( I18n.ERR_162 ) );
LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
bindResult.setDiagnosticMessage( I18n.err( I18n.ERR_163 ) );
ldapSession.getIoSession().write( bindRequest.getResultResponse() );
return;
}
// Deal with the two kinds of authentication : Simple and SASL
if ( bindRequest.isSimple() )
{
handleSimpleAuth( ldapSession, bindRequest );
}
else
{
handleSaslAuth( ldapSession, bindRequest );
}
}
示例2: init
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
public static IoFilterChainBuilder init( LdapServer server ) throws LdapException
{
SSLContext sslCtx;
try
{
sslCtx = server.getSSLContext();
}
catch ( Exception e )
{
throw new LdapException( I18n.err( I18n.ERR_683 ), e );
}
DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
SslFilter sslFilter = new SslFilter( sslCtx );
List<String> cipherSuites = server.getEnabledCipherSuites();
if( ( cipherSuites != null ) && !cipherSuites.isEmpty() )
{
sslFilter.setEnabledCipherSuites( cipherSuites.toArray( new String[cipherSuites.size()] ) );
}
sslFilter.setWantClientAuth( true );
chain.addLast( "sslFilter", sslFilter );
return chain;
}
示例3: getPartition
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Partition getPartition( Dn dn ) throws LdapException
{
Partition parent = null;
synchronized ( partitionLookupTree )
{
parent = partitionLookupTree.getElement( dn );
}
if ( parent == null )
{
throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) );
}
else
{
return parent;
}
}
示例4: getOriginalEntry
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
private Entry getOriginalEntry( OperationContext opContext ) throws LdapException
{
// We have to use the admin session here, otherwise we may have
// trouble reading the entry due to insufficient access rights
CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();
Entry foundEntry = adminSession.lookup( opContext.getDn(), SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES,
SchemaConstants.ALL_USER_ATTRIBUTES );
if ( foundEntry != null )
{
return foundEntry;
}
else
{
// This is an error : we *must* have an entry if we want to be able to rename.
LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
opContext.getDn() ) );
throw ldnfe;
}
}
示例5: delete
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Checks to make sure the entry being deleted exists, and has no children, otherwise throws the appropriate
* LdapException.
*/
public void delete( DeleteOperationContext deleteContext ) throws LdapException
{
Dn dn = deleteContext.getDn();
if ( dn.equals( subschemSubentryDn ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_253,
subschemSubentryDn ) );
}
next( deleteContext );
// Update the alias cache
synchronized ( notAliasCache )
{
if ( notAliasCache.containsKey( dn.getNormName() ) )
{
notAliasCache.remove( dn.getNormName() );
}
}
}
示例6: move
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void move( MoveOperationContext moveContext ) throws LdapException
{
Dn oriChildName = moveContext.getDn();
if ( oriChildName.equals( subschemSubentryDn ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258,
subschemSubentryDn, subschemSubentryDn ) );
}
next( moveContext );
// Remove the original entry from the NotAlias cache, if needed
synchronized ( notAliasCache )
{
if ( notAliasCache.containsKey( oriChildName.getNormName() ) )
{
notAliasCache.remove( oriChildName.getNormName() );
}
}
}
示例7: moveAndRename
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
Dn oldDn = moveAndRenameContext.getDn();
// Don't allow M&R in the SSSE
if ( oldDn.equals( subschemSubentryDn ) )
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258,
subschemSubentryDn, subschemSubentryDn ) );
}
// Remove the original entry from the NotAlias cache, if needed
synchronized ( notAliasCache )
{
if ( notAliasCache.containsKey( oldDn.getNormName() ) )
{
notAliasCache.remove( oldDn.getNormName() );
}
}
next( moveAndRenameContext );
}
示例8: compare
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean compare( CompareOperationContext compareContext ) throws LdapException
{
if ( IS_DEBUG )
{
LOG.debug( "Operation Context: {}", compareContext );
}
// Check that the requested AT exists
// complain if we do not recognize the attribute being compared
if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
{
throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
}
boolean result = next( compareContext );
return result;
}
示例9: assertAllAttributesAllowed
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Checks to see if an attribute is required by as determined from an entry's
* set of objectClass attribute values.
*
* @return true if the objectClass values require the attribute, false otherwise
* @throws Exception if the attribute is not recognized
*/
private void assertAllAttributesAllowed( Dn dn, Entry entry, Set<String> allowed ) throws LdapException
{
// Never check the attributes if the extensibleObject objectClass is
// declared for this entry
Attribute objectClass = entry.get( OBJECT_CLASS_AT );
if ( objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
{
return;
}
for ( Attribute attribute : entry )
{
String attrOid = attribute.getAttributeType().getOid();
AttributeType attributeType = attribute.getAttributeType();
if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
&& !allowed.contains( attrOid ) )
{
throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_277,
attribute.getUpId(), dn.getName() ) );
}
}
}
示例10: getPartition
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Partition getPartition( Dn dn ) throws LdapException
{
Partition parent = null;
if ( !dn.isSchemaAware() )
{
dn.apply( schemaManager );
}
synchronized ( partitionLookupTree )
{
parent = partitionLookupTree.getElement( dn );
}
if ( parent == null )
{
throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_268, dn ) );
}
else
{
return parent;
}
}
示例11: checkMechanism
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Check if the mechanism exists.
*/
private boolean checkMechanism( String saslMechanism ) throws Exception
{
// Guard clause: Reject unsupported SASL mechanisms.
if ( !ldapServer.getSupportedMechanisms().contains( saslMechanism ) )
{
LOG.error( I18n.err( I18n.ERR_160, saslMechanism ) );
return false;
}
else
{
return true;
}
}
示例12: handleSaslAuthPending
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
private void handleSaslAuthPending( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
// First, check that we have the same mechanism
String saslMechanism = bindRequest.getSaslMechanism();
// The empty mechanism is also a request for a new Bind session
if ( Strings.isEmpty( saslMechanism )
|| !ldapSession.getSaslProperty( SaslConstants.SASL_MECH ).equals( saslMechanism ) )
{
sendAuthMethNotSupported( ldapSession, bindRequest );
return;
}
// We have already received a first BindRequest, and sent back some challenge.
// First, check if the mechanism is the same
MechanismHandler mechanismHandler = handlers.get( saslMechanism );
if ( mechanismHandler == null )
{
String message = I18n.err( I18n.ERR_161, saslMechanism );
// Clear the saslProperties, and move to the anonymous state
ldapSession.clearSaslProperties();
ldapSession.setAnonymous();
LOG.error( message );
throw new IllegalArgumentException( message );
}
// Get the previously created SaslServer instance
SaslServer ss = mechanismHandler.handleMechanism( ldapSession, bindRequest );
generateSaslChallengeOrComplete( ldapSession, ss, bindRequest );
}
示例13: DefaultPartitionNexus
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Creates the root nexus singleton of the entire system. The root DSE has
* several attributes that are injected into it besides those that may
* already exist. As partitions are added to the system more namingContexts
* attributes are added to the rootDSE.
*
* @see <a href="http://www.faqs.org/rfcs/rfc3045.html">Vendor Information</a>
* @param rootDse the root entry for the DSA
* @throws javax.naming.Exception on failure to initialize
*/
public DefaultPartitionNexus( Entry rootDse ) throws Exception
{
id = ID;
suffixDn = null;
// setup that root DSE
this.rootDse = rootDse;
// Add the basic informations
rootDse.put( SchemaConstants.SUBSCHEMA_SUBENTRY_AT, ServerDNConstants.CN_SCHEMA_DN );
rootDse.put( SchemaConstants.SUPPORTED_LDAP_VERSION_AT, "3" );
rootDse.put( SchemaConstants.SUPPORTED_FEATURES_AT, SchemaConstants.FEATURE_ALL_OPERATIONAL_ATTRIBUTES );
rootDse.put( SchemaConstants.SUPPORTED_EXTENSION_AT, NoticeOfDisconnect.EXTENSION_OID );
// Add the objectClasses
rootDse.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
// Add the 'vendor' name and version infos
rootDse.put( SchemaConstants.VENDOR_NAME_AT, ASF );
Properties props = new Properties();
try
{
props.load( getClass().getResourceAsStream( "version.properties" ) );
}
catch ( IOException e )
{
LOG.error( I18n.err( I18n.ERR_33 ) );
}
rootDse.put( SchemaConstants.VENDOR_VERSION_AT, props.getProperty( "apacheds.version", "UNKNOWN" ) );
// The rootDSE uuid has been randomly created
rootDse.put( SchemaConstants.ENTRY_UUID_AT, "f290425c-8272-4e62-8a67-92b06f38dbf5" );
}
示例14: getUnion
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Creates a new attribute which contains the values representing the union
* of two attributes. If one attribute is null then the resultant attribute
* returned is a copy of the non-null attribute. If both are null then we
* cannot determine the attribute ID and an {@link IllegalArgumentException}
* is raised.
*
* @param attr0 the first attribute
* @param attr1 the second attribute
* @return a new attribute with the union of values from both attribute
* arguments
* @throws LdapException if there are problems accessing attribute values
*/
public static Attribute getUnion( Attribute attr0, Attribute attr1 ) throws LdapException
{
if ( attr0 == null && attr1 == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_465 ) );
}
else if ( attr0 == null )
{
return attr1.clone();
}
else if ( attr1 == null )
{
return attr0.clone();
}
else if ( !attr0.getAttributeType().equals( attr1.getAttributeType() ) )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_466 ) );
}
Attribute attr = attr0.clone();
for ( Value<?> value : attr1 )
{
attr.add( value );
}
return attr;
}
示例15: eagerlyPopulateFields
import org.apache.directory.server.i18n.I18n; //导入依赖的package包/类
/**
* Eagerly populates fields of operation contexts so multiple Interceptors
* in the processing pathway can reuse this value without performing a
* redundant lookup operation.
*
* @param opContext the operation context to populate with cached fields
*/
private void eagerlyPopulateFields( OperationContext opContext ) throws LdapException
{
// If the entry field is not set for ops other than add for example
// then we set the entry but don't freak if we fail to do so since it
// may not exist in the first place
if ( opContext.getEntry() == null )
{
// We have to use the admin session here, otherwise we may have
// trouble reading the entry due to insufficient access rights
CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();
LookupOperationContext lookupContext = new LookupOperationContext( adminSession, opContext.getDn(),
SchemaConstants.ALL_ATTRIBUTES_ARRAY );
Entry foundEntry = opContext.getSession().getDirectoryService().getPartitionNexus().lookup( lookupContext );
if ( foundEntry != null )
{
opContext.setEntry( foundEntry );
}
else
{
// This is an error : we *must* have an entry if we want to be able to rename.
LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
opContext.getDn() ) );
throw ldnfe;
}
}
}