{@inheritDoc}

@param objectClass
@param username
@param password
@param options
@return
188626
@Override
    public Uid authenticate(
            final ObjectClass objectClass,
            final String username,
            final GuardedString password,
            final OperationOptions options) {

        LOG.ok("User uthentication");

        // check objectclass
        if (objectClass == null || (!objectClass.equals(ObjectClass.ACCOUNT))) {
            throw new IllegalArgumentException("Invalid objectclass");
        }

        // check creadentials
        if (username == null || password == null) {
            throw new IllegalArgumentException("Invalid credentuals");
        }

        // get web service client
        final Provisioning provisioning = connection.getProvisioning();
        if (provisioning == null) {
            throw new IllegalStateException("Web Service client not found");
        }

        try {
            return new Uid(provisioning.authenticate(username, password.toString()));
        } catch (ProvisioningException e) {
            throw new ConnectorException("Authentication failed", e);
        } catch (Throwable t) {
            throw new ConnectorException("Communication exception", t);
        }
    }
818184
@Override
    public Object getObjectInstance(Object o, Name n, Context c, Hashtable<?, ?> envmt) throws Exception {

        if (tc.isEntryEnabled()) {
            Tr.entry(tc, "getObjectInstance: o=" + o + ",name=" + n + ",context=" + c + ",evnmt=" + envmt);
        }

        if (!(o instanceof Reference)) {
            if (tc.isEntryEnabled()) {
                Tr.exit(tc, "Object " + o + " is not an instance of javax.naming.Reference. Returning null.");
            }
            return null;
        }
        Reference ref = (Reference) o;
        final Class<?> contextClass = Class.forName(ref.getClassName());
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Creating a proxy for type {0}", contextClass);
        Object proxy = null;

        if (Application.class.equals(contextClass)) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "This is an Application sub-class being injected. Injecting an instance of ApplicationInjectionProxy.");
            }
            proxy = new ApplicationInjectionProxy();
        } else if (HttpServletRequest.class.equals(contextClass)) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "This is an HttpServletRequest sub-class being injected. Injecting an instance of HttpServletRequestInjectionProxy.");
            }
            proxy = new HttpServletRequestInjectionProxy();
        } else if (HttpServletResponse.class.equals(contextClass)) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "This is an HttpServletResponse sub-class being injected. Injecting an instance of HttpServletResponseInjectionProxy.");
            }
            proxy = new HttpServletResponseInjectionProxy();
        } else {
            proxy = Proxy.newProxyInstance(priv.getClassLoader(contextClass),
                                           new Class[] { contextClass },
                                           new InvocationHandler() {
                                               @Override
                                               public Object invoke(Object proxy,
                                                                    Method method,
                                                                    Object[] args) throws Throwable {
                                                   // Without these entry and exit calls RAS uses bytecode injection
                                                   // to insert Tr.entry on first line of this method and then Tr.exit
                                                   // on last lie. Tr.entry attempts to call proxy.toString(), which
                                                   // loops back to the invoke method again--hence resulting in a
                                                   // StackOverflowError
                                                   if (tc.isEntryEnabled()) {
                                                       Tr.entry(tc, "invoke");
                                                   }

                                                   Object result = null;
                                                   // use runtimeContext from TLS
                                                   InjectionRuntimeContext runtimeContext = InjectionRuntimeContextHelper.getRuntimeContext();

                                                   if ("toString".equals(method.getName()) && (method.getParameterTypes().length == 0)) {
                                                       result = "Proxy for " + contextClass.getName();
                                                       if (tc.isEntryEnabled()) {
                                                           Tr.exit(tc, "invoke", result);
                                                       }
                                                       return result;
                                                   }

                                                   // get the real context from the RuntimeContext
                                                   Object context = runtimeContext.getRuntimeCtxObject(contextClass.getName());
                                                   if (context != null) {
                                                       result = method.invoke(context, args);
                                                   }

                                                   if (tc.isEntryEnabled()) {
                                                       Tr.exit(tc, "invoke", result);
                                                   }
                                                   // invoke the method on the real context
                                                   return result;
                                               }
                                           });
        }

        if (tc.isEntryEnabled()) {
            Tr.exit(tc, "getObjectInstance", proxy);
        }

        return proxy;

    }
629949
public function connection($username, $password, array $options)
    {
        if ($this->pdo)
        {
            throw new \BadFunctionCallException(__METHOD__);
        }

        $class     = $this->class;
        $this->pdo = new $class($this->dsn(), $username, $password, $options);

        return $this->pdo;
    }
919470
@Override
    public boolean login() throws LoginException {
        try{
            Object[] userPass= getCallBackAuth();
            if (null == userPass || userPass.length < 2) {
                setAuthenticated(false);
                throw new FailedLoginException();
            }
            String name = (String) userPass[0];
            Object pass = userPass[1];
            boolean authenticated = authenticate(name, pass);
            setAuthenticated(authenticated);

            if (!isAuthenticated()) {
                throw new FailedLoginException();
            }
            return isAuthenticated();
        } catch (UnsupportedCallbackException e) {
            throw new LoginException("Error obtaining callback information.");
        } catch (IOException e) {
            if (_debug) {
                e.printStackTrace();
            }
            throw new LoginException("IO Error performing login.");
        }
    }
803514
public static List toList( JSONArray jsonArray, Class objectClass ) {
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.setRootClass( objectClass );
      return toList( jsonArray, jsonConfig );
   }
1317342
public Object makeObjectFromClassName(String className, String version, boolean bErrorIfNotFound) throws RuntimeException
    {
        if (className == null)
            return null;
        className = ClassServiceUtility.getFullClassName(className);

        Class<?> clazz = null;
        try {
            clazz = Class.forName(className);
        } catch (ClassNotFoundException e) {
            if (this.getClassFinder(null) != null)
                clazz = this.getClassFinder(null).findClass(className, version);	// Try to find this class in the obr repos
            if (clazz == null)
                if (bErrorIfNotFound)
                    throw new RuntimeException(e.getMessage());
        }

        Object object = null;
        try {
            if (clazz != null)
                object = clazz.newInstance();
        } catch (InstantiationException e)   {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        } catch (IllegalAccessException e)   {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        } catch (Exception e) {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        }
        return object;
    }
1121021
public static MOAObject fromOption(ClassOption option) {
  	return MOAUtils.fromCommandLine(option.getRequiredType(), option.getValueAsCLIString());
  }
859031
private static ObjectSchema readSchema(String url, String user, String pass,
            SyntaxToJavaClass syntaxToJavaClass, Set<String> binarySet, Set<String> objectClasses) 
        throws NamingException, ClassNotFoundException {
        
        // Set up environment 
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.PROVIDER_URL, url);
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        if (user != null) {
            env.put(Context.SECURITY_PRINCIPAL, user);
        }
        if (pass != null) {
            env.put(Context.SECURITY_CREDENTIALS, pass);
        }

        DirContext context = new InitialDirContext(env);
        DirContext schemaContext = context.getSchema("");
        SchemaReader reader = new SchemaReader(schemaContext, syntaxToJavaClass, binarySet);
        ObjectSchema schema = reader.getObjectSchema(objectClasses);
        
        if (LOG.isDebugEnabled()) {
            LOG.debug(String.format("Schema - %1$s", schema.toString()));
        }
        
        return schema;  
    }
22582
public function findEventObjects(string $objectClass, string $uuid, int $max_version = null, int $min_version = null, int $user = null): array
    {
        $criteria = new Criteria();

        $criteria->where(Criteria::expr()->eq('uuid', $uuid));

        if (null !== $max_version) {
            $criteria->andWhere(Criteria::expr()->lte('version', $max_version));
        }

        if (null !== $min_version) {
            $criteria->andWhere(Criteria::expr()->gte('version', $min_version));
        }

        if (null !== $user) {
            $criteria->andWhere(Criteria::expr()->eq('user', $user));
        }

        $criteria->orderBy(['version' => Criteria::ASC]);

        $eventObjectsResults = $this->em->getRepository($objectClass)->matching($criteria);

        return $eventObjectsResults ? $eventObjectsResults->toArray() : [];
    }
398744
@Override
    public Uid create(
            final ObjectClass objClass,
            final Set<Attribute> attrs,
            final OperationOptions options) {

        LOG.ok("Account creation");

        // check objectclass
        if (objClass == null || (!objClass.equals(ObjectClass.ACCOUNT))) {
            throw new IllegalArgumentException("Invalid objectclass");
        }

        // check attributes
        if (attrs == null || attrs.isEmpty()) {
            throw new IllegalArgumentException("No attribute specified");
        }

        // get web service client
        final Provisioning provisioning = connection.getProvisioning();
        if (provisioning == null) {
            throw new IllegalStateException("Web Service client not found");
        }

        // get account name
        final Name name = AttributeUtil.getNameFromAttributes(attrs);
        if (name == null) {
            throw new IllegalArgumentException("No name specified");
        }

        LOG.ok("Account to be created: " + name.getNameValue());

        // to be user in order to pass information to the web service
        final List<WSAttributeValue> attributes = new ArrayList<WSAttributeValue>();

        // retrieve attributes
        for (Attribute attr : attrs) {
            final WSAttribute wsAttribute = new WSAttribute(attr.getName());

            if (attr.is(Name.NAME)) {
                wsAttribute.setKey(true);
                wsAttribute.setNullable(false);
            }

            if (attr.is(OperationalAttributeInfos.PASSWORD.getName())) {
                wsAttribute.setName(OperationalAttributeInfos.PASSWORD.getName());
                wsAttribute.setPassword(true);
            }

            if (LOG.isOk()) {
                LOG.ok(
                        "\nAttribute: "
                        + "\n\tName: " + wsAttribute.getName()
                        + "\n\tType: " + wsAttribute.getType()
                        + "\n\tIsKey: " + wsAttribute.isKey()
                        + "\n\tIsPassword: " + wsAttribute.isPassword());
            }

            final WSAttributeValue wsAttributeValue = new WSAttributeValue(wsAttribute);
            attributes.add(wsAttributeValue);

            final List<Object> value = attr.getValue();
            if (value != null && value.size() == 1
                    && (value.get(0) instanceof GuardedString || value.get(0) instanceof GuardedByteArray)) {

                wsAttributeValue.addValue(value.toString());
            } else {
                wsAttributeValue.setValues(value);
            }
        }

        LOG.ok("\nUser " + name.getNameValue() + "\n\tattributes: " + attributes.size());

        try {
            // user creation
            provisioning.create(attributes);
        } catch (ProvisioningException e) {
            throw new ConnectorException("Creation failed", e);
        } catch (Throwable t) {
            throw new ConnectorException("Communication exception", t);
        }

        // return Uid
        return new Uid(name.getNameValue());
    }
1334241
public static Map<String, String> createBasicAuthenticationProperty(final String username, final String password) {
        Map<String, String> map = new TreeMap<String, String>();
        try {
            String base64Binary = DatatypeConverter.printBase64Binary((username + ":" + password).getBytes("US-ASCII"));
            map.put("Authorization", "Basic " + base64Binary);
        } catch (UnsupportedEncodingException e) {
            // unreachable code
            throw new RuntimeException(e);
        }
        return map;
    }
1171720
public Login login(String username, String password) throws Exception {
    return login(username, password, null);
  }
758670
public static ObjectName getSystemObjectName(final String domainName,
                                               final String containerName,
                                               final Class theClass) throws MalformedObjectNameException {
    String tmp = domainName + ":" +
                 "type=" + theClass.getName() +
                 ",name=" + getRelativeName(containerName, theClass);
    return new ObjectName(tmp);
  }
390568
public String login(String loginName, String password) throws AuthException{
    String loginResult = null;
    try{
      Debug.logVerbose("[JdonFramework] --> enter login", module);

      TargetMetaDef targetMetaDef = new POJOTargetMetaDef("authenticator",
           "com.jdon.bussinessproxy.remote.auth.Authenticator");

      Authenticator authenticator = (Authenticator) getService(targetMetaDef);
      loginResult = authenticator.login(loginName, password);
    }catch(Exception e){
      throw new AuthException(e);
    }
    return loginResult;

  }
579269
protected UserDetails authenticateUser(String username, String password, HttpRequest authRequest) throws AuthenticationException {
        UserDetails userDetails;
        IUserAuthentication ua;
        if (OAuthConfig.getUserAuthenticationClass() != null) {
            try {
                ua = OAuthConfig.getUserAuthenticationClass().newInstance();
                userDetails = ua.authenticate(username, password, authRequest);
            } catch (InstantiationException | IllegalAccessException e) {
                LOG.error("cannot instantiate user authentication class", e);
                throw new AuthenticationException(e.getMessage());
            }
        } else {
            // if no specific UserAuthentication used, always returns customerId - 12345
            userDetails = new UserDetails("12345", null);
        }
        return userDetails;
    }
587424
@ReadOperation
    public Map<String, Object> handle(final String username,
                                      final String password,
                                      final String service) {

        val selectedService = this.serviceFactory.createService(service);
        val registeredService = this.servicesManager.findServiceBy(selectedService);

        val credential = new UsernamePasswordCredential(username, password);
        val result = this.authenticationSystemSupport.handleAndFinalizeSingleAuthenticationTransaction(selectedService, credential);
        val authentication = result.getAuthentication();

        val principal = authentication.getPrincipal();
        val attributesToRelease = registeredService.getAttributeReleasePolicy().getAttributes(principal, selectedService, registeredService);
        val principalId = registeredService.getUsernameAttributeProvider().resolveUsername(principal, selectedService, registeredService);
        val modifiedPrincipal = this.principalFactory.createPrincipal(principalId, attributesToRelease);
        val builder = DefaultAuthenticationBuilder.newInstance(authentication);
        builder.setPrincipal(modifiedPrincipal);
        val finalAuthentication = builder.build();

        val samlResponse = this.samlResponseBuilder.createResponse(selectedService.getId(), selectedService);
        samlResponseBuilder.prepareSuccessfulResponse(samlResponse, selectedService, finalAuthentication, principal,
            finalAuthentication.getAttributes(), principal.getAttributes());

        val resValidation = new LinkedHashMap<String, Object>();
        val encoded = SamlUtils.transformSamlObject(this.openSamlConfigBean, samlResponse).toString();
        resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_ASSERTION, encoded);
        resValidation.put(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE, selectedService);
        resValidation.put("registeredService", registeredService);

        return resValidation;
    }
96461
public Session login(final String username, final String password) throws RepositoryException {
        assertStateAfterOrEqual(State.CREATED);
        if (!userSessions.containsKey(username)) {
            userSessions.put(username, getRepository().login(new SimpleCredentials(username, password.toCharArray())));
        }
        return userSessions.get(username);
    }