diff --git a/db/StoredProcedures.sql b/db/StoredProcedures.sql
index 3ebe064c2e6362398e970d8d6ade43424c13fd00..182126f84fcdc8da2e05c61c61a36aefdbb3b1dc 100644
--- a/db/StoredProcedures.sql
+++ b/db/StoredProcedures.sql
@@ -4364,4 +4364,65 @@ BEGIN
 	RETURN 1;
 END //
 
+DROP PROCEDURE IF EXISTS CreateFaculty //
+CREATE PROCEDURE CreateFaculty (IN pFacultyName VARCHAR(100) CHARSET utf8, IN pFacultyAbbr VARCHAR(20) CHARSET utf8)
+	NO SQL
+BEGIN
+	INSERT INTO faculties (Name, Abbr) 
+		VALUES(pFacultyName, pFacultyAbbr);
+END //
+
+DROP PROCEDURE IF EXISTS GetSession //
+CREATE PROCEDURE GetSession (IN pID INT(11), OUT pSessionID VARCHAR(40), OUT pUserLogin VARCHAR(50) CHARSET utf8, OUT pUserPassword VARCHAR(64))
+	NO SQL
+BEGIN
+
+	SELECT SessionID, Login, Password 
+		INTO pSessionID, pUserLogin, pUserPassword
+		FROM sessions
+		WHERE sessions.ID=pID;
+END //
+
+DROP FUNCTION IF EXISTS DeleteSubject //
+CREATE FUNCTION DeleteSubject (pSubjectID INT) RETURNS INT(11)
+	NO SQL
+BEGIN
+	DECLARE discCount INT;
+	SELECT COUNT(*) INTO discCount 
+		FROM disciplines 
+		WHERE disciplines.SubjectID=pSubjectID;
+	IF discCount>0 THEN
+		RETURN -1; -- "Удаляемый предмет используется в disciplines.";
+	END IF;
+	DELETE FROM subjects_faculties 
+		WHERE subjects_faculties.SubjectID=pSubjectID;
+	DELETE FROM subjects 
+		WHERE subjects.ID=pSubjectID;
+	RETURN 0; -- "Успешно удалено.";
+END //
+
+DROP FUNCTION IF EXISTS CreateDepartment //
+CREATE FUNCTION CreateDepartment(pName VARCHAR(200) CHARSET utf8, pFacultyID INT(11)) RETURNS INT(11)
+	NO SQL
+BEGIN
+	DECLARE facultyExist INT;
+	SELECT COUNT(*) INTO facultyExist 
+		FROM faculties 
+		WHERE faculties.ID=pFacultyID;
+	IF facultyExist>0 THEN
+		INSERT INTO departments (Name, FacultyID) VALUES(pName, pFacultyID);
+		RETURN 0;
+	END IF;
+	RETURN -1;
+END //
+
+DROP FUNCTION IF EXISTS SaveSession //
+CREATE FUNCTION SaveSession(pSessionID VARCHAR(40), pUserLogin VARCHAR(50) CHARSET utf8, pUserPassword VARCHAR(64)) RETURNS INT(11)
+	NO SQL
+BEGIN
+	INSERT INTO sessions (SessionID, Login, Password) 
+		VALUES(pSessionID, pUserLogin, pUserPassword);
+	RETURN LAST_INSERT_ID();;
+END //
+
 DELIMITER ;
\ No newline at end of file
diff --git a/~dev_rating/application/bootstrap.php b/~dev_rating/application/bootstrap.php
index 1f913902e38389f2c2d1c91a47f98dd51ee79aca..192a23d4b76e2e6d0a44b178920eb36334d10bda 100644
--- a/~dev_rating/application/bootstrap.php
+++ b/~dev_rating/application/bootstrap.php
@@ -351,4 +351,10 @@ Route::set('dean_office:index', 'dean_office')
             'directory' => 'DeanOffice',
             'controller' => 'index',
             'action' => 'index'
-        ));
\ No newline at end of file
+        ));
+		
+/* --------------- Java session provider -------------- */
+Route::set('javaSessionProvider', 'java_authentication')
+	->defaults(array(
+		'controller' => 'JavaAuthentication',
+		'action' => 'authentication',));
\ No newline at end of file
diff --git a/~dev_rating/application/classes/Controller/JavaAuthentication.php b/~dev_rating/application/classes/Controller/JavaAuthentication.php
new file mode 100644
index 0000000000000000000000000000000000000000..bff4dc4f8f77523b3987951a78aa6c20cd78fcf4
--- /dev/null
+++ b/~dev_rating/application/classes/Controller/JavaAuthentication.php
@@ -0,0 +1,119 @@
+<?php defined('SYSPATH') or die('No direct script access.');
+
+class Controller_JavaAuthentication extends Controller
+{
+	
+	public function action_authentication()
+	{
+		
+		//$secretKey="r1SsaFw@WQgRmR6c";
+		$session=Session::Instance();
+		/*$data = $session->as_array();
+		$length=count($data);
+		echo "length=".$length."<br/>";
+		
+		echo $session;
+		echo "session=".$session->get('start_time')."<br/>";*/
+		//echo "session id=".session_id()."<br/>";
+		
+		/*for($i=0; $i<$length; ++$i)
+			echo $data[$i]."<br/>";*/
+		$outStr="";
+		$outStr=$outStr.session_id().'<br/>';
+		$user=User::instance();
+		$userInfo=$user->getInfoAsArray();
+		$outStr=$outStr."length=".count($userInfo)."<br/>";
+		if($user->isSignedIn())
+			foreach($userInfo as $key => $value) 
+			{ 
+				$outStr=$outStr."$key = $value <br />"; 
+			}
+		else
+			$outStr=$outStr."user is not signed";
+		
+		//echo User::instance()->php();
+		
+		/*if(User::instance()->isSignedIn())
+		{
+		switch($_POST["authType"])
+		{
+		case "getSessionId":
+			$s_id="1".session_id();
+			$userLogin="userLogin";
+			$userPassword="userPassword";
+			
+			$response="{\"session_hash\": \"".md5($s_id.$secretKey)."\",";
+			$sql = "SELECT `SaveSession`('$s_id', '$userLogin', '$userPassword') AS `Num`;";
+			$res = DB::query(Database::SELECT, $sql)->execute();
+			$response=$response." \"record_id\": ".$res[0]['Num']."}";
+			echo $response;
+			return;
+		break;
+		default:
+		}
+		}*/
+		
+		/*$s_id=session_id();
+		$userLogin="userLogin";
+		$userPassword="userPassword";
+			
+		$response="{\"session_hash\": \"".md5($s_id.$secretKey)."\",";
+		$sql = "SELECT `SaveSession`('$s_id', '$userLogin', '$userPassword') AS `Num`;";
+		$res = DB::query(Database::SELECT, $sql)->execute();
+		$response=$response." \"record_id\": ".$res[0]['Num']."}";
+		//echo $response;*/
+			
+		/*$twig = Twig::factory('teacher/javaAuth');
+		$twig->SendUrl=$_GET["resUrl"];
+		$twig->Session=session_id();
+		$twig->RecordId=$res[0]['Num'];
+		$twig->SessionHash=md5($s_id.$secretKey);
+		$twig->Out=$outStr;
+		$this->response->body($twig);*/
+
+		//echo $outStr;
+		
+		$secretKey="r1SsaFw@WQgRmR6c";
+		$session=Session::instance();
+		$user=User::instance();
+		$userInfo=$user->getInfoAsArray();
+		if($user->isSignedIn())
+		{
+			//echo "sign<br/>";
+			if(array_key_exists ("authType", $_GET) && $_GET["authType"]=="authJavaUser")
+			{
+				//echo "authType=".$_GET["authType"]."<br/>";
+				if(array_key_exists ("openKey", $_GET) && array_key_exists ("resUrl", $_GET))
+				{
+					//echo "Open and res:";
+					//echo $_GET["openKey"]." ".$_GET["resUrl"]."<br/>";
+					$openKey=$_GET["openKey"];
+					$s_id=session_id();
+					$userLogin=$userInfo["Login"];
+					$userPassword=$userInfo["Last"].$userInfo["First"];
+					
+					//$response="{\"session_hash\": \"".md5($s_id.$secret_key)."\",";
+					//echo "SELECT `SaveSession`('$s_id', '$userLogin', '$userPassword') AS `Num`;";
+					
+					/*echo "String for hash:".$secretKey.$openKey.$userLogin.$userPassword."<br/>";
+					echo "Hash:".md5($secretKey.$openKey.$userLogin.$userPassword)."<br/>";*/
+					
+					$sql = "SELECT `SaveSession`('$s_id', '$userLogin', '$userPassword') AS `Num`;";
+					$res = DB::query(Database::SELECT, $sql)->execute();
+					
+					$recordId=$res[0]['Num'];
+					
+					$twig = Twig::factory('teacher/javaAuth');
+					$twig->SendUrl=$_GET["resUrl"];
+					$twig->RecordId=$recordId;
+					$twig->UserHash=md5($s_id.$secretKey.$openKey);
+					$this->response->body($twig);
+					//$response=$response." \"record_id\": ".$res[0]['Num']."}";
+				}
+			}
+		}
+		else
+			$this->redirect('sign', 302);
+	}
+}
+	
\ No newline at end of file
diff --git a/~dev_rating/application/views/teacher/javaAuth.twig b/~dev_rating/application/views/teacher/javaAuth.twig
new file mode 100644
index 0000000000000000000000000000000000000000..ee2b6d93b27d5822591269110dfbd043249a1011
--- /dev/null
+++ b/~dev_rating/application/views/teacher/javaAuth.twig
@@ -0,0 +1,24 @@
+<html>
+<head>
+{% block media %} {# head -> css, js #}
+	{{ HTML.script('media/js/jquery-1.9.1.min.js')|raw }}
+	{{ HTML.script('media/js/javaAuth.js')|raw }}
+{% endblock %}
+	<script>
+		$(document).ready(function()
+		{
+			$("#sendForm").submit();
+		});
+	</script>
+</head>
+
+<body>
+	<!--<div>Session={{ Session }}</div>
+	<div>OutStr={{ Out }}</div>-->
+	<form id="sendForm" method="POST" action="{{ SendUrl }}">
+		<input name="actionType" hidden value="auth"/>
+		<input name="recordId" hidden value="{{ RecordId }}"/>
+		<input name="userHash" hidden value="{{ UserHash }}"/>
+	</form>
+</body>
+</html>
\ No newline at end of file