• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.vpn;
18 
19 import android.net.vpn.L2tpIpsecProfile;
20 import android.security.Credentials;
21 
22 import java.io.IOException;
23 
24 /**
25  * The service that manages the certificate based L2TP-over-IPSec VPN connection.
26  */
27 class L2tpIpsecService extends VpnService<L2tpIpsecProfile> {
28     private static final String IPSEC = "racoon";
29 
30     @Override
connect(String serverIp, String username, String password)31     protected void connect(String serverIp, String username, String password)
32             throws IOException {
33         L2tpIpsecProfile p = getProfile();
34         VpnDaemons daemons = getDaemons();
35 
36         // IPSEC
37         DaemonProxy ipsec = daemons.startIpsecForL2tp(serverIp,
38                 Credentials.USER_PRIVATE_KEY + p.getUserCertificate(),
39                 Credentials.USER_CERTIFICATE + p.getUserCertificate(),
40                 Credentials.CA_CERTIFICATE + p.getCaCertificate());
41         ipsec.closeControlSocket();
42 
43         sleep(2000); // 2 seconds
44 
45         // L2TP
46         daemons.startL2tp(serverIp,
47                 (p.isSecretEnabled() ? p.getSecretString() : null),
48                 username, password);
49     }
50 }
51