private Entry getEntry( OperationContext opContext ) throws LdapException { /** * Exclude operational attributes while doing lookup * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, modifiedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
/** * Gets attributes required for modifications. * * @param dn the dn of the entry to get * @return the entry's attributes (may be immutable if the schema subentry) * @throws Exception on error accessing the entry's attributes */ private Entry getAttributes( OperationContext opContext ) throws LdapException { Dn dn = opContext.getDn(); Entry serverEntry; // @todo make sure we're not putting in operational attributes that cannot be user modified if ( dn.equals( ServerDNConstants.CN_SCHEMA_DN ) ) { return SchemaService.getSubschemaEntryCloned( directoryService ); } else { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); serverEntry = directoryService.getPartitionNexus().lookup( lookupContext ); } return serverEntry; } }
/** * Checks to see if subentries for the search and list operations should be * made visible based on the availability of the search request control * * @param opContext the invocation object to use for determining subentry visibility * @return true if subentries should be visible, false otherwise * @throws Exception if there are problems accessing request controls */ private boolean isSubentryVisible( OperationContext opContext ) throws LdapException { if ( !opContext.hasRequestControls() ) { return false; } // found the subentry request control so we return its value if ( opContext.hasRequestControl( SUBENTRY_CONTROL ) ) { SubentriesDecorator subentriesDecorator = ( SubentriesDecorator ) opContext .getRequestControl( SUBENTRY_CONTROL ); return subentriesDecorator.getDecorated().isVisible(); } return false; }
/** * Check if the current operation has a valid PrincipalDN or not. * * @param operation the operation type * @throws Exception */ private void checkAuthenticated( OperationContext operation ) throws LdapException { if ( operation.getSession().isAnonymous() && !directoryService.isAllowAnonymousAccess() && !operation.getDn().isEmpty() ) { String msg = I18n.err( I18n.ERR_5, operation.getName() ); LOG.error( msg ); throw new LdapNoPermissionException( msg ); } }
/** * Returns {@link LdapPrincipal} of current context. * * @param opContext TODO * @return the authenticated principal */ public static LdapPrincipal getPrincipal( OperationContext opContext ) { return opContext.getSession().getEffectivePrincipal(); }
String modifiersName = opContext.getSession().getEffectivePrincipal().getName(); String modifyTimestamp = DateUtils.getGeneralizedTime(); CoreSession session = opContext.getSession(); ModifyOperationContext modifyContext = new ModifyOperationContext( session, schemaModificationDN, mods ); modifyContext.setPartition( this ); modifyContext.setTransaction( opContext.getTransaction() );
/** * checks to see if the user's password should be changed before performing any operations * other than bind, password update, unbind, abandon or StartTLS * * @param opContext the operation's context * @throws LdapException */ private void checkPwdReset( OperationContext opContext ) throws LdapException { if ( directoryService.isPwdPolicyEnabled() ) { CoreSession session = opContext.getSession(); if ( session.isPwdMustChange() ) { boolean isPPolicyReqCtrlPresent = opContext .hasRequestControl( PasswordPolicy.OID ); if ( isPPolicyReqCtrlPresent ) { PasswordPolicyDecorator pwdRespCtrl = new PasswordPolicyDecorator( directoryService.getLdapCodecService(), true ); pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET ); opContext.addResponseControl( pwdRespCtrl ); } throw new LdapNoPermissionException( "password needs to be reset before performing this operation" ); } } }
Subordinates subordinates = partition.getSubordinates( operationContext.getTransaction(), entry );
private ReplicaEventLog getEventLog( OperationContext opCtx ) { Dn consumerLogDn = opCtx.getDn(); String name = ReplicaEventLog.REPLICA_EVENT_LOG_NAME_PREFIX + consumerLogDn.getRdn().getValue(); for ( ReplicaEventLog log : replicaLogMap.values() ) { if ( name.equalsIgnoreCase( log.getName() ) ) { return log; } } // end of for return null; }
private void internalModify( OperationContext opContext, ModifyOperationContext bindModCtx ) throws LdapException Partition partition = opContext.getPartition(); bindModCtx.setPartition( partition ); PartitionTxn partitionTxn = null;
/** * Extracts request controls from a request to populate into an * OperationContext. * * @param opContext the context to populate with request controls * @param request the request to extract controls from */ public static void setRequestControls( OperationContext opContext, Request request ) { if ( request.getControls() != null ) { opContext .addRequestControls( request.getControls().values().toArray( LdapProtocolConstants.EMPTY_CONTROLS ) ); } }
protected Dn getOperationPrincipal() throws LdapInvalidDnException { Principal principal = opContext.getSession().getEffectivePrincipal(); return opContext.getSession().getDirectoryService().getDnFactory().create( principal.getName() ); }
private Entry getDeletedEntry( OperationContext opContext ) throws LdapException { /** * Using LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS here to exclude operational attributes * especially subentry related ones like "triggerExecutionSubentries". */ CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, deletedEntryName, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } }
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } ); SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), baseDn, filter, controls ); searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES ); searchOperationContext.setPartition( opContext.getPartition() ); searchOperationContext.setTransaction( opContext.getTransaction() ); modifications = getOperationalModsForRemove( opContext.getDn(), candidate ); break; LOG.debug( "The entry {} has been evaluated to true for subentry {}", candidate.getDn(), opContext.getDn() ); ModifyOperationContext modifyContext = new ModifyOperationContext( opContext.getSession(), candidateDn, modifications ); modifyContext.setPartition( opContext.getPartition() ); modifyContext.setTransaction( opContext.getTransaction() );
private Object executeProcedure( OperationContext opContext, String procedure, Object[] values ) throws LdapException { try { Entry spUnit = manager.findStoredProcUnit( opContext.getSession(), procedure ); StoredProcEngine engine = manager.getStoredProcEngineInstance( spUnit ); return engine.invokeProcedure( opContext.getSession(), procedure, values ); } catch ( Exception e ) { LdapOtherException lne = new LdapOtherException( e.getMessage(), e ); lne.initCause( e ); throw lne; } } }
@Override public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapException { Generic_LDAP_CONTEXT ldapCtxParam = ( Generic_LDAP_CONTEXT ) param; Dn ldapCtxName = ldapCtxParam.getCtxName(); CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, ldapCtxName, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); return session.getDirectoryService().getPartitionNexus().lookup( lookupContext ); } };
public boolean hasPermission( OperationContext opContext ) throws LdapException { Dn principalName = opContext.getSession().getEffectivePrincipal().getDn(); return principalName.equals( opContext.getSession().getDirectoryService().getAdminSession() .getAuthenticatedPrincipal().getDn() ); } }
/** * Get the administrativePoint role */ private void checkAdministrativeRole( OperationContext opContext, Dn apDn ) throws LdapException { CoreSession session = opContext.getSession(); LookupOperationContext lookupContext = new LookupOperationContext( session, apDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ); lookupContext.setPartition( opContext.getPartition() ); lookupContext.setTransaction( opContext.getTransaction() ); Entry administrationPoint = directoryService.getPartitionNexus().lookup( lookupContext ); // The administrativeRole AT must exist and not be null Attribute administrativeRole = administrationPoint.get( directoryService.getAtProvider() .getAdministrativeRole() ); // check that administrativeRole has something valid in it for us if ( ( administrativeRole == null ) || ( administrativeRole.size() <= 0 ) ) { LOG.error( "The entry on {} is not an AdministrativePoint", apDn ); throw new LdapNoSuchAttributeException( I18n.err( I18n.ERR_306, apDn ) ); } }
public Object inject( OperationContext opContext, StoredProcedureParameter param ) throws LdapInvalidDnException { // Return a safe copy constructed with user provided name. return opContext.getSession().getDirectoryService().getDnFactory().create( oldDn.getName() ); } };
controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), name, filter, controls ); searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES ); searchOperationContext.setTransaction( opContext.getTransaction() ); searchOperationContext.setPartition( opContext.getPartition() );