index
int64 0
0
| repo_id
stringlengths 9
205
| file_path
stringlengths 31
246
| content
stringlengths 1
12.2M
| __index_level_0__
int64 0
10k
|
---|---|---|---|---|
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteAddPrincipalCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
/**
* Remote add principal command
*/
public class RemoteAddPrincipalCommand extends RemoteCommand {
public static final String USAGE = "Usage: add_principal [options] <principal-name>\n"
+ "\toptions are:\n"
+ "\t\t[-randkey|-nokey]\n"
+ "\t\t[-pw password]"
+ "\tExample:\n"
+ "\t\tadd_principal -pw mypassword alice\n";
public RemoteAddPrincipalCommand(AdminClient adminClient) {
super(adminClient);
}
@Override
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
if (items.length < 2) {
System.err.println(USAGE);
return;
}
String adminRealm = adminClient.getAdminConfig().getAdminRealm();
String clientPrincipal = items[items.length - 1] + "@" + adminRealm;
if (!items[1].startsWith("-")) {
adminClient.requestAddPrincipal(clientPrincipal);
} else if (items[1].startsWith("-nokey")) {
adminClient.requestAddPrincipal(clientPrincipal);
} else if (items[1].startsWith("-pw")) {
String password = items[2];
adminClient.requestAddPrincipal(clientPrincipal, password);
} else {
System.err.println("add_principal command format error.");
System.err.println(USAGE);
}
}
}
| 0 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteListPrincsCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
import java.util.List;
public class RemoteListPrincsCommand extends RemoteCommand {
private static final String USAGE = "Usage: list_principals [expression]\n"
+ "\t'expression' is a shell-style glob expression that can contain the wild-card characters ?, *, and []."
+ "\tExample:\n"
+ "\t\tlist_principals [expression]\n";
public RemoteListPrincsCommand(AdminClient adminClient) {
super(adminClient);
}
@Override
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
//String param = items[0];
if (items.length > 2) {
System.err.println(USAGE);
return;
}
List<String> principalLists = null;
if (items.length == 1) {
principalLists = adminClient.requestGetprincs();
} else {
//have expression
String exp = items[1];
principalLists = adminClient.requestGetprincsWithExp(exp);
}
if (principalLists.size() == 0 || principalLists.size() == 1 && principalLists.get(0).isEmpty()) {
return;
} else {
System.out.println("Principals are listed:");
for (String principal : principalLists) {
System.out.println(principal);
}
}
}
}
| 1 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteDeletePrincipalCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
import java.io.Console;
import java.util.Scanner;
/**
* Remote delete principal command
*/
public class RemoteDeletePrincipalCommand extends RemoteCommand {
public static final String USAGE = "Usage: delete_principal <principal-name>\n"
+ "\tExample:\n"
+ "\t\tdelete_principal alice\n";
public RemoteDeletePrincipalCommand(AdminClient adminClient) {
super(adminClient);
}
@Override
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
if (items.length < 2) {
System.err.println(USAGE);
return;
}
String principal = items[items.length - 1] + "@"
+ adminClient.getAdminConfig().getAdminRealm();
String reply;
Console console = System.console();
String prompt = "Are you sure to delete the principal? (yes/no, YES/NO, y/n, Y/N) ";
if (console == null) {
System.out.println("Couldn't get Console instance, "
+ "maybe you're running this from within an IDE. "
+ "Use scanner to read password.");
Scanner scanner = new Scanner(System.in, "UTF-8");
reply = getReply(scanner, prompt);
} else {
reply = getReply(console, prompt);
}
if (reply.equals("yes") || reply.equals("YES") || reply.equals("y") || reply.equals("Y")) {
adminClient.requestDeletePrincipal(principal);
} else if (reply.equals("no") || reply.equals("NO") || reply.equals("n") || reply.equals("N")) {
System.out.println("Principal \"" + principal + "\" not deleted.");
} else {
System.err.println("Unknown request, fail to delete the principal.");
System.err.println(USAGE);
}
}
private String getReply(Scanner scanner, String prompt) {
System.out.println(prompt);
return scanner.nextLine().trim();
}
private String getReply(Console console, String prompt) {
console.printf(prompt);
String line = console.readLine();
return line;
}
}
| 2 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
/**
* Abstract class of all remote kadmin commands
*/
public abstract class RemoteCommand {
AdminClient adminClient;
public RemoteCommand(AdminClient adminClient) {
this.adminClient = adminClient;
}
/**
* Execute the remote kadmin command
* @param input String includes commands
* @throws KrbException If there is an a problem executing the remote command
*/
public abstract void execute(String input) throws KrbException;
}
| 3 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteGetPrincipalCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
import org.apache.kerby.kerberos.kerb.request.KrbIdentity;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
public class RemoteGetPrincipalCommand extends RemoteCommand {
private static final String USAGE = "Usage: getprinc principalName\n"
+ "\tExample:\n"
+ "\t\tgetprinc hello@TEST.COM\n";
public RemoteGetPrincipalCommand(AdminClient adminClient) {
super(adminClient);
}
@Override
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
if (items.length != 2) {
System.err.println(USAGE);
return;
}
String clientPrincipalName = items[items.length - 1];
KrbIdentity identity = null;
try {
identity = adminClient.requestGetPrincipal(clientPrincipalName);
} catch (KrbException e) {
System.err.println("Failed to get principal: " + clientPrincipalName + ". " + e.toString());
}
if (identity == null) {
return;
} else {
System.out.println("Principal is listed:");
System.out.println(
"Principal: " + identity.getPrincipalName() + "\n"
+ "Expiration date: " + identity.getExpireTime() + "\n"
+ "Created time: " + identity.getCreatedTime() + "\n"
+ "KDC flags: " + identity.getKdcFlags() + "\n"
+ "Key version: " + identity.getKeyVersion() + "\n"
+ "Number of keys: " + identity.getKeys().size()
);
for (EncryptionType keyType: identity.getKeys().keySet()) {
System.out.println("key: " + keyType);
}
}
}
} | 4 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemotePrintUsageCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
public class RemotePrintUsageCommand extends RemoteCommand {
private static final String LISTPRINCSUSAGE = "Usage: list_principals [expression]\n"
+ "\t'expression' is a shell-style glob expression that can contain "
+ "the wild-card characters ?, *, and [].\n"
+ "\tExample:\n"
+ "\t\tlist_principals [expression]\n";
public RemotePrintUsageCommand() {
super(null);
}
@Override
public void execute(String input) throws KrbException {
if (input.startsWith("listprincs")) {
System.out.println(LISTPRINCSUSAGE);
}
}
}
| 5 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote | Create_ds/directory-kerby/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteKeytabAddCommand.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.admin.kadmin.remote.command;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
import java.io.File;
import java.util.List;
public class RemoteKeytabAddCommand extends RemoteCommand {
private static final String USAGE = "Usage: ktadd [-k[eytab] keytab] "
+ "[principal | -glob princ-exp] [...]\n"
+ "\tExample:\n"
+ "\t\tktadd hello@TEST.COM -k /keytab/location\n";
private static final String DEFAULT_KEYTAB_FILE_LOCATION = "/etc/krb5.keytab";
public RemoteKeytabAddCommand(AdminClient adminClient) {
super(adminClient);
}
@Override
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
if (items.length < 2) {
System.err.println(USAGE);
return;
}
String principal = null;
String keytabFileLocation = null;
boolean glob = false;
int index = 1;
while (index < items.length) {
String command = items[index];
if (command.equals("-k")) {
index++;
if (index >= items.length) {
System.err.println(USAGE);
return;
}
keytabFileLocation = items[index].trim();
} else if (command.equals("-glob")) {
glob = true;
} else if (!command.startsWith("-")) {
principal = command;
}
index++;
}
if (keytabFileLocation == null) {
keytabFileLocation = DEFAULT_KEYTAB_FILE_LOCATION;
}
File keytabFile = new File(keytabFileLocation);
if (principal == null) {
System.out.println((glob ? "princ-exp" : "principal") + " not specified!");
System.err.println(USAGE);
return;
}
try {
if (glob) {
List<String> principals = adminClient.requestGetprincsWithExp(principal);
adminClient.requestExportKeytab(keytabFile, principals);
} else {
adminClient.requestExportKeytab(keytabFile, principal);
}
System.out.println("Export Keytab to " + keytabFileLocation);
} catch (KrbException e) {
System.err.println("Principal \"" + principal + "\" fail to add entry to keytab. "
+ e.toString());
}
}
}
| 6 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/AsReqCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
import org.apache.kerby.kerberos.kerb.type.base.HostAddrType;
import org.apache.kerby.kerberos.kerb.type.base.HostAddress;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.SimpleTimeZone;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test AsReq message using a real 'correct' network packet captured from MS-AD
* to detective programming errors and compatibility issues particularly
* regarding Kerberos crypto.
*/
public class AsReqCodecTest {
@Test
public void test() throws IOException, ParseException {
byte[] bytes = CodecTestUtil.readBinaryFile("/asreq.token");
Asn1.decodeAndDump(bytes);
ByteBuffer asReqToken = ByteBuffer.wrap(bytes);
AsReq asReq = new AsReq();
asReq.decode(asReqToken);
Asn1.dump(asReq);
assertThat(asReq.getPvno()).isEqualTo(5);
assertThat(asReq.getMsgType()).isEqualTo(KrbMessageType.AS_REQ);
PaData paData = asReq.getPaData();
PaDataEntry encTimestampEntry = paData.findEntry(PaDataType.ENC_TIMESTAMP);
assertThat(encTimestampEntry.getPaDataType()).isEqualTo(PaDataType.ENC_TIMESTAMP);
assertThat(encTimestampEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 33, 96));
PaDataEntry pacRequestEntry = paData.findEntry(PaDataType.PAC_REQUEST);
assertThat(pacRequestEntry.getPaDataType()).isEqualTo(PaDataType.PAC_REQUEST);
assertThat(pacRequestEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 108, 115));
KdcReqBody body = asReq.getReqBody();
assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
assertThat(body.getKdcOptions().getValue()).isEqualTo(Arrays.copyOfRange(bytes, 126, 130));
PrincipalName cName = body.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
assertThat(cName.getName()).isEqualTo("des");
assertThat(body.getRealm()).isEqualTo("DENYDC");
PrincipalName sName = body.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("krbtgt", "DENYDC");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
Date date = sdf.parse("20370913024805");
assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
assertThat(body.getRtime().getTime()).isEqualTo(date.getTime());
assertThat(body.getNonce()).isEqualTo(197451134);
List<EncryptionType> types = body.getEtypes();
assertThat(types).hasSize(7);
assertThat(types.get(0).getValue()).isEqualTo(0x0017);
//assertThat(types.get(1).getValue()).isEqualTo(0xff7b);//FIXME
//assertThat(types.get(2).getValue()).isEqualTo(0x0080);//FIXME
assertThat(types.get(3).getValue()).isEqualTo(0x0003);
assertThat(types.get(4).getValue()).isEqualTo(0x0001);
assertThat(types.get(5).getValue()).isEqualTo(0x0018);
//assertThat(types.get(6).getValue()).isEqualTo(0xff79);//FIXME
List<HostAddress> hostAddress = body.getAddresses().getElements();
assertThat(hostAddress).hasSize(1);
assertThat(hostAddress.get(0).getAddrType()).isEqualTo(HostAddrType.ADDRTYPE_NETBIOS);
}
}
| 7 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.kerberos.kerb.KrbCodec;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.CheckSumType;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
public class CodecTest {
@Test
public void testCodec() throws KrbException, IOException {
CheckSum mcs = new CheckSum();
mcs.setCksumtype(CheckSumType.CRC32);
mcs.setChecksum(new byte[] {0x10});
byte[] bytes = KrbCodec.encode(mcs);
assertThat(bytes).isNotNull();
CheckSum restored = KrbCodec.decode(bytes, CheckSum.class);
assertThat(restored).isNotNull();
assertThat(restored.getCksumtype()).isEqualTo(mcs.getCksumtype());
assertThat(mcs.getChecksum()).isEqualTo(restored.getChecksum());
assertThat(restored.tag()).isEqualTo(mcs.tag());
}
}
| 8 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TgsRepCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.TgsRep;
import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test TgsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
* and compatibility issues particularly regarding Kerberos crypto.
*/
public class TgsRepCodecTest {
@Test
public void test() throws IOException {
byte[] bytes = CodecTestUtil.readBinaryFile("/tgsrep.token");
TgsRep tgsRep = new TgsRep();
tgsRep.decode(bytes);
assertThat(tgsRep.getPvno()).isEqualTo(5);
assertThat(tgsRep.getMsgType()).isEqualTo(KrbMessageType.TGS_REP);
assertThat(tgsRep.getCrealm()).isEqualTo("DENYDC.COM");
PrincipalName cName = tgsRep.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
assertThat(cName.getNameStrings()).hasSize(1).contains("des");
Ticket ticket = tgsRep.getTicket();
assertThat(ticket.getTktvno()).isEqualTo(5);
assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
PrincipalName sName = ticket.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("host", "xp1.denydc.com");
//FIXME
//EncTicketPart encTicketPart = ticket.getEncPart();
//assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(23);
//assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
//EncKdcRepPart encKdcRepPart = tgsRep.getEncPart();
//assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(3);
}
}
| 9 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/ADTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.kerby.asn1.type.Asn1Utf8String;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.type.ad.ADAuthenticationIndicator;
import org.apache.kerby.kerberos.kerb.type.ad.AuthorizationData;
import org.apache.kerby.kerberos.kerb.type.ad.AuthorizationDataEntry;
import org.apache.kerby.kerberos.kerb.type.ad.AuthorizationDataWrapper;
import org.apache.kerby.kerberos.kerb.type.ad.AuthorizationDataWrapper.WrapperType;
import org.junit.jupiter.api.Test;
/**
* Test class for Authorization data codec.
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADTest {
private static final String FOO = "Foo";
private static final String BAR = "Bar";
/**
* Test the Authorization Data codec.
*
* @throws KrbException Exception
* @throws IOException Exception
*/
@Test
public void testADCodec() throws KrbException, IOException {
int i = -1;
// Construct an AD_AUTHENTICATION_INDICATOR entry
ADAuthenticationIndicator indicators = new ADAuthenticationIndicator();
indicators.add(new Asn1Utf8String(FOO));
indicators.add(new Asn1Utf8String(BAR));
// Encode
System.out.println("\nIndicators prior to encoding:");
for (Asn1Utf8String ind : indicators.getAuthIndicators()) {
System.out.println(ind.toString());
}
byte[] enIndicators = indicators.encode();
// Decode get this out of asn1 tests
indicators.decode(enIndicators);
System.out.println("\nIndicators after decoding:");
for (Asn1Utf8String ind : indicators.getAuthIndicators()) {
System.out.println(ind.toString());
}
// Create an AD_IF_RELEVENT container
AuthorizationData adirData = new AuthorizationData();
adirData.add(indicators);
AuthorizationDataWrapper adirWrap = new AuthorizationDataWrapper(WrapperType.AD_IF_RELEVANT, adirData);
// Encode
System.out.println("\nADE (IR) Wrapper prior to encoding:");
for (AuthorizationDataEntry ade : adirWrap.getAuthorizationData().getElements()) {
ADAuthenticationIndicator ad = (ADAuthenticationIndicator) ade;
for (Asn1Utf8String ind : ad.getAuthIndicators()) {
System.out.println(ind.toString());
}
}
byte[] enAdir = adirWrap.encode();
// Decode
adirWrap.decode(enAdir);
System.out.println("\nADE (IR) Wrapper after decoding:");
for (AuthorizationDataEntry ade : adirWrap.getAuthorizationData().getElements()) {
ADAuthenticationIndicator ad = (ADAuthenticationIndicator) ade;
i = 0;
for (Asn1Utf8String ind : ad.getAuthIndicators()) {
System.out.println(ind.toString());
if (i == 0) {
assertEquals(ind.getValue(), FOO);
} else {
assertEquals(ind.getValue(), BAR);
}
i++;
}
}
// Create an AD_MANDATORY_FOR_KDC container
AuthorizationData admfkData = new AuthorizationData();
admfkData.add(indicators);
AuthorizationDataWrapper admfkWrap = new AuthorizationDataWrapper(WrapperType.AD_MANDATORY_FOR_KDC, admfkData);
// Encode
System.out.println("\nADE (MFK) Wrapper prior to encoding:");
for (AuthorizationDataEntry ade : admfkWrap.getAuthorizationData().getElements()) {
ADAuthenticationIndicator ad = (ADAuthenticationIndicator) ade;
for (Asn1Utf8String ind : ad.getAuthIndicators()) {
System.out.println(ind.toString());
}
}
byte[] enAdmfk = admfkWrap.encode();
// Decode
admfkWrap.decode(enAdmfk);
System.out.println("\nADE (MFK) Wrapper after decoding:");
for (AuthorizationDataEntry ade : admfkWrap.getAuthorizationData().getElements()) {
ADAuthenticationIndicator ad = (ADAuthenticationIndicator) ade;
for (Asn1Utf8String ind : ad.getAuthIndicators()) {
System.out.println(ind.toString());
}
i = 0;
for (Asn1Utf8String ind : ad.getAuthIndicators()) {
System.out.println(ind.toString());
if (i == 0) {
assertEquals(ind.getValue(), FOO);
} else {
assertEquals(ind.getValue(), BAR);
}
i++;
}
}
}
}
| 10 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/PkinitRsaAsReqCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.cms.type.ContentInfo;
import org.apache.kerby.cms.type.SignedData;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsReq;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
public class PkinitRsaAsReqCodecTest {
@Test
public void test() throws IOException, ParseException {
byte[] bytes = CodecTestUtil.readDataFile("/pkinit_rsa_asreq.token");
Asn1.parseAndDump(bytes);
ByteBuffer asReqToken = ByteBuffer.wrap(bytes);
AsReq asReq = new AsReq();
asReq.decode(asReqToken);
//Asn1.decodeAndDump(asReq);
assertThat(asReq.getPvno()).isEqualTo(5);
assertThat(asReq.getMsgType()).isEqualTo(KrbMessageType.AS_REQ);
PaData paData = asReq.getPaData();
PaDataEntry paFxCookieEntry = paData.findEntry(PaDataType.FX_COOKIE);
assertThat(paFxCookieEntry.getPaDataType()).isEqualTo(PaDataType.FX_COOKIE);
assertThat(paFxCookieEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 38, 41));
PaDataEntry pkAsReqEntry = paData.findEntry(PaDataType.PK_AS_REQ);
assertThat(pkAsReqEntry.getPaDataType()).isEqualTo(PaDataType.PK_AS_REQ);
assertThat(pkAsReqEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 58, 2138));
PaPkAsReq paPkAsReq = new PaPkAsReq();
paPkAsReq.decode(pkAsReqEntry.getPaDataValue());
ContentInfo contentInfo = new ContentInfo();
//Asn1.parseAndDump(paPkAsReq.getSignedAuthPack());
contentInfo.decode(paPkAsReq.getSignedAuthPack());
assertThat(contentInfo.getContentType()).isEqualTo("1.2.840.113549.1.7.2");
//Asn1.dump(contentInfo);
SignedData signedData = contentInfo.getContentAs(SignedData.class);
assertThat(signedData.getCertificates().getElements().size()).isEqualTo(1);
assertThat(signedData.getEncapContentInfo().getContentType()).isEqualTo("1.3.6.1.5.2.3.1");
PaDataEntry encpaEntry = paData.findEntry(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
assertThat(encpaEntry.getPaDataType()).isEqualTo(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
assertThat(encpaEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 2148, 2148));
KdcReqBody body = asReq.getReqBody();
assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
assertThat(body.getKdcOptions().getValue()).isEqualTo(Arrays.copyOfRange(bytes, 2161, 2165));
PrincipalName cName = body.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
assertThat(body.getRealm()).isEqualTo("EXAMPLE.COM");
PrincipalName sName = body.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("krbtgt", "EXAMPLE.COM");
assertThat(body.getNonce()).isEqualTo(658979657);
List<EncryptionType> types = body.getEtypes();
assertThat(types).hasSize(6);
assertThat(types.get(0).getValue()).isEqualTo(0x0012);
assertThat(types.get(1).getValue()).isEqualTo(0x0011);
assertThat(types.get(2).getValue()).isEqualTo(0x0010);
assertThat(types.get(3).getValue()).isEqualTo(0x0017);
assertThat(types.get(4).getValue()).isEqualTo(0x0019);
assertThat(types.get(5).getValue()).isEqualTo(0x001A);
// Test encode PaPkAsReq
byte[] encodedPaPkAsReq = paPkAsReq.encode();
PaPkAsReq decodedPaPkAsReq = new PaPkAsReq();
decodedPaPkAsReq.decode(encodedPaPkAsReq);
}
}
| 11 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/PkinitAnonymousAsRepCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.cms.type.EncapsulatedContentInfo;
import org.apache.kerby.cms.type.SignedContentInfo;
import org.apache.kerby.cms.type.SignedData;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.DhRepInfo;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.KdcDhKeyInfo;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsRep;
import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import static org.assertj.core.api.Assertions.assertThat;
public class PkinitAnonymousAsRepCodecTest {
@Test
public void test() throws IOException {
byte[] bytes = CodecTestUtil.readDataFile("/pkinit_anonymous_asrep.token");
ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
AsRep asRep = new AsRep();
asRep.decode(asRepToken);
assertThat(asRep.getPvno()).isEqualTo(5);
assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
PaData paData = asRep.getPaData();
PaDataEntry pkAsRepEntry = paData.findEntry(PaDataType.PK_AS_REP);
assertThat(pkAsRepEntry.getPaDataType()).isEqualTo(PaDataType.PK_AS_REP);
PaPkAsRep paPkAsRep = new PaPkAsRep();
byte[] padataValue = pkAsRepEntry.getPaDataValue();
//Asn1.parseAndDump(padataValue);
paPkAsRep.decode(padataValue);
testPaPkAsRep(paPkAsRep);
PaDataEntry etypeInfo2Entry = paData.findEntry(PaDataType.ETYPE_INFO2);
assertThat(etypeInfo2Entry.getPaDataType()).isEqualTo(PaDataType.ETYPE_INFO2);
PaDataEntry pkinitKxEntry = paData.findEntry(PaDataType.PKINIT_KX);
assertThat(pkinitKxEntry.getPaDataType()).isEqualTo(PaDataType.PKINIT_KX);
assertThat(asRep.getPvno()).isEqualTo(5);
assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
assertThat(asRep.getCrealm()).isEqualTo("WELLKNOWN:ANONYMOUS");
PrincipalName cName = asRep.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_WELLKNOWN);
assertThat(cName.getNameStrings()).hasSize(2).contains("WELLKNOWN", "ANONYMOUS");
Ticket ticket = asRep.getTicket();
assertThat(ticket.getTktvno()).isEqualTo(5);
assertThat(ticket.getRealm()).isEqualTo("EXAMPLE.COM");
PrincipalName sName = ticket.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("krbtgt", "EXAMPLE.COM");
EncryptedData encryptedData = ticket.getEncryptedEncPart();
assertThat(encryptedData.getKvno()).isEqualTo(1);
assertThat(encryptedData.getEType().getValue()).isEqualTo(0x0012);
// Test encode PaPkAsRep
byte[] encodedPaPkAsRep = paPkAsRep.encode();
Asn1.parseAndDump(encodedPaPkAsRep);
PaPkAsRep decodedPaPkAsRep = new PaPkAsRep();
decodedPaPkAsRep.decode(encodedPaPkAsRep);
testPaPkAsRep(decodedPaPkAsRep);
}
private void testPaPkAsRep(PaPkAsRep paPkAsRep) throws IOException {
assertThat(paPkAsRep.getDHRepInfo()).isNotNull();
DhRepInfo dhRepInfo = paPkAsRep.getDHRepInfo();
byte[] dhSignedData = dhRepInfo.getDHSignedData();
SignedContentInfo contentInfo = new SignedContentInfo();
contentInfo.decode(dhSignedData);
assertThat(contentInfo.getContentType()).isEqualTo("1.2.840.113549.1.7.2");
SignedData signedData = contentInfo.getContentAs(SignedData.class);
assertThat(signedData.getCertificates()).isNotNull();
EncapsulatedContentInfo encapsulatedContentInfo = signedData.getEncapContentInfo();
assertThat(encapsulatedContentInfo.getContentType()).isEqualTo("1.3.6.1.5.2.3.2");
byte[] eContentInfo = encapsulatedContentInfo.getContent();
KdcDhKeyInfo kdcDhKeyInfo = new KdcDhKeyInfo();
kdcDhKeyInfo.decode(eContentInfo);
assertThat(kdcDhKeyInfo.getSubjectPublicKey()).isNotNull();
assertThat(kdcDhKeyInfo.getDHKeyExpiration()).isNull();
assertThat(kdcDhKeyInfo.getNonce()).isNotNull();
}
}
| 12 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/PkinitAnonymousAsReqCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.cms.type.DigestAlgorithmIdentifiers;
import org.apache.kerby.cms.type.SignedContentInfo;
import org.apache.kerby.cms.type.SignedData;
import org.apache.kerby.cms.type.SignerInfos;
import org.apache.kerby.kerberos.kerb.KrbConstant;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.AuthPack;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsReq;
import org.apache.kerby.x509.type.DhParameter;
import org.apache.kerby.x509.type.SubjectPublicKeyInfo;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class PkinitAnonymousAsReqCodecTest {
@Test
public void test() throws IOException, ParseException {
byte[] bytes = CodecTestUtil.readDataFile("/pkinit_anonymous_asreq.token");
//Asn1.dump(bytes, true);
ByteBuffer asReqToken = ByteBuffer.wrap(bytes);
AsReq asReq = new AsReq();
asReq.decode(asReqToken);
//Asn1.dump(asReq, false);
assertThat(asReq.getPvno()).isEqualTo(5);
assertThat(asReq.getMsgType()).isEqualTo(KrbMessageType.AS_REQ);
PaData paData = asReq.getPaData();
PaDataEntry paFxCookieEntry = paData.findEntry(PaDataType.FX_COOKIE);
assertThat(paFxCookieEntry.getPaDataType()).isEqualTo(PaDataType.FX_COOKIE);
assertThat(paFxCookieEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 38, 41));
PaDataEntry pkAsReqEntry = paData.findEntry(PaDataType.PK_AS_REQ);
assertThat(pkAsReqEntry.getPaDataType()).isEqualTo(PaDataType.PK_AS_REQ);
assertThat(pkAsReqEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 58, 1366));
PaPkAsReq paPkAsReq = new PaPkAsReq();
paPkAsReq.decode(pkAsReqEntry.getPaDataValue());
testPaPkAsReq(paPkAsReq);
PaDataEntry encpaEntry = paData.findEntry(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
assertThat(encpaEntry.getPaDataType()).isEqualTo(PaDataType.ENCPADATA_REQ_ENC_PA_REP);
assertThat(encpaEntry.getPaDataValue()).isEqualTo(Arrays.copyOfRange(bytes, 1376, 1376));
KdcReqBody body = asReq.getReqBody();
assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
assertThat(body.getKdcOptions().getValue()).isEqualTo(Arrays.copyOfRange(bytes, 1389, 1393));
PrincipalName cName = body.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_WELLKNOWN);
assertThat(cName.getName()).isEqualTo(KrbConstant.ANONYMOUS_PRINCIPAL);
assertThat(body.getRealm()).isEqualTo("EXAMPLE.COM");
PrincipalName sName = body.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("krbtgt", "EXAMPLE.COM");
assertThat(body.getNonce()).isEqualTo(1797404543);
List<EncryptionType> types = body.getEtypes();
assertThat(types).hasSize(6);
assertThat(types.get(0).getValue()).isEqualTo(0x0012);
assertThat(types.get(1).getValue()).isEqualTo(0x0011);
assertThat(types.get(2).getValue()).isEqualTo(0x0010);
assertThat(types.get(3).getValue()).isEqualTo(0x0017);
assertThat(types.get(4).getValue()).isEqualTo(0x0019);
assertThat(types.get(5).getValue()).isEqualTo(0x001A);
// Test encode PaPkAsReq
byte[] encodedPaPkAsReq = paPkAsReq.encode();
PaPkAsReq decodedPaPkAsReq = new PaPkAsReq();
decodedPaPkAsReq.decode(encodedPaPkAsReq);
testPaPkAsReq(decodedPaPkAsReq);
}
private void testPaPkAsReq(PaPkAsReq paPkAsReq) throws IOException {
SignedContentInfo contentInfo = new SignedContentInfo();
Asn1.parseAndDump(paPkAsReq.getSignedAuthPack());
contentInfo.decode(paPkAsReq.getSignedAuthPack());
assertThat(contentInfo.getContentType()) .isEqualTo("1.2.840.113549.1.7.2");
Asn1.dump(contentInfo);
SignedData signedData = contentInfo.getSignedData();
assertThat(signedData.getVersion()).isEqualTo(3);
DigestAlgorithmIdentifiers dais = signedData.getDigestAlgorithms();
assertThat(dais).isNotNull();
if (dais != null) {
assertThat(dais.getElements()).isEmpty();
}
assertThat(signedData.getCertificates()).isNull();
assertThat(signedData.getCrls()).isNull();
SignerInfos signerInfos = signedData.getSignerInfos();
assertThat(signerInfos).isNotNull();
if (signerInfos != null) {
assertThat(signerInfos.getElements()).isEmpty();
}
assertThat(signedData.getEncapContentInfo().getContentType())
.isEqualTo("1.3.6.1.5.2.3.1");
AuthPack authPack = new AuthPack();
Asn1.parseAndDump(signedData.getEncapContentInfo().getContent());
authPack.decode(signedData.getEncapContentInfo().getContent());
assertThat(authPack.getsupportedCmsTypes().getElements().size()).isEqualTo(1);
assertThat(authPack.getsupportedCmsTypes().getElements().get(0).getAlgorithm())
.isEqualTo("1.2.840.113549.3.7");
SubjectPublicKeyInfo subjectPublicKeyInfo = authPack.getClientPublicValue();
assertThat(subjectPublicKeyInfo.getAlgorithm().getAlgorithm())
.isEqualTo("1.2.840.10046.2.1");
DhParameter dhParameter =
subjectPublicKeyInfo.getAlgorithm().getParametersAs(DhParameter.class);
assertThat(dhParameter.getG()).isEqualTo(BigInteger.valueOf(2));
assertThat(authPack.getsupportedKDFs().getElements().size()).isEqualTo(3);
assertThat(authPack.getsupportedKDFs().getElements().get(0).getKdfId())
.isEqualTo("1.3.6.1.5.2.3.6.2");
assertThat(authPack.getsupportedKDFs().getElements().get(1).getKdfId())
.isEqualTo("1.3.6.1.5.2.3.6.1");
assertThat(authPack.getsupportedKDFs().getElements().get(2).getKdfId())
.isEqualTo("1.3.6.1.5.2.3.6.3");
}
}
| 13 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/PkinitRsaAsRepCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.cms.type.ContentInfo;
import org.apache.kerby.cms.type.EnvelopedData;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsRep;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import static org.assertj.core.api.Assertions.*;
public class PkinitRsaAsRepCodecTest {
@Test
public void test() throws IOException {
byte[] bytes = CodecTestUtil.readDataFile("/pkinit_rsa_asrep.token");
ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
AsRep asRep = new AsRep();
asRep.decode(asRepToken);
assertThat(asRep.getPvno()).isEqualTo(5);
assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
PaData paData = asRep.getPaData();
PaDataEntry pkAsRepEntry = paData.findEntry(PaDataType.PK_AS_REP);
assertThat(pkAsRepEntry.getPaDataType()).isEqualTo(PaDataType.PK_AS_REP);
PaPkAsRep paPkAsRep = new PaPkAsRep();
byte[] padataValue = pkAsRepEntry.getPaDataValue();
paPkAsRep.decode(padataValue);
assertThat(paPkAsRep.getEncKeyPack()).isNotNull();
byte[] encKeyPack = paPkAsRep.getEncKeyPack();
Asn1.parseAndDump(encKeyPack);
ContentInfo contentInfo = new ContentInfo();
contentInfo.decode(encKeyPack);
assertThat(contentInfo.getContentType()).isEqualTo("1.2.840.113549.1.7.3");
EnvelopedData envelopedData = contentInfo.getContentAs(EnvelopedData.class);
Asn1.dump(envelopedData);
}
}
| 14 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/KerberosTimeTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.kerby.kerberos.kerb.type.KerberosTime;
import org.junit.jupiter.api.Test;
/**
* Testing the KerberosTime class
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class KerberosTimeTest {
@Test
public void testLessThan() {
KerberosTime kerberosTime = new KerberosTime();
assertTrue(kerberosTime.lessThan(System.currentTimeMillis() + 100));
assertFalse(kerberosTime.lessThan(System.currentTimeMillis() - 10000));
}
@Test
public void testGreaterThan() {
KerberosTime kerberosTime = new KerberosTime();
assertTrue(kerberosTime.greaterThan(new KerberosTime(System.currentTimeMillis() - 10000)));
assertFalse(kerberosTime.greaterThan(new KerberosTime(System.currentTimeMillis() + 100)));
}
@Test
public void testExtend() {
KerberosTime kerberosTime = new KerberosTime();
KerberosTime extended = kerberosTime.extend(1000);
assertTrue(kerberosTime.lessThan(extended));
assertFalse(kerberosTime.greaterThan(extended));
assertEquals(-1000L, kerberosTime.diff(extended));
}
}
| 15 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/TgsReqCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
import org.apache.kerby.kerberos.kerb.type.kdc.TgsReq;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.SimpleTimeZone;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test TgsReq message using a real 'correct' network packet captured from MS-AD to detective programming errors
* and compatibility issues particularly regarding Kerberos crypto.
*/
public class TgsReqCodecTest {
@Test
public void test() throws IOException, ParseException {
byte[] bytes = CodecTestUtil.readBinaryFile("/tgsreq.token");
TgsReq tgsReq = new TgsReq();
tgsReq.decode(bytes);
assertThat(tgsReq.getPvno()).isEqualTo(5);
assertThat(tgsReq.getMsgType()).isEqualTo(KrbMessageType.TGS_REQ);
PaData paData = tgsReq.getPaData();
assertThat(paData.getElements()).hasSize(1);
PaDataEntry entry = paData.getElements().iterator().next();
assertThat(entry.getPaDataType()).isEqualTo(PaDataType.TGS_REQ);
//request body
KdcReqBody body = tgsReq.getReqBody();
assertThat(body.getKdcOptions().getPadding()).isEqualTo(0);
byte[] kdcOptionsValue = {64, (byte) 128, 0, 0};
assertThat(body.getKdcOptions().getValue()).isEqualTo(kdcOptionsValue);
assertThat(body.getRealm()).isEqualTo("DENYDC.COM");
PrincipalName sName = body.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_HST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("host", "xp1.denydc.com");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
Date date = sdf.parse("20370913024805");
assertThat(body.getTill().getTime()).isEqualTo(date.getTime());
assertThat(body.getNonce()).isEqualTo(197296424);
List<EncryptionType> eTypes = body.getEtypes();
assertThat(eTypes).hasSize(7);
assertThat(eTypes.get(0).getValue()).isEqualTo(0x0017);
//assertThat(eTypes.get(1).getValue()).isEqualTo(-133);//FIXME
//assertThat(eTypes.get(2).getValue()).isEqualTo(-128);//FIXME
assertThat(eTypes.get(3).getValue()).isEqualTo(0x0003);
assertThat(eTypes.get(4).getValue()).isEqualTo(0x0001);
assertThat(eTypes.get(5).getValue()).isEqualTo(0x0018);
//assertThat(eTypes.get(6).getValue()).isEqualTo(-135);//FIXME
}
}
| 16 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/PaPkAsRepTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.cms.type.ContentInfo;
import org.apache.kerby.kerberos.kerb.KrbCodec;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.DhRepInfo;
import org.apache.kerby.kerberos.kerb.type.pa.pkinit.PaPkAsRep;
import org.junit.jupiter.api.Test;
import java.io.IOException;
public class PaPkAsRepTest {
@Test
public void test() throws IOException, KrbException {
PaPkAsRep paPkAsRep = new PaPkAsRep();
DhRepInfo dhRepInfo = new DhRepInfo();
ContentInfo contentInfo = new ContentInfo();
contentInfo.setContentType("1.2.840.113549.1.7.2");
dhRepInfo.setDHSignedData(contentInfo.encode());
paPkAsRep.setDHRepInfo(dhRepInfo);
Asn1.parseAndDump(paPkAsRep.encode());
KrbCodec.decode(paPkAsRep.encode(), PaPkAsRep.class);
}
}
| 17 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/AsRepCodecTest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.base.NameType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test AsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
* and compatibility issues particularly regarding Kerberos crypto.
*/
public class AsRepCodecTest {
@Test
public void test() throws IOException {
byte[] bytes = CodecTestUtil.readBinaryFile("/asrep.token");
ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
AsRep asRep = new AsRep();
asRep.decode(asRepToken);
assertThat(asRep.getPvno()).isEqualTo(5);
assertThat(asRep.getMsgType()).isEqualTo(KrbMessageType.AS_REP);
assertThat(asRep.getCrealm()).isEqualTo("DENYDC.COM");
PrincipalName cName = asRep.getCname();
assertThat(cName.getNameType()).isEqualTo(NameType.NT_PRINCIPAL);
assertThat(cName.getNameStrings()).hasSize(1).contains("u5");
Ticket ticket = asRep.getTicket();
assertThat(ticket.getTktvno()).isEqualTo(5);
assertThat(ticket.getRealm()).isEqualTo("DENYDC.COM");
PrincipalName sName = ticket.getSname();
assertThat(sName.getNameType()).isEqualTo(NameType.NT_SRV_INST);
assertThat(sName.getNameStrings()).hasSize(2)
.contains("krbtgt", "DENYDC.COM");
//FIXME
//EncTicketPart encTicketPart = ticket.getEncPart();
//assertThat(encTicketPart.getKey().getKvno()).isEqualTo(2);
//assertThat(encTicketPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
//EncKdcRepPart encKdcRepPart = asRep.getEncPart();
//assertThat(encKdcRepPart.getKey().getKeyType().getValue()).isEqualTo(0x0017);
//assertThat(encKdcRepPart.getKey().getKvno()).isEqualTo(7);
}
}
| 18 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/codec/CodecTestUtil.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.codec;
import org.apache.kerby.asn1.util.HexUtil;
import org.apache.kerby.asn1.util.IOUtil;
import java.io.IOException;
import java.io.InputStream;
public class CodecTestUtil {
static byte[] readBinaryFile(String path) throws IOException {
try (InputStream is = CodecTestUtil.class.getResourceAsStream(path)) {
byte[] bytes = new byte[is.available()];
is.read(bytes);
return bytes;
}
}
static byte[] readDataFile(String resource) throws IOException {
try (InputStream is = CodecTestUtil.class.getResourceAsStream(resource)) {
String hexStr = IOUtil.readInput(is);
return HexUtil.hex2bytes(hexStr);
}
}
}
| 19 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbException.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
public class KrbException extends Exception {
private static final long serialVersionUID = 7305497872367599428L;
private KrbErrorCode errorCode;
public KrbException(String message) {
super(message);
}
public KrbException(String message, Throwable cause) {
super(message, cause);
}
public KrbException(KrbErrorCode errorCode) {
super(errorCode.getMessage());
this.errorCode = errorCode;
}
public KrbException(KrbErrorCode errorCode, Throwable cause) {
super(errorCode.getMessage(), cause);
this.errorCode = errorCode;
}
public KrbException(KrbErrorCode errorCode, String message) {
super(message + " with error code: " + errorCode.name());
this.errorCode = errorCode;
}
public KrbErrorCode getKrbErrorCode() {
return errorCode;
}
}
| 20 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
import org.apache.kerby.asn1.EnumType;
public enum KrbErrorCode implements EnumType {
KDC_ERR_NONE(0, "No error"),
KDC_ERR_NAME_EXP(1, "Client's entry in database has expired"),
KDC_ERR_SERVICE_EXP(2, "Server's entry in database has expired"),
KDC_ERR_BAD_PVNO(3, "Requested protocol version number not supported"),
KDC_ERR_C_OLD_MAST_KVNO(4, "Client's key encrypted in old master key"),
KDC_ERR_S_OLD_MAST_KVNO(5, "Server's key encrypted in old master key"),
KDC_ERR_C_PRINCIPAL_UNKNOWN(6, "Client not found in Kerberos database"),
KDC_ERR_S_PRINCIPAL_UNKNOWN(7, "Server not found in Kerberos database"),
KDC_ERR_PRINCIPAL_NOT_UNIQUE(8, "Multiple principal entries in database"),
KDC_ERR_NULL_KEY(9, "The client or server has a null key"),
KDC_ERR_CANNOT_POSTDATE(10, "Ticket not eligible for postdating"),
KDC_ERR_NEVER_VALID(11, "Requested start time is later than end time"),
KDC_ERR_POLICY(12, "KDC policy rejects request"),
KDC_ERR_BADOPTION(13, "KDC cannot accommodate requested option"),
KDC_ERR_ETYPE_NOSUPP(14, "KDC has no support for encryption type"),
KDC_ERR_SUMTYPE_NOSUPP(15, "KDC has no support for checksum type"),
KDC_ERR_PADATA_TYPE_NOSUPP(16, "KDC has no support for padata type"),
KDC_ERR_TRTYPE_NOSUPP(17, "KDC has no support for transited type"),
KDC_ERR_CLIENT_REVOKED(18, "Clients credentials have been revoked"),
KDC_ERR_SERVICE_REVOKED(19, "Credentials for server have been revoked"),
KDC_ERR_TGT_REVOKED(20, "TGT has been revoked"),
KDC_ERR_CLIENT_NOTYET(21, "Client not yet valid; try again later"),
KDC_ERR_SERVICE_NOTYET(22, "Server not yet valid; try again later"),
KDC_ERR_KEY_EXPIRED(23, "Password has expired; change password to reset"),
KDC_ERR_PREAUTH_FAILED(24, "Pre-authentication information was invalid"),
KDC_ERR_PREAUTH_REQUIRED(25, "Additional pre-authentication required"),
KDC_ERR_SERVER_NOMATCH(26, "Requested server and ticket don't match"),
KDC_ERR_MUST_USE_USER2USER(27, "Server valid for user2user only"),
KDC_ERR_PATH_NOT_ACCEPTED(28, "KDC Policy rejects transited path"),
KDC_ERR_SVC_UNAVAILABLE(29, "A service is not available"),
KRB_AP_ERR_BAD_INTEGRITY(31, "Integrity check on decrypted field failed"),
KRB_AP_ERR_TKT_EXPIRED(32, "Ticket expired"),
KRB_AP_ERR_TKT_NYV(33, "Ticket not yet valid"),
KRB_AP_ERR_REPEAT(34, "Request is a replay"),
KRB_AP_ERR_NOT_US(35, "The ticket isn't for us"),
KRB_AP_ERR_BADMATCH(36, "Ticket and authenticator don't match"),
KRB_AP_ERR_SKEW(37, "Clock skew too great"),
KRB_AP_ERR_BADADDR(38, "Incorrect net address"),
KRB_AP_ERR_BADVERSION(39, "Protocol version mismatch"),
KRB_AP_ERR_MSG_TYPE(40, "Invalid msg type"),
KRB_AP_ERR_MODIFIED(41, "Message stream modified"),
KRB_AP_ERR_BADORDER(42, "Message out of order"),
KRB_AP_ERR_BADKEYVER(44, "Specified version of key is not available"),
KRB_AP_ERR_NOKEY(45, "Service key not available"),
KRB_AP_ERR_MUT_FAIL(46, "Mutual authentication failed"),
KRB_AP_ERR_BADDIRECTION(47, "Incorrect message direction"),
KRB_AP_ERR_METHOD(48, "Alternative authentication method required"),
KRB_AP_ERR_BADSEQ(49, "Incorrect sequence number in message"),
KRB_AP_ERR_INAPP_CKSUM(50, "Inappropriate type of checksum in message"),
KRB_AP_PATH_NOT_ACCEPTED(51, "Policy rejects transited path"),
RESPONSE_TOO_BIG(52, "Response too big for UDP; retry with TCP"),
KRB_ERR_GENERIC(60, "Generic error (description in e-text)"),
FIELD_TOOLONG(61, "Field is too long for this implementation"),
KDC_ERR_CLIENT_NOT_TRUSTED(62, "Client is not trusted"),
KDC_NOT_TRUSTED(63, "KDC is not trusted"),
KDC_ERR_INVALID_SIG(64, "Signature is invalid"),
KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED(65, "Diffie-Hellman (DH) key parameters not accepted."),
CERTIFICATE_MISMATCH(66, "Certificates do not match"),
KRB_AP_ERR_NO_TGT(67, "No TGT available to validate USER-TO-USER"),
WRONG_REALM(68, "Wrong realm"),
KRB_AP_ERR_USER_TO_USER_REQUIRED(69, "Ticket must be for USER-TO-USER"),
KDC_ERR_CANT_VERIFY_CERTIFICATE(70, "Can't verify certificate"),
KDC_ERR_INVALID_CERTIFICATE(71, "Invalid certificate"),
KDC_ERR_REVOKED_CERTIFICATE(72, "Revoked certificate"),
KDC_ERR_REVOCATION_STATUS_UNKNOWN(73, "Revocation status unknown"),
REVOCATION_STATUS_UNAVAILABLE(74, "Revocation status unavailable"),
KDC_ERR_CLIENT_NAME_MISMATCH(75, "Client names do not match"),
KDC_NAME_MISMATCH(76, "KDC names do not match"),
KDC_ERR_INCONSISTENT_KEY_PURPOSE(77, "Inconsistent key purpose"),
KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED(78, "Digest in certificate not accepted"),
KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED(79, "PA checksum must be included"),
KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED(80, "Digest in signed data not accepted"),
KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED(81, "Public key encryption not supported"),
KRB_AP_ERR_PRINCIPAL_UNKNOWN(82, "A well-known Kerberos principal name is used but not supported"),
TOKEN_PREAUTH_NOT_ALLOWED(83, "Token preauth is not allowed"),
KRB_TIMEOUT(5000, "Network timeout"),
UNKNOWN_ERR(5001, "Unknown error");
private final int value;
private final String message;
KrbErrorCode(int value, String message) {
this.value = value;
this.message = message;
}
public static KrbErrorCode fromValue(Integer value) {
if (value != null) {
for (EnumType e : values()) {
if (e.getValue() == value.intValue()) {
return (KrbErrorCode) e;
}
}
}
return KRB_ERR_GENERIC;
}
public int getValue() {
return value;
}
@Override
public String getName() {
return name();
}
public String getMessage() {
return message;
}
}
| 21 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/TokenProviderRegistry.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kerby.kerberos.kerb;
import org.apache.kerby.kerberos.kerb.provider.TokenProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class TokenProviderRegistry {
static final Logger LOG = LoggerFactory.getLogger(TokenProviderRegistry.class);
private static Map<String, Class> allProvider = new ConcurrentHashMap<>();
static {
ServiceLoader<TokenProvider> providers = ServiceLoader.load(TokenProvider.class);
for (TokenProvider provider : providers) {
allProvider.put(provider.getTokenType(), provider.getClass());
}
}
public static Set<String> registeredProviders() {
return Collections.unmodifiableSet(allProvider.keySet());
}
public static boolean registeredProvider(String name) {
return allProvider.containsKey(name);
}
public static TokenProvider createProvider(String name) {
if (!registeredProvider(name)) {
LOG.error("Unregistered token provider " + name);
throw new RuntimeException("Unregistered token provider " + name);
}
try {
return (TokenProvider) allProvider.get(name).newInstance();
} catch (Exception e) {
LOG.error("Create {} token provider failed", name, e);
throw new RuntimeException("Create " + name + "token provider failed" + e);
}
}
}
| 22 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbRuntime.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
import org.apache.kerby.kerberos.kerb.provider.TokenProvider;
/**
* This runtime allows hook external dependencies thru ServiceProvider interface.
* The hook behavior should be done at the very initial time during startup.
*
* TODO: to be enhanced to allow arbitrary provider to be hooked into.
*/
public class KrbRuntime {
private static TokenProvider tokenProvider;
/**
* Set up token provider, should be done at very initial time
* @return token provider
*/
public static synchronized TokenProvider getTokenProvider(String tokenType) {
if (tokenProvider == null || !tokenType.equals(tokenProvider.getTokenType())) {
tokenProvider = TokenProviderRegistry.createProvider(tokenType);
}
if (tokenProvider == null) {
throw new RuntimeException("No token provider is available");
}
return tokenProvider;
}
/**
* Set token provider.
* @param tokenProvider The token provider
*/
public static synchronized void setTokenProvider(TokenProvider tokenProvider) {
KrbRuntime.tokenProvider = tokenProvider;
}
}
| 23 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorException.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
import org.apache.kerby.kerberos.kerb.type.base.KrbError;
public class KrbErrorException extends KrbException {
private static final long serialVersionUID = -6726737724490205771L;
private KrbError krbError;
public KrbErrorException(KrbError krbError) {
super(krbError.getErrorCode().getMessage());
this.krbError = krbError;
}
public KrbError getKrbError() {
return krbError;
}
}
| 24 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
import org.apache.kerby.asn1.Asn1;
import org.apache.kerby.asn1.Tag;
import org.apache.kerby.asn1.parse.Asn1ParseResult;
import org.apache.kerby.asn1.type.Asn1Type;
import org.apache.kerby.kerberos.kerb.type.ap.ApReq;
import org.apache.kerby.kerberos.kerb.type.base.KrbError;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessage;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.kdc.AsRep;
import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
import org.apache.kerby.kerberos.kerb.type.kdc.TgsRep;
import org.apache.kerby.kerberos.kerb.type.kdc.TgsReq;
import java.io.IOException;
import java.nio.ByteBuffer;
public class KrbCodec {
public static byte[] encode(Asn1Type krbObj) throws KrbException {
try {
return krbObj.encode();
} catch (IOException e) {
throw new KrbException("encode failed", e);
}
}
public static void encode(Asn1Type krbObj, ByteBuffer buffer) throws KrbException {
try {
krbObj.encode(buffer);
} catch (IOException e) {
throw new KrbException("Encoding failed", e);
}
}
public static void decode(byte[] content, Asn1Type value) throws KrbException {
decode(ByteBuffer.wrap(content), value);
}
public static void decode(ByteBuffer content, Asn1Type value) throws KrbException {
try {
value.decode(content);
} catch (IOException e) {
throw new KrbException("Decoding failed", e);
}
}
public static <T extends Asn1Type> T decode(
byte[] content, Class<T> krbType) throws KrbException {
return decode(ByteBuffer.wrap(content), krbType);
}
public static <T extends Asn1Type> T decode(
ByteBuffer content, Class<T> krbType) throws KrbException {
Asn1Type implObj;
try {
implObj = krbType.newInstance();
} catch (Exception e) {
throw new KrbException("Decoding failed", e);
}
try {
implObj.decode(content);
} catch (IOException e) {
throw new KrbException("Decoding failed", e);
}
return (T) implObj;
}
public static KrbMessage decodeMessage(ByteBuffer buffer) throws IOException {
Asn1ParseResult parsingResult = Asn1.parse(buffer);
Tag tag = parsingResult.tag();
KrbMessage msg;
KrbMessageType msgType = KrbMessageType.fromValue(tag.tagNo());
if (msgType == KrbMessageType.TGS_REQ) {
msg = new TgsReq();
} else if (msgType == KrbMessageType.AS_REP) {
msg = new AsRep();
} else if (msgType == KrbMessageType.AS_REQ) {
msg = new AsReq();
} else if (msgType == KrbMessageType.TGS_REP) {
msg = new TgsRep();
} else if (msgType == KrbMessageType.AP_REQ) {
msg = new ApReq();
} else if (msgType == KrbMessageType.AP_REP) {
msg = new ApReq();
} else if (msgType == KrbMessageType.KRB_ERROR) {
msg = new KrbError();
} else {
throw new IOException("To be supported krb message type with tag: " + tag);
}
msg.decode(parsingResult);
return msg;
}
}
| 25 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbConstant.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb;
public class KrbConstant {
public static final int KRB_V5 = 5;
public static final String TGS_PRINCIPAL = "krbtgt";
public static final String ANONYMOUS_PRINCIPAL = "WELLKNOWN/ANONYMOUS";
}
| 26 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenFactory.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.provider;
import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
/**
* A token factory.
*/
public interface TokenFactory {
AuthToken createToken();
}
| 27 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenDecoder.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.provider;
import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
import java.io.IOException;
import java.security.PrivateKey;
import java.security.PublicKey;
/**
* An AuthToken decoder.
*/
public interface TokenDecoder {
/**
* Decode a token from a bytes array.
* @param content The content
* @return token
* @throws IOException e
*/
AuthToken decodeFromBytes(byte[] content) throws IOException;
/**
* Decode a token from a string.
* @param content The content
* @return token
* @throws IOException e
*/
AuthToken decodeFromString(String content) throws IOException;
/**
* set the verify key
*
* @param key a public key
*/
void setVerifyKey(PublicKey key);
/**
* set the verify key
*
* @param key a byte[] key
*/
void setVerifyKey(byte[] key);
/**
* Set the decryption key
*
* @param key a private key
*/
void setDecryptionKey(PrivateKey key);
/**
* Set the decryption key
*
* @param key a secret key
*/
void setDecryptionKey(byte[] key);
/**
* The token signed or not
*
* @return signed or not signed
*/
boolean isSigned();
}
| 28 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenEncoder.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.provider;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
import java.security.PrivateKey;
import java.security.PublicKey;
/**
* An AuthToken encoder.
*/
public interface TokenEncoder {
/**
* Encode a token resulting in a bytes array.
* @param token The auth token
* @return bytes array
* @throws KrbException e
*/
byte[] encodeAsBytes(AuthToken token) throws KrbException;
/**
* Encode a token resulting in a string.
* @param token The auth token
* @return string representation
* @throws KrbException e
*/
String encodeAsString(AuthToken token) throws KrbException;
/**
* set the encryption key
*
* @param key a public key
*/
void setEncryptionKey(PublicKey key);
/**
* set the encryption key
*
* @param key a secret key
*/
void setEncryptionKey(byte[] key);
/**
* set the sign key
*
* @param key a private key
*/
void setSignKey(PrivateKey key);
/**
* set the sign key
*
* @param key a secret key
*/
void setSignKey(byte[] key);
}
| 29 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/TokenProvider.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.provider;
/**
* Token provider for TokenPreauth mechanism. This is needed because JWT token
* encoding and decoding require various facilities that can be provided by 3rd
* libraries. We need them but would not allow them to invade into the core.
*/
public interface TokenProvider extends KrbProvider {
/**
* Get the token type
*
* @return login type
*/
String getTokenType();
/**
* Create a token encoder.
* @return token encoder
*/
TokenEncoder createTokenEncoder();
/**
* Create a token decoder.
* @return token decoder
*/
TokenDecoder createTokenDecoder();
/**
* Create a token factory that can be used to construct concrete token.
* @return token factory
*/
TokenFactory createTokenFactory();
}
| 30 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/provider/KrbProvider.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.provider;
/**
* Krb provider for allowing to hook external dependencies.
*/
public interface KrbProvider {
// no op, just an interface mark.
}
| 31 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosString.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.type.Asn1GeneralString;
/**
* The Kerberos String, as defined in RFC 4120. It restricts the set of chars that
* can be used to [0x00..0x7F]
*
* <pre>
* KerberosString ::= GeneralString -- (IA5String)
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class KerberosString extends Asn1GeneralString {
/**
* Creates a new KerberosString
*/
public KerberosString() {
super();
}
/**
* Creates a new KerberosString with an initial value
*
* @param value The String to store in the KerberosString
*/
public KerberosString(String value) {
super(value);
// Check that the value is valid
if (value != null) {
for (char c:value.toCharArray()) {
if ((c & 0xFF80) != 0x0000) {
throw new IllegalArgumentException("The value contains non ASCII chars " + value);
}
}
}
}
}
| 32 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KrbSequenceType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.type.Asn1SequenceType;
public abstract class KrbSequenceType extends Asn1SequenceType {
public KrbSequenceType(Asn1FieldInfo[] fieldInfos) {
super(fieldInfos);
}
protected int getFieldAsInt(EnumType index) {
Integer value = getFieldAsInteger(index);
if (value != null) {
return value.intValue();
}
return -1;
}
protected void setFieldAsString(EnumType index, String value) {
setFieldAs(index, new KerberosString(value));
}
protected KerberosTime getFieldAsTime(EnumType index) {
return getFieldAs(index, KerberosTime.class);
}
protected void setFieldAsTime(EnumType index, long value) {
setFieldAs(index, new KerberosTime(value));
}
protected void setField(EnumType index, EnumType value) {
setFieldAsInt(index, value.getValue());
}
}
| 33 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import java.util.Date;
import org.apache.kerby.asn1.type.Asn1GeneralizedTime;
/**
* A specialization of the ASN.1 GeneralTime. The Kerberos time contains date and
* time up to the seconds, but with no fractional seconds. It's also always
* expressed as UTC timeZone, thus the 'Z' at the end of its string representation.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class KerberosTime extends Asn1GeneralizedTime {
/** Constant for the {@link KerberosTime} "infinity." */
public static final KerberosTime NEVER = new KerberosTime(Long.MAX_VALUE);
/** The number of milliseconds in a minute. */
public static final int MINUTE = 60000;
/** The number of milliseconds in a day. */
public static final int DAY = MINUTE * 1440;
/** The number of milliseconds in a week. */
public static final int WEEK = MINUTE * 10080;
/**
* Creates a new instance of a KerberosTime object with the current time
*/
public KerberosTime() {
// divide current time by 1000 to drop the ms then multiply by 1000 to convert to ms
super((System.currentTimeMillis() / 1000L) * 1000L);
}
/**
* @param time in milliseconds
*/
public KerberosTime(long time) {
super(time);
}
/**
* @return time in milliseconds
*/
public long getTime() {
return getValue().getTime();
}
/**
* Set the Kerberos time
* @param time set time in milliseconds
*/
public void setTime(long time) {
setValue(new Date(time));
}
/**
* Gets the time in seconds
*
* @return The time
*/
public long getTimeInSeconds() {
return getTime() / 1000;
}
/**
* Compare the KerberosTime with another one, and return <tt>true</tt>
* if it's lesser than the provided one
*
* @param ktime in milliseconds
* @return <tt>true</tt> if less
*/
public boolean lessThan(KerberosTime ktime) {
return getValue().compareTo(ktime.getValue()) < 0;
}
/**
* Compare the KerberosTime with a time, and return <tt>true</tt>
* if it's lesser than the provided one
*
* @param time in milliseconds
* @return <tt>true</tt> if less
*/
public boolean lessThan(long time) {
return getValue().getTime() < time;
}
/**
* Compare the KerberosTime with another one, and return <tt>true</tt>
* if it's lesser than the provided one with time skew
* @param ktime
* @param skew Maximum time skew in milliseconds
* @return <tt>true</tt> if less
*/
public boolean lessThanWithSkew(KerberosTime ktime, long skew) {
return diff(ktime) - skew <= 0;
}
/**
* Compare the KerberosTime with another one, and return <tt>true</tt>
* if it's greater than the provided one
*
* @param ktime compare with milliseconds
* @return <tt>true</tt> if greater
*/
public boolean greaterThan(KerberosTime ktime) {
return getValue().compareTo(ktime.getValue()) > 0;
}
/**
* Compare the KerberosTime with another one, and return <tt>true</tt>
* if it's greater than the provided one with time skew
* @param ktime
* @param skew Maximum time skew in milliseconds
* @return <tt>true</tt> if greater
*/
public boolean greaterThanWithSkew(KerberosTime ktime, long skew) {
return diff(ktime) + skew >= 0;
}
/**
* Check if the KerberosTime is within the provided clock skew
*
* @param clockSkew The clock skew
* @return true if in clock skew
*/
public boolean isInClockSkew(long clockSkew) {
long delta = Math.abs(getTime() - System.currentTimeMillis());
return delta < clockSkew;
}
/**
* @return A copy of the KerbeorsTime
*/
public KerberosTime copy() {
long time = getTime();
return new KerberosTime(time);
}
/**
* Create a KerberosTime based on a time in milliseconds.
*
* @param duration The duration
* @return The created kerberos time
*/
public KerberosTime extend(long duration) {
long result = getTime() + duration;
return new KerberosTime(result);
}
/**
* Return the difference between the currentKerberosTime and the provided one
*
* @param kerberosTime The kerberos time
* @return The difference between the two KerberosTime
*/
public long diff(KerberosTime kerberosTime) {
return getTime() - kerberosTime.getTime();
}
/**
* @return The current KerberosTime
*/
public static KerberosTime now() {
return new KerberosTime(System.currentTimeMillis());
}
/**
* @see Object#hashCode()
*/
@Override
public int hashCode() {
return getValue().hashCode();
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (!(that instanceof KerberosTime)) {
return false;
}
return this.getValue().equals(((KerberosTime) that).getValue());
}
} | 34 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KrbPriv.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessage;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
/**
* The KRB_PRIV message, as defined in RFC 1510 :
* The KRB_PRIV message contains user data encrypted in the Session Key.
* The message fields are:
* <pre>
* KRB-PRIV ::= [APPLICATION 21] SEQUENCE {
* pvno[0] INTEGER,
* msg-type[1] INTEGER,
* enc-part[3] EncryptedData
* </pre>
*/
public class KrbPriv extends KrbMessage {
protected enum KrbPrivField implements EnumType {
PVNO,
MSG_TYPE,
UNUSED,
ENC_PART;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbPriv.KrbPrivField.PVNO, Asn1Integer.class),
new ExplicitField(KrbPriv.KrbPrivField.MSG_TYPE, Asn1Integer.class),
new ExplicitField(KrbPriv.KrbPrivField.UNUSED, null),
new ExplicitField(KrbPriv.KrbPrivField.ENC_PART, EncryptedData.class)
};
/**
* Creates a new instance of a KRB-PRIv message
*/
public KrbPriv() {
super(KrbMessageType.KRB_PRIV, fieldInfos);
}
private EncKrbPrivPart encPart;
public EncryptedData getEncryptedEncPart() {
return getFieldAs(KrbPriv.KrbPrivField.ENC_PART, EncryptedData.class);
}
public void setEncryptedEncPart(EncryptedData encryptedEncPart) {
setFieldAs(KrbPriv.KrbPrivField.ENC_PART, encryptedEncPart);
}
public EncKrbPrivPart getEncPart() {
return encPart;
}
public void setEncPart(EncKrbPrivPart encPart) {
this.encPart = encPart;
}
}
| 35 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosStrings.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import java.util.List;
public class KerberosStrings extends KrbSequenceOfType<KerberosString> {
public KerberosStrings() {
super();
}
public KerberosStrings(List<String> strings) {
super();
setValues(strings);
}
public void setValues(List<String> values) {
clear();
if (values != null) {
for (String value : values) {
addElement(new KerberosString(value));
}
}
}
}
| 36 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KrbAppSequenceType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.type.Asn1TaggingSequence;
/**
* This is for application specific sequence tagged with a number.
*/
public abstract class KrbAppSequenceType extends Asn1TaggingSequence {
public KrbAppSequenceType(int tagNo, Asn1FieldInfo[] fieldInfos) {
super(tagNo, fieldInfos, true, false); // Kerberos favors explicit
}
protected int getFieldAsInt(EnumType index) {
Integer value = getFieldAsInteger(index);
if (value != null) {
return value.intValue();
}
return -1;
}
protected void setFieldAsString(EnumType index, String value) {
setFieldAs(index, new KerberosString(value));
}
protected KerberosTime getFieldAsTime(EnumType index) {
return getFieldAs(index, KerberosTime.class);
}
protected void setFieldAsTime(EnumType index, long value) {
setFieldAs(index, new KerberosTime(value));
}
protected void setField(EnumType index, EnumType krbEnum) {
setFieldAsInt(index, krbEnum.getValue());
}
}
| 37 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/EncKrbPrivPart.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.base.HostAddress;
/**
EncKrbPrivPart ::= [APPLICATION 28] SEQUENCE {
user-data[0] OCTET STRING,
timestamp[1] KerberosTime OPTIONAL,
usec[2] INTEGER OPTIONAL,
seq-number[3] INTEGER OPTIONAL,
s-address[4] HostAddress, -- sender's addr
r-address[5] HostAddress OPTIONAL
-- recip's addr
}
*/
public class EncKrbPrivPart extends KrbAppSequenceType {
public static final int TAG = 28;
protected enum EncKrbPrivPartField implements EnumType {
USER_DATA,
TIMESTAMP,
USEC,
SEQ_NUMBER,
S_ADDRESS,
R_ADDRESS;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.USER_DATA, Asn1OctetString.class),
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.TIMESTAMP, KerberosTime.class),
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.USEC, Asn1Integer.class),
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.SEQ_NUMBER, Asn1Integer.class),
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.S_ADDRESS, HostAddress.class),
new ExplicitField(EncKrbPrivPart.EncKrbPrivPartField.R_ADDRESS, HostAddress.class)
};
public EncKrbPrivPart() {
super(TAG, fieldInfos);
}
public byte[] getUserData() {
return getFieldAsOctets(EncKrbPrivPart.EncKrbPrivPartField.USER_DATA);
}
public void setUserData(byte[] userData) {
setFieldAsOctets(EncKrbPrivPart.EncKrbPrivPartField.USER_DATA, userData);
}
public KerberosTime getTimeStamp() {
return getFieldAsTime(EncKrbPrivPart.EncKrbPrivPartField.TIMESTAMP);
}
public void setTimeStamp(KerberosTime timeStamp) {
setFieldAs(EncKrbPrivPart.EncKrbPrivPartField.TIMESTAMP, timeStamp);
}
public int getUsec() {
return getFieldAsInt(EncKrbPrivPart.EncKrbPrivPartField.USEC);
}
public void setUsec(int usec) {
setFieldAsInt(EncKrbPrivPart.EncKrbPrivPartField.USEC, usec);
}
public int getSeqNumber() {
return getFieldAsInt(EncKrbPrivPart.EncKrbPrivPartField.SEQ_NUMBER);
}
public void setSeqNumber(int seqNumber) {
setFieldAsInt(EncKrbPrivPart.EncKrbPrivPartField.SEQ_NUMBER, seqNumber);
}
public HostAddress getSAddress() {
return getFieldAs(EncKrbPrivPart.EncKrbPrivPartField.S_ADDRESS, HostAddress.class);
}
public void setSAddress(HostAddress hostAddress) {
setFieldAs(EncKrbPrivPart.EncKrbPrivPartField.S_ADDRESS, hostAddress);
}
public HostAddress getRAddress() {
return getFieldAs(EncKrbPrivPart.EncKrbPrivPartField.R_ADDRESS, HostAddress.class);
}
public void setRAddress(HostAddress hostAddress) {
setFieldAs(EncKrbPrivPart.EncKrbPrivPartField.R_ADDRESS, hostAddress);
}
}
| 38 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KrbIntegers.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import org.apache.kerby.asn1.type.Asn1Integer;
import java.util.ArrayList;
import java.util.List;
public class KrbIntegers extends KrbSequenceOfType<Asn1Integer> {
public KrbIntegers() {
super();
}
public KrbIntegers(List<Integer> values) {
super();
setValues(values);
}
public void setValues(List<Integer> values) {
clear();
if (values != null) {
for (Integer value : values) {
addElement(new Asn1Integer(value));
}
}
}
public List<Integer> getValues() {
List<Integer> results = new ArrayList<>();
for (Asn1Integer value : getElements()) {
results.add(value.getValue().intValue());
}
return results;
}
}
| 39 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KrbSequenceOfType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type;
import java.util.ArrayList;
import java.util.List;
import org.apache.kerby.asn1.type.Asn1SequenceOf;
import org.apache.kerby.asn1.type.Asn1String;
import org.apache.kerby.asn1.type.Asn1Type;
/**
* A class that represents a SequenceOf Kerberos elements.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*
* @param <T> The KrbSequence type
*/
public class KrbSequenceOfType<T extends Asn1Type> extends Asn1SequenceOf<T> {
/**
* @return A String List of the Kerberos Elements in this sequenceOf.
*/
public List<String> getAsStrings() {
List<T> elements = getElements();
// may be spurious... Careful check of the elements nullity.
if (elements == null) {
return new ArrayList<String>();
}
List<String> results = new ArrayList<>(elements.size());
for (T ele : elements) {
if (ele instanceof Asn1String) {
results.add(((Asn1String) ele).getValue());
} else {
throw new RuntimeException("The targeted field type isn't of string");
}
}
return results;
}
}
| 40 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AndOr.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
* <pre>
* AD-AND-OR ::= SEQUENCE {
* condition-count [0] Int32,
* elements [1] AuthorizationData
* }
* </pre>
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class AndOr extends KrbSequenceType {
protected enum AndOrField implements EnumType {
AndOr_ConditionCount, AndOr_Elements;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The CamMac's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(AndOrField.AndOr_ConditionCount, Asn1Integer.class),
new ExplicitField(AndOrField.AndOr_Elements, AuthorizationData.class)};
public AndOr() {
super(fieldInfos);
}
public AndOr(int conditionCount, AuthorizationData authzData) {
super(fieldInfos);
setFieldAs(AndOrField.AndOr_ConditionCount, new Asn1Integer(conditionCount));
setFieldAs(AndOrField.AndOr_Elements, authzData);
}
public int getConditionCount() {
return getFieldAs(AndOrField.AndOr_ConditionCount, Asn1Integer.class).getValue().intValue();
}
public void setConditionCount(int conditionCount) {
setFieldAs(AndOrField.AndOr_ConditionCount, new Asn1Integer(conditionCount));
}
public AuthorizationData getAuthzData() {
return getFieldAs(AndOrField.AndOr_Elements, AuthorizationData.class);
}
public void setAuthzData(AuthorizationData authzData) {
setFieldAs(AndOrField.AndOr_Elements, authzData);
}
}
| 41 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/CamMacVerifierMac.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
/**
* <pre>
* Verifier-MAC ::= SEQUENCE {
* identifier [0] PrincipalName OPTIONAL,
* kvno [1] UInt32 OPTIONAL,
* enctype [2] Int32 OPTIONAL,
* mac [3] Checksum
* }
* </pre>
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class CamMacVerifierMac extends KrbSequenceType {
protected enum CamMacField implements EnumType {
CAMMAC_identifier, CAMMAC_kvno, CAMMAC_enctype, CAMMAC_mac;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The CamMac's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(CamMacField.CAMMAC_identifier, PrincipalName.class),
new ExplicitField(CamMacField.CAMMAC_kvno, Asn1Integer.class),
new ExplicitField(CamMacField.CAMMAC_enctype, Asn1Integer.class),
new ExplicitField(CamMacField.CAMMAC_mac, CheckSum.class)};
public CamMacVerifierMac() {
super(fieldInfos);
}
public CamMacVerifierMac(PrincipalName identifier) {
super(fieldInfos);
setFieldAs(CamMacField.CAMMAC_identifier, identifier);
}
public PrincipalName getIdentifier() {
return getFieldAs(CamMacField.CAMMAC_identifier, PrincipalName.class);
}
public void setIdentifier(PrincipalName identifier) {
setFieldAs(CamMacField.CAMMAC_identifier, identifier);
}
public int getKvno() {
return getFieldAs(CamMacField.CAMMAC_kvno, Asn1Integer.class).getValue().intValue();
}
public void setKvno(int kvno) {
setFieldAs(CamMacField.CAMMAC_kvno, new Asn1Integer(kvno));
}
public int getEnctype() {
return getFieldAs(CamMacField.CAMMAC_enctype, Asn1Integer.class).getValue().intValue();
}
public void setEnctype(int encType) {
setFieldAs(CamMacField.CAMMAC_enctype, new Asn1Integer(encType));
}
public CheckSum getMac() {
return getFieldAs(CamMacField.CAMMAC_mac, CheckSum.class);
}
public void setMac(CheckSum mac) {
setFieldAs(CamMacField.CAMMAC_mac, mac);
}
}
| 42 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AuthorizationData.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* The AuthorizationData as defined in RFC 4120 :
* <pre>
* AuthorizationData ::= SEQUENCE OF SEQUENCE {
* ad-type [0] Int32,
* ad-data [1] OCTET STRING
* }
* </pre>
*
* This class is just empty, as the content is already stored in a SequenceOf.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AuthorizationData extends KrbSequenceOfType<AuthorizationDataEntry> {
public AuthorizationData clone() {
AuthorizationData result = new AuthorizationData();
for (AuthorizationDataEntry entry : super.getElements()) {
result.add(entry.clone());
}
return result;
}
}
| 43 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/CamMacVerifierChoice.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Choice;
import org.apache.kerby.asn1.type.Asn1Type;
/**
* <pre>
* Verifier ::= CHOICE {
mac Verifier-MAC,
...
}
* </pre>
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class CamMacVerifierChoice extends Asn1Choice {
protected enum VerifierChoice implements EnumType {
CAMMAC_verifierMac;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The CamMac's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(VerifierChoice.CAMMAC_verifierMac, CamMacVerifierMac.class)};
public CamMacVerifierChoice() {
super(fieldInfos);
}
public void setChoice(EnumType type, Asn1Type choice) {
setChoiceValue(type, choice);
}
}
| 44 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AuthorizationDataEntry.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.asn1.type.Asn1Type;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* The AuthorizationData component as defined in RFC 4120 :
*
* <pre>
* AuthorizationData ::= SEQUENCE {
* ad-type [0] Int32,
* ad-data [1] OCTET STRING
* }
* </pre>
*
* We just implement what is in the SEQUENCE OF.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AuthorizationDataEntry extends KrbSequenceType {
private static final Logger LOG = LoggerFactory
.getLogger(AuthorizationDataEntry.class);
/**
* The possible fields
*/
protected enum AuthorizationDataEntryField implements EnumType {
AD_TYPE,
AD_DATA;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The AuthorizationDataEntry's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(AuthorizationDataEntryField.AD_TYPE, Asn1Integer.class),
new ExplicitField(AuthorizationDataEntryField.AD_DATA, Asn1OctetString.class)
};
/**
* Creates an AuthorizationDataEntry instance
*/
public AuthorizationDataEntry() {
super(fieldInfos);
}
/**
* Creates an AuthorizationDataEntry instance
* @param type The authorization type
*/
public AuthorizationDataEntry(AuthorizationType type) {
super(fieldInfos);
setAuthzType(type);
}
/**
* Creates an AuthorizationDataEntry instance
* @param type The authorization type
* @param authzData The authorization data
*/
public AuthorizationDataEntry(AuthorizationType type, byte[] authzData) {
super(fieldInfos);
setAuthzType(type);
setAuthzData(authzData);
}
/**
* @return The AuthorizationType (AD_TYPE) field
*/
public AuthorizationType getAuthzType() {
Integer value = getFieldAsInteger(AuthorizationDataEntryField.AD_TYPE);
return AuthorizationType.fromValue(value);
}
/**
* Sets the AuthorizationType (AD_TYPE) field
* @param authzType The AuthorizationType to set
*/
public void setAuthzType(AuthorizationType authzType) {
setFieldAsInt(AuthorizationDataEntryField.AD_TYPE, authzType.getValue());
}
/**
* @return The AuthorizationData (AD_DATA) field
*/
public byte[] getAuthzData() {
return getFieldAsOctets(AuthorizationDataEntryField.AD_DATA);
}
/**
* Sets the AuthorizationData (AD_DATA) field
* @param authzData The AuthorizationData to set
*/
public void setAuthzData(byte[] authzData) {
setFieldAsOctets(AuthorizationDataEntryField.AD_DATA, authzData);
}
/**
* @param <T> type The type
* @return The AuthorizationData (AD_DATA) field
*/
public <T extends Asn1Type> T getAuthzDataAs(Class<T> type) {
T result = null;
byte[] authzBytes = getFieldAsOctets(
AuthorizationDataEntryField.AD_DATA);
if (authzBytes != null) {
try {
result = type.newInstance();
result.decode(authzBytes);
} catch (InstantiationException | IllegalAccessException | IOException e) {
LOG.error("Failed to get the AD_DATA field. " + e.toString());
}
}
return result;
}
public AuthorizationDataEntry clone() {
return new AuthorizationDataEntry(getAuthzType(),
getAuthzData().clone());
}
}
| 45 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAndOr.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import java.util.List;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADAndOr extends AuthorizationDataEntry {
private KrbSequenceOfType<AndOr> myAndOr;
public ADAndOr() {
super(AuthorizationType.AD_AND_OR);
myAndOr = new KrbSequenceOfType<>();
myAndOr.outerEncodeable = this;
}
public ADAndOr(byte[] encoded) throws IOException {
this();
myAndOr.decode(encoded);
}
public ADAndOr(List<AndOr> elements) {
this();
for (AndOr element : elements) {
myAndOr.add(element);
}
}
public List<AndOr> getAndOrs() throws IOException {
return myAndOr.getElements();
}
public void add(AndOr element) {
myAndOr.add(element);
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myAndOr.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myAndOr.dumpWith(dumper, indents + 8);
}
}
| 46 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AuthorizationType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.EnumType;
/**
* The various AuthorizationType values, as defined in RFC 4120 and RFC 1510.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum AuthorizationType implements EnumType {
/**
* Constant for the "null" authorization type.
*/
NONE(0),
/**
* Constant for the "if relevant" authorization type.
*
* RFC 4120
*
* AD elements encapsulated within the if-relevant element are intended for
* interpretation only by application servers that understand the particular
* ad-type of the embedded element. Application servers that do not
* understand the type of an element embedded within the if-relevant element
* may ignore the uninterpretable element. This element promotes
* interoperability across implementations which may have local extensions
* for authorization.
*/
AD_IF_RELEVANT(1),
/**
* Constant for the "intended for server" authorization type.
*
* RFC 4120
*
* AD-INTENDED-FOR-SERVER SEQUENCE { intended-server[0] SEQUENCE OF
* PrincipalName elements[1] AuthorizationData }
*
* AD elements encapsulated within the intended-for-server element may be
* ignored if the application server is not in the list of principal names
* of intended servers. Further, a KDC issuing a ticket for an application
* server can remove this element if the application server is not in the
* list of intended servers.
*
* Application servers should check for their principal name in the
* intended-server field of this element. If their principal name is not
* found, this element should be ignored. If found, then the encapsulated
* elements should be evaluated in the same manner as if they were present
* in the top level authorization data field. Applications and application
* servers that do not implement this element should reject tickets that
* contain authorization data elements of this type.
*/
AD_INTENDED_FOR_SERVER(2),
/**
* Constant for the "intended for application class" authorization type.
*
* RFC 4120
*
* AD-INTENDED-FOR-APPLICATION-CLASS SEQUENCE {
* intended-application-class[0] SEQUENCE OF GeneralString elements[1]
* AuthorizationData } AD elements
*
* encapsulated within the intended-for-application-class element may be
* ignored if the application server is not in one of the named classes of
* application servers. Examples of application server classes include
* "FILESYSTEM", and other kinds of servers.
*
* This element and the elements it encapsulates may be safely ignored by
* applications, application servers, and KDCs that do not implement this
* element.
*/
AD_INTENDED_FOR_APPLICATION_CLASS(3),
/**
* Constant for the "kdc issued" authorization type.
*
* RFC 4120
*
* AD-KDCIssued SEQUENCE { ad-checksum[0] Checksum, i-realm[1] Realm
* OPTIONAL, i-sname[2] PrincipalName OPTIONAL, elements[3]
* AuthorizationData. }
*
* ad-checksum A checksum over the elements field using a cryptographic
* checksum method that is identical to the checksum used to protect the
* ticket itself (i.e. using the same hash function and the same encryption
* algorithm used to encrypt the ticket) and using a key derived from the
* same key used to protect the ticket. i-realm, i-sname The name of the
* issuing principal if different from the KDC itself. This field would be
* used when the KDC can verify the authenticity of elements signed by the
* issuing principal and it allows this KDC to notify the application server
* of the validity of those elements. elements A sequence of authorization
* data elements issued by the KDC.
*
* The KDC-issued ad-data field is intended to provide a means for Kerberos
* principal credentials to embed within themselves privilege attributes and
* other mechanisms for positive authorization, amplifying the privileges of
* the principal beyond what can be done using a credentials without such an
* a-data element.
*
* This can not be provided without this element because the definition of
* the authorization-data field allows elements to be added at will by the
* bearer of a TGT at the time that they request service tickets and
* elements may also be added to a delegated ticket by inclusion in the
* authenticator.
*/
AD_KDC_ISSUED(4),
/**
* Constant for the "and/or" authorization type.
*
* RFC 4120
*
* When restrictive AD elements encapsulated within the and-or element are
* encountered, only the number specified in condition-count of the
* encapsulated conditions must be met in order to satisfy this element.
* This element may be used to implement an "or" operation by setting the
* condition-count field to 1, and it may specify an "and" operation by
* setting the condition count to the number of embedded elements.
* Application servers that do not implement this element must reject
* tickets that contain authorization data elements of this type.
*/
AD_AND_OR(5),
/**
* Constant for the "mandatory ticket extensions" authorization type.
*
* RFC 4120
*
* AD-Mandatory-Ticket-Extensions Checksum
*
* An authorization data element of type mandatory-ticket-extensions
* specifies a collision-proof checksum using the same hash algorithm used
* to protect the integrity of the ticket itself. This checksum will be
* calculated over the entire extensions field. If there are more than one
* extension, all will be covered by the checksum. This restriction
* indicates that the ticket should not be accepted if the checksum does not
* match that calculated over the ticket extensions. Application servers
* that do not implement this element must reject tickets that contain
* authorization data elements of this type.
*/
AD_MANDATORY_TICKET_EXTENSIONS(6),
/**
* Constant for the "in ticket extensions" authorization type.
*
* RFC 4120
*
* AD-IN-Ticket-Extensions Checksum
*
* An authorization data element of type in-ticket-extensions specifies a
* collision-proof checksum using the same hash algorithm used to protect
* the integrity of the ticket itself. This checksum is calculated over a
* separate external AuthorizationData field carried in the ticket
* extensions. Application servers that do not implement this element must
* reject tickets that contain authorization data elements of this type.
* Application servers that do implement this element will search the ticket
* extensions for authorization data fields, calculate the specified
* checksum over each authorization data field and look for one matching the
* checksum in this in-ticket-extensions element. If not found, then the
* ticket must be rejected. If found, the corresponding authorization data
* elements will be interpreted in the same manner as if they were contained
* in the top level authorization data field.
*/
AD_IN_TICKET_EXTENSIONS(7),
/**
* Constant for the "mandatory-for-kdc" authorization type.
*
* RFC 4120
*
* AD-MANDATORY-FOR-KDC ::= AuthorizationData
*
* AD elements encapsulated within the mandatory-for-kdc element are to be
* interpreted by the KDC. KDCs that do not understand the type of an
* element embedded within the mandatory-for-kdc element MUST reject the
* request.
*/
AD_MANDATORY_FOR_KDC(8),
/**
* Constant for the "initial-verified-cas" authorization type.
*
* RFC 4556
*
* AD-INITIAL-VERIFIED-CAS ::= SEQUENCE OF ExternalPrincipalIdentifier --
* Identifies the certification path with which -- the client certificate
* was validated. -- Each ExternalPrincipalIdentifier identifies a CA -- or
* a CA certificate (thereby its public key).
*
* The AD-INITIAL-VERIFIED-CAS structure identifies the certification path
* with which the client certificate was validated. Each
* ExternalPrincipalIdentifier (as defined in Section 3.2.1) in the AD-
* INITIAL-VERIFIED-CAS structure identifies a CA or a CA certificate
* (thereby its public key).
*
* Note that the syntax for the AD-INITIAL-VERIFIED-CAS authorization data
* does permit empty SEQUENCEs to be encoded. Such empty sequences may only
* be used if the KDC itself vouches for the user's certificate.
*
* The AS wraps any AD-INITIAL-VERIFIED-CAS data in AD-IF-RELEVANT
* containers if the list of CAs satisfies the AS' realm's local policy
* (this corresponds to the TRANSITED-POLICY-CHECKED ticket flag [RFC4120]).
* Furthermore, any TGS MUST copy such authorization data from tickets used
* within a PA-TGS-REQ of the TGS-REQ into the resulting ticket. If the list
* of CAs satisfies the local KDC's realm's policy, the TGS MAY wrap the
* data into the AD-IF-RELEVANT container; otherwise, it MAY unwrap the
* authorization data out of the AD-IF-RELEVANT container.
*
* Application servers that understand this authorization data type SHOULD
* apply local policy to determine whether a given ticket bearing such a
* type *not* contained within an AD-IF-RELEVANT container is acceptable.
* (This corresponds to the AP server's checking the transited field when
* the TRANSITED-POLICY-CHECKED flag has not been set [RFC4120].) If such a
* data type is contained within an AD-IF- RELEVANT container, AP servers
* MAY apply local policy to determine whether the authorization data is
* acceptable.
*
* ExternalPrincipalIdentifier ::= SEQUENCE { subjectName [0] IMPLICIT OCTET
* STRING OPTIONAL, -- Contains a PKIX type Name encoded according to --
* [RFC3280]. -- Identifies the certificate subject by the -- distinguished
* subject name. -- REQUIRED when there is a distinguished subject -- name
* present in the certificate. issuerAndSerialNumber [1] IMPLICIT OCTET
* STRING OPTIONAL, -- Contains a CMS type IssuerAndSerialNumber encoded --
* according to [RFC3852]. -- Identifies a certificate of the subject. --
* REQUIRED for TD-INVALID-CERTIFICATES and -- TD-TRUSTED-CERTIFIERS.
* subjectKeyIdentifier [2] IMPLICIT OCTET STRING OPTIONAL, -- Identifies
* the subject's public key by a key -- identifier. When an X.509
* certificate is -- referenced, this key identifier matches the X.509 --
* subjectKeyIdentifier extension value. When other -- certificate formats
* are referenced, the documents -- that specify the certificate format and
* their use -- with the CMS must include details on matching the -- key
* identifier to the appropriate certificate -- field. -- RECOMMENDED for
* TD-TRUSTED-CERTIFIERS. ... }
*/
AD_INITIAL_VERIFIED_CAS(9),
/**
* Constant for the "OSF DCE" authorization type.
*
* RFC 1510
*/
OSF_DCE(64),
/**
* Constant for the "sesame" authorization type.
*
* RFC 4120
*/
SESAME(65),
/**
* Constant for the "OSF-DCE pki certid" authorization type.
*
* RFC 4120
*/
AD_OSF_DCE_PKI_CERTID(66),
/**
* Constant for the "CAM-MAC" authorization type.
*
* RFC 7751 for details.
*/
AD_CAMMAC(96),
/**
* Constant for the "Authentication-Indicator" authorization type.
*
* RFC 6711 An IANA Registry for Level of Assurance (LoA) Profiles provides
* the syntax and semantics of LoA profiles.
*
* RFC-8129 "Authentication Indicator in Kerberos Tickets" for details.
*/
AD_AUTHENTICATION_INDICATOR(97),
/**
* Constant for the "Windows 2K Privilege Attribute Certificate (PAC)"
* authorization type.
*
* RFC 4120
*
* See: Microsoft standard documents MS-PAC and MS-KILE.
*/
AD_WIN2K_PAC(128),
/**
* Constant for the "EncType-Negotiation" authorization type.
*
* RFC 4537 for details.
*/
AD_ETYPE_NEGOTIATION(129),
/**
* Constant for the Authorization Data Type. Note that this is not a
* standard Type as of yet.
*
* See the draft spec "Token Pre-Authentication for Kerberos".
*/
AD_TOKEN(256);
/** The internal value */
private final int value;
/**
* Create a new enum
*/
AuthorizationType(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return value;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
/**
* Get the AuthorizationType associated with a value.
*
* @param value The integer value of the AuthorizationType we are looking for
* @return The associated AuthorizationType, or NULL if not found or if value is null
*/
public static AuthorizationType fromValue(Integer value) {
if (value != null) {
for (EnumType e : values()) {
if (e.getValue() == value) {
return (AuthorizationType) e;
}
}
}
return NONE;
}
}
| 47 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import java.util.List;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.type.Asn1Utf8String;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADAuthenticationIndicator extends AuthorizationDataEntry {
private AuthIndicator myAuthIndicator;
private static class AuthIndicator extends KrbSequenceOfType<Asn1Utf8String> {
}
public ADAuthenticationIndicator() {
super(AuthorizationType.AD_AUTHENTICATION_INDICATOR);
myAuthIndicator = new AuthIndicator();
myAuthIndicator.outerEncodeable = this;
}
public ADAuthenticationIndicator(byte[] encoded) throws IOException {
this();
myAuthIndicator.decode(encoded);
}
public List<Asn1Utf8String> getAuthIndicators() {
return myAuthIndicator.getElements();
}
public void add(Asn1Utf8String indicator) {
myAuthIndicator.add(indicator);
resetBodyLength();
}
public void clear() {
myAuthIndicator.clear();
resetBodyLength();
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myAuthIndicator.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myAuthIndicator.dumpWith(dumper, indents + 8);
}
}
| 48 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/CamMacOtherVerifiers.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class CamMacOtherVerifiers extends KrbSequenceOfType<CamMacVerifierChoice> {
}
| 49 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADIntendedForApplicationClass.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KerberosStrings;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
* Asn1 Class for the "intended for application class" authorization type.
*
* RFC 4120
*
* AD-INTENDED-FOR-APPLICATION-CLASS SEQUENCE { intended-application-class[0]
* SEQUENCE OF GeneralString elements[1] AuthorizationData } AD elements
*
* encapsulated within the intended-for-application-class element may be ignored
* if the application server is not in one of the named classes of application
* servers. Examples of application server classes include "FILESYSTEM", and
* other kinds of servers.
*
* This element and the elements it encapsulates may be safely ignored by
* applications, application servers, and KDCs that do not implement this
* element.
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADIntendedForApplicationClass extends AuthorizationDataEntry {
private IntendedForApplicationClass myIntForAppClass;
private static class IntendedForApplicationClass extends KrbSequenceType {
private AuthorizationData authzData;
/**
* The possible fields
*/
protected enum IntendedForApplicationClassField implements EnumType {
IFAC_intendedAppClass, IFAC_elements;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The IntendedForApplicationClass's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(IntendedForApplicationClassField.IFAC_intendedAppClass, KerberosStrings.class),
new ExplicitField(IntendedForApplicationClassField.IFAC_elements, AuthorizationData.class)};
/**
* Creates an IntendedForApplicationClass instance
*/
IntendedForApplicationClass() {
super(fieldInfos);
}
/**
* Creates an IntendedForApplicationClass instance
*/
IntendedForApplicationClass(KerberosStrings intendedAppClass) {
super(fieldInfos);
setFieldAs(IntendedForApplicationClassField.IFAC_intendedAppClass, intendedAppClass);
}
public KerberosStrings getIntendedForApplicationClass() {
return getFieldAs(IntendedForApplicationClassField.IFAC_intendedAppClass, KerberosStrings.class);
}
/**
* Sets the Intended Application Class value.
*/
public void setIntendedForApplicationClass(KerberosStrings intendedAppClass) {
setFieldAs(IntendedForApplicationClassField.IFAC_intendedAppClass, intendedAppClass);
resetBodyLength();
}
public AuthorizationData getAuthzData() {
if (authzData == null) {
authzData = getFieldAs(IntendedForApplicationClassField.IFAC_elements, AuthorizationData.class);
}
return authzData;
}
public void setAuthzData(AuthorizationData authzData) {
this.authzData = authzData;
setFieldAs(IntendedForApplicationClassField.IFAC_elements, authzData);
resetBodyLength();
}
}
public ADIntendedForApplicationClass() {
super(AuthorizationType.AD_INTENDED_FOR_APPLICATION_CLASS);
myIntForAppClass = new IntendedForApplicationClass();
myIntForAppClass.outerEncodeable = this;
}
public ADIntendedForApplicationClass(byte[] encoded) throws IOException {
this();
myIntForAppClass.decode(encoded);
}
public ADIntendedForApplicationClass(KerberosStrings intendedAppClass) throws IOException {
this();
myIntForAppClass.setIntendedForApplicationClass(intendedAppClass);
}
public KerberosStrings getIntendedForApplicationClass() {
return myIntForAppClass.getIntendedForApplicationClass();
}
/**
* Sets the Intended Application Class value.
*/
public void setIntendedForApplicationClass(KerberosStrings intendedAppClass) {
myIntForAppClass.setIntendedForApplicationClass(intendedAppClass);
}
public AuthorizationData getAuthorizationData() {
return myIntForAppClass.getAuthzData();
}
public void setAuthorizationData(AuthorizationData authzData) {
myIntForAppClass.setAuthzData(authzData);
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myIntForAppClass.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myIntForAppClass.dumpWith(dumper, indents + 8);
}
}
| 50 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADKdcIssued.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
import org.apache.kerby.kerberos.kerb.type.base.Realm;
/**
* <pre>
* AD-KDCIssued ::= SEQUENCE {
* ad-checksum [0] Checksum,
* i-realm [1] Realm OPTIONAL,
* i-sname [2] PrincipalName OPTIONAL,
* elements [3] AuthorizationData
* }
* </pre>
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADKdcIssued extends AuthorizationDataEntry {
private KdcIssued myKdcIssued;
private static class KdcIssued extends KrbSequenceType {
enum KdcIssuedField implements EnumType {
AD_CHECKSUM, I_REALM, I_SNAME, ELEMENTS;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The AuthorizationDataEntry's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KdcIssuedField.AD_CHECKSUM, CheckSum.class),
new ExplicitField(KdcIssuedField.I_REALM, Realm.class),
new ExplicitField(KdcIssuedField.I_SNAME, PrincipalName.class),
new ExplicitField(KdcIssuedField.ELEMENTS, AuthorizationData.class)};
KdcIssued() {
super(fieldInfos);
}
public CheckSum getCheckSum() {
return getFieldAs(KdcIssuedField.AD_CHECKSUM, CheckSum.class);
}
public void setCheckSum(CheckSum chkSum) {
setFieldAs(KdcIssuedField.AD_CHECKSUM, chkSum);
}
public Realm getRealm() {
return getFieldAs(KdcIssuedField.I_REALM, Realm.class);
}
public void setRealm(Realm realm) {
setFieldAs(KdcIssuedField.I_REALM, realm);
}
public PrincipalName getSname() {
return getFieldAs(KdcIssuedField.I_SNAME, PrincipalName.class);
}
public void setSname(PrincipalName sName) {
setFieldAs(KdcIssuedField.I_SNAME, sName);
}
public AuthorizationData getAuthzData() {
return getFieldAs(KdcIssuedField.ELEMENTS, AuthorizationData.class);
}
public void setAuthzData(AuthorizationData authzData) {
setFieldAs(KdcIssuedField.ELEMENTS, authzData);
}
}
public ADKdcIssued() {
super(AuthorizationType.AD_KDC_ISSUED);
myKdcIssued = new KdcIssued();
myKdcIssued.outerEncodeable = this;
}
public ADKdcIssued(byte[] encoded) throws IOException {
this();
myKdcIssued.decode(encoded);
}
public CheckSum getCheckSum() {
return myKdcIssued.getCheckSum();
}
public void setCheckSum(CheckSum chkSum) {
myKdcIssued.setCheckSum(chkSum);
}
public Realm getRealm() {
return myKdcIssued.getRealm();
}
public void setRealm(Realm realm) {
myKdcIssued.setRealm(realm);
}
public PrincipalName getSname() {
return myKdcIssued.getSname();
}
public void setSname(PrincipalName sName) {
myKdcIssued.setSname(sName);
}
public AuthorizationData getAuthorizationData() {
return myKdcIssued.getAuthzData();
}
public void setAuthzData(AuthorizationData authzData) {
myKdcIssued.setAuthzData(authzData);
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myKdcIssued.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myKdcIssued.dumpWith(dumper, indents + 8);
}
}
| 51 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/PrincipalList.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class PrincipalList extends KrbSequenceOfType<PrincipalName> {
}
| 52 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADCamMac.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <pre>
* AD-CAMMAC ::= SEQUENCE {
* elements [0] AuthorizationData,
* kdc-verifier [1] Verifier-MAC OPTIONAL,
* svc-verifier [2] Verifier-MAC OPTIONAL,
* other-verifiers [3] SEQUENCE (SIZE (1..MAX))
* OF Verifier OPTIONAL
* }
* </pre>
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADCamMac extends AuthorizationDataEntry {
private static final Logger LOG = LoggerFactory
.getLogger(ADCamMac.class);
private CamMac myCamMac;
private static class CamMac extends KrbSequenceType {
protected enum CamMacField implements EnumType {
CAMMAC_elements, CAMMAC_kdc_verifier, CAMMAC_svc_verifier, CAMMAC_other_verifiers;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The CamMac's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(CamMacField.CAMMAC_elements, AuthorizationData.class),
new ExplicitField(CamMacField.CAMMAC_kdc_verifier, CamMacVerifierMac.class),
new ExplicitField(CamMacField.CAMMAC_svc_verifier, CamMacVerifierMac.class),
new ExplicitField(CamMacField.CAMMAC_other_verifiers, CamMacOtherVerifiers.class)};
CamMac() {
super(fieldInfos);
}
CamMac(byte[] authzFields) {
super(fieldInfos);
super.setFieldAsOctets(AuthorizationDataEntryField.AD_DATA, authzFields);
}
CamMac(AuthorizationData authzData) {
super(fieldInfos);
setFieldAs(CamMacField.CAMMAC_elements, authzData);
}
public AuthorizationData getAuthorizationData() {
return getFieldAs(CamMacField.CAMMAC_elements, AuthorizationData.class);
}
public void setAuthorizationData(AuthorizationData authzData) {
setFieldAs(CamMacField.CAMMAC_elements, authzData);
resetBodyLength();
}
public CamMacVerifierMac getKdcVerifier() {
return getFieldAs(CamMacField.CAMMAC_kdc_verifier, CamMacVerifierMac.class);
}
public void setKdcVerifier(CamMacVerifierMac kdcVerifier) {
setFieldAs(CamMacField.CAMMAC_kdc_verifier, kdcVerifier);
resetBodyLength();
}
public CamMacVerifierMac getSvcVerifier() {
return getFieldAs(CamMacField.CAMMAC_svc_verifier, CamMacVerifierMac.class);
}
public void setSvcVerifier(CamMacVerifierMac svcVerifier) {
setFieldAs(CamMacField.CAMMAC_svc_verifier, svcVerifier);
resetBodyLength();
}
public CamMacOtherVerifiers getOtherVerifiers() {
return getFieldAs(CamMacField.CAMMAC_other_verifiers, CamMacOtherVerifiers.class);
}
public void setOtherVerifiers(CamMacOtherVerifiers svcVerifier) {
setFieldAs(CamMacField.CAMMAC_other_verifiers, svcVerifier);
resetBodyLength();
}
}
public ADCamMac() {
super(AuthorizationType.AD_CAMMAC);
myCamMac = new CamMac();
myCamMac.outerEncodeable = this;
}
public ADCamMac(byte[] encoded) throws IOException {
this();
myCamMac.decode(encoded);
}
public AuthorizationData getAuthorizationData() {
return myCamMac.getAuthorizationData();
}
public void setAuthorizationData(AuthorizationData authzData) {
myCamMac.setAuthorizationData(authzData);
}
public CamMacVerifierMac getKdcVerifier() {
return myCamMac.getKdcVerifier();
}
public void setKdcVerifier(CamMacVerifierMac kdcVerifier) {
myCamMac.setKdcVerifier(kdcVerifier);
}
public CamMacVerifierMac getSvcVerifier() {
return myCamMac.getSvcVerifier();
}
public void setSvcVerifier(CamMacVerifierMac svcVerifier) {
myCamMac.setSvcVerifier(svcVerifier);
}
public CamMacOtherVerifiers getOtherVerifiers() {
return myCamMac.getOtherVerifiers();
}
public void setOtherVerifiers(CamMacOtherVerifiers otherVerifiers) {
myCamMac.setOtherVerifiers(otherVerifiers);
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myCamMac.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
try {
setAuthzData(myCamMac.encode());
} catch (IOException e) {
LOG.error("Failed to set the AD_DATA field. " + e.toString());
}
super.dumpWith(dumper, indents);
dumper.newLine();
myCamMac.dumpWith(dumper, indents + 8);
}
}
| 53 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADEnctypeNegotiation.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import java.util.List;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADEnctypeNegotiation extends AuthorizationDataEntry {
private KrbSequenceOfType<Asn1Integer> myEnctypeNeg;
public ADEnctypeNegotiation() {
super(AuthorizationType.AD_ETYPE_NEGOTIATION);
myEnctypeNeg = new KrbSequenceOfType<>();
myEnctypeNeg.outerEncodeable = this;
}
public ADEnctypeNegotiation(byte[] encoded) throws IOException {
this();
myEnctypeNeg.decode(encoded);
}
public ADEnctypeNegotiation(List<Asn1Integer> enctypeNeg) throws IOException {
this();
for (Asn1Integer element : enctypeNeg) {
myEnctypeNeg.add(element);
}
}
public List<Asn1Integer> getEnctypeNegotiation() {
return myEnctypeNeg.getElements();
}
public void add(Asn1Integer element) {
myEnctypeNeg.add(element);
}
public void clear() {
myEnctypeNeg.clear();
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myEnctypeNeg.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
}
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myEnctypeNeg.dumpWith(dumper, indents + 8);
}
}
| 54 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AuthorizationDataWrapper.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.EnumType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class AuthorizationDataWrapper extends AuthorizationDataEntry {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizationDataWrapper.class);
private AuthorizationData authorizationData;
public enum WrapperType implements EnumType {
AD_IF_RELEVANT(AuthorizationType.AD_IF_RELEVANT.getValue()), AD_MANDATORY_FOR_KDC(
AuthorizationType.AD_MANDATORY_FOR_KDC.getValue());
/** The internal value */
private final int value;
/**
* Create a new enum
*/
WrapperType(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return value;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
public AuthorizationDataWrapper(WrapperType type) {
super(Enum.valueOf(AuthorizationType.class, type.name()));
}
public AuthorizationDataWrapper(WrapperType type, AuthorizationData authzData) throws IOException {
super(Enum.valueOf(AuthorizationType.class, type.name()));
authorizationData = authzData;
if (authzData != null) {
setAuthzData(authzData.encode());
} else {
setAuthzData(null);
}
}
/**
* @return The AuthorizationType (AD_DATA) field
* @throws IOException e
*/
public AuthorizationData getAuthorizationData() throws IOException {
AuthorizationData result;
if (authorizationData != null) {
result = authorizationData;
} else {
result = new AuthorizationData();
result.decode(getAuthzData());
}
return result;
}
/**
* Sets the AuthorizationData (AD_DATA) field
*
* @param authzData The AuthorizationData to set
* @throws IOException e
*/
public void setAuthorizationData(AuthorizationData authzData) throws IOException {
setAuthzData(authzData.encode());
}
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
try {
getAuthorizationData().dumpWith(dumper, indents + 8);
} catch (IOException e) {
LOG.error("Fail to get authorization data. " + e);
}
}
}
| 55 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADIntendedForServer.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import java.io.IOException;
import org.apache.kerby.asn1.Asn1Dumper;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
* Asn1 Class for the "intended for server" authorization type.
*
* RFC 4120
*
* AD-INTENDED-FOR-SERVER SEQUENCE { intended-server[0] SEQUENCE OF
* PrincipalName elements[1] AuthorizationData }
*
* AD elements encapsulated within the intended-for-server element may be
* ignored if the application server is not in the list of principal names of
* intended servers. Further, a KDC issuing a ticket for an application server
* can remove this element if the application server is not in the list of
* intended servers.
*
* Application servers should check for their principal name in the
* intended-server field of this element. If their principal name is not found,
* this element should be ignored. If found, then the encapsulated elements
* should be evaluated in the same manner as if they were present in the top
* level authorization data field. Applications and application servers that do
* not implement this element should reject tickets that contain authorization
* data elements of this type.
*
* Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
*
* @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
*/
public class ADIntendedForServer extends AuthorizationDataEntry {
private IntForSrvr myIntForSrvr;
private static class IntForSrvr extends KrbSequenceType {
private AuthorizationData authzData;
protected enum IntForSrvrField implements EnumType {
IFS_intendedServer, IFS_elements;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
/** The IntendedForServer's fields */
private static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(IntForSrvrField.IFS_intendedServer, PrincipalList.class),
new ExplicitField(IntForSrvrField.IFS_elements, AuthorizationData.class)};
IntForSrvr() {
super(fieldInfos);
}
IntForSrvr(PrincipalList principals) {
super(fieldInfos);
setFieldAs(IntForSrvrField.IFS_intendedServer, principals);
}
public PrincipalList getIntendedServer() {
return getFieldAs(IntForSrvrField.IFS_intendedServer, PrincipalList.class);
}
public void setIntendedServer(PrincipalList principals) {
setFieldAs(IntForSrvrField.IFS_intendedServer, principals);
resetBodyLength();
}
public AuthorizationData getAuthzData() {
if (authzData == null) {
authzData = getFieldAs(IntForSrvrField.IFS_elements, AuthorizationData.class);
}
return authzData;
}
public void setAuthzData(AuthorizationData authzData) {
this.authzData = authzData;
setFieldAs(IntForSrvrField.IFS_elements, authzData);
resetBodyLength();
}
}
public ADIntendedForServer() {
super(AuthorizationType.AD_INTENDED_FOR_SERVER);
myIntForSrvr = new IntForSrvr();
myIntForSrvr.outerEncodeable = this;
}
public ADIntendedForServer(byte[] encoded) throws IOException {
this();
myIntForSrvr.decode(encoded);
}
public ADIntendedForServer(PrincipalList principals) throws IOException {
this();
myIntForSrvr.setIntendedServer(principals);
}
public PrincipalList getIntendedServer() {
return myIntForSrvr.getIntendedServer();
}
public void setIntendedServer(PrincipalList principals) {
myIntForSrvr.setIntendedServer(principals);
}
public AuthorizationData getAuthorizationData() {
return myIntForSrvr.getAuthzData();
}
public void setAuthorizationData(AuthorizationData authzData) {
myIntForSrvr.setAuthzData(authzData);
}
@Override
protected int encodingBodyLength() throws IOException {
if (bodyLength == -1) {
setAuthzData(myIntForSrvr.encode());
bodyLength = super.encodingBodyLength();
}
return bodyLength;
};
@Override
public void dumpWith(Asn1Dumper dumper, int indents) {
super.dumpWith(dumper, indents);
dumper.newLine();
myIntForSrvr.dumpWith(dumper, indents + 8);
}
}
| 56 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/AdToken.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ad;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.KrbToken;
/**
* The AdToken component as defined in "Token Pre-Authentication for Kerberos", "draft-ietf-kitten-kerb-token-preauth-01"
* (not yet published, but stored in docs/Token-preauth.pdf) :
*
* <pre>
* 6.4. AD-TOKEN
* The new Authorization Data Type AD-TOKEN type contains token
* derivation and is meant to be encapsulated into AD-KDC-ISSUED type
* and to be put into tgt or service tickets. Application can safely
* ignore it if the application doesn't understand it. The token field
* SHOULD be ASN.1 encoded of the binary representation of the
* serialization result of the derivation token according to [JWT].
*
* AD-TOKEN ::= SEQUENCE {
* token [0] OCTET STRING,
* }
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class AdToken extends KrbSequenceType {
/**
* The possible fields
*/
protected enum AdTokenField implements EnumType {
TOKEN;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The AdToken's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(AdTokenField.TOKEN, KrbToken.class)
};
/**
* Creates an instance of AdToken
*/
public AdToken() {
super(fieldInfos);
}
/**
* @return The token
*/
public KrbToken getToken() {
return getFieldAs(AdTokenField.TOKEN, KrbToken.class);
}
/**
* Sets the token
* @param token The token to store
*/
public void setToken(KrbToken token) {
setFieldAs(AdTokenField.TOKEN, token);
}
}
| 57 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/ApOption.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.EnumType;
/**
* The various APOptions values, as defined in RFC 4120.
*
* <pre>
* APOptions ::= KerberosFlags
* -- reserved(0),
* -- use-session-key(1),
* -- mutual-required(2)
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum ApOption implements EnumType {
NONE(-1),
RESERVED(0x80000000), // Bit 0, in ASN.1 BIT STRING definition : the most left-handed bit
USE_SESSION_KEY(0x40000000), // Bit 1
MUTUAL_REQUIRED(0x20000000), // Bit 2
//
// The following values are taken from the MIT Kerberos file krb5.hin :
//
// #define AP_OPTS_ETYPE_NEGOTIATION 0x00000002
// #define AP_OPTS_USE_SUBKEY 0x00000001 /**< Generate a subsession key
// from the current session key
// obtained from the
// credentials */
//
// ---->
ETYPE_NEGOTIATION(0x00000002), // bit 30
USE_SUBKEY(0x00000001); // bit 31
// <---- End of krb5.hin inclusion
/** The internal value */
private final int value;
/**
* Create a new enum
*/
ApOption(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return value;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
/**
* Get the APOptions associated with a value.
*
* @param value The integer value of the APOptions we are looking for
* @return The associated APOptions, or NONE if not found or if value is null
*/
public static ApOption fromValue(int value) {
for (EnumType e : values()) {
if (e.getValue() == value) {
return (ApOption) e;
}
}
return NONE;
}
}
| 58 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/EncAPRepPart.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KerberosTime;
import org.apache.kerby.kerberos.kerb.type.KrbAppSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
/**
* The EncAPRepPart, as defined in RFC 4120, section 5.5.2
* <pre>
* EncAPRepPart ::= [APPLICATION 27] SEQUENCE {
* ctime [0] KerberosTime,
* cusec [1] Microseconds,
* subkey [2] EncryptionKey OPTIONAL,
* seq-number [3] UInt32 OPTIONAL
* }
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EncAPRepPart extends KrbAppSequenceType {
/* The APPLICATION tag */
public static final int TAG = 27;
/**
* The possible fields
*/
protected enum EncAPRepPartField implements EnumType {
CTIME,
CUSEC,
SUBKEY,
SEQ_NUMBER;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The EncAPRepPart's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(EncAPRepPartField.CTIME, KerberosTime.class),
new ExplicitField(EncAPRepPartField.CUSEC, Asn1Integer.class),
new ExplicitField(EncAPRepPartField.SUBKEY, EncryptionKey.class),
new ExplicitField(EncAPRepPartField.SEQ_NUMBER, Asn1Integer.class)
};
/**
* Creates an instance of ApRep
*/
public EncAPRepPart() {
super(TAG, fieldInfos);
}
/**
* @return The current time on client host
*/
public KerberosTime getCtime() {
return getFieldAsTime(EncAPRepPartField.CTIME);
}
/**
* Set the client time
* @param ctime The client time
*/
public void setCtime(KerberosTime ctime) {
setFieldAs(EncAPRepPartField.CTIME, ctime);
}
/**
* @return the microsecond part on the client's timestamp
*/
public int getCusec() {
return getFieldAsInt(EncAPRepPartField.CUSEC);
}
/**
* Set the client's microsecond
* @param cusec the client's microsecond
*/
public void setCusec(int cusec) {
setFieldAsInt(EncAPRepPartField.CUSEC, cusec);
}
/**
* @return The encryption key
*/
public EncryptionKey getSubkey() {
return getFieldAs(EncAPRepPartField.SUBKEY, EncryptionKey.class);
}
/**
* Set the encryption key
* @param subkey the encryption key
*/
public void setSubkey(EncryptionKey subkey) {
setFieldAs(EncAPRepPartField.SUBKEY, subkey);
}
/**
* @return The Sequence Number
*/
public int getSeqNumber() {
return getFieldAsInt(EncAPRepPartField.SEQ_NUMBER);
}
/**
* Set the Sequence Number
* @param seqNumber the Sequence Number
*/
public void setSeqNumber(Integer seqNumber) {
setFieldAsInt(EncAPRepPartField.SEQ_NUMBER, seqNumber);
}
}
| 59 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/ApRep.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessage;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
/**
* The AP-REP message, as defined in RFC 4120 :
*
* <pre>
* AP-REP ::= [APPLICATION 15] SEQUENCE {
* pvno [0] INTEGER (5),
* msg-type [1] INTEGER (15),
* enc-part [2] EncryptedData -- EncAPRepPart
* }
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApRep extends KrbMessage {
/**
* The possible fields
*/
protected enum ApRepField implements EnumType {
PVNO,
MSG_TYPE,
ENC_PART;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The ApRep's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(ApRepField.PVNO, Asn1Integer.class),
new ExplicitField(ApRepField.MSG_TYPE, Asn1Integer.class),
new ExplicitField(ApRepField.ENC_PART, EncryptedData.class)
};
/** The decrypted part of this message (Not used atm) */
private EncAPRepPart encRepPart;
/**
* Creates an instance of ApRep
*/
public ApRep() {
super(KrbMessageType.AP_REP, fieldInfos);
}
/**
* @return The decrypted EncRepPart
*/
public EncAPRepPart getEncRepPart() {
return encRepPart;
}
/**
* Set the decrypted EncRepPart into the message
*
* @param encRepPart The decrypted EncRepPart to store
*/
public void setEncRepPart(EncAPRepPart encRepPart) {
this.encRepPart = encRepPart;
}
/**
* @return The encrypted part
*/
public EncryptedData getEncryptedEncPart() {
return getFieldAs(ApRepField.ENC_PART, EncryptedData.class);
}
/**
* Set the encrypted part into the message
*
* @param encPart The encrypted part to store
*/
public void setEncryptedEncPart(EncryptedData encPart) {
setFieldAs(ApRepField.ENC_PART, encPart);
}
}
| 60 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/ApReq.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessage;
import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
/**
* The AP-REQ message, as defined in RFC 4120 :
* <pre>
* AP-REQ ::= [APPLICATION 14] SEQUENCE {
* pvno [0] INTEGER (5),
* msg-type [1] INTEGER (14),
* ap-options [2] APOptions,
* ticket [3] Ticket,
* authenticator [4] EncryptedData -- Authenticator
* }
* </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApReq extends KrbMessage {
/**
* The possible fields
*/
protected enum ApReqField implements EnumType {
PVNO,
MSG_TYPE,
AP_OPTIONS,
TICKET,
AUTHENTICATOR;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The ApReq's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(ApReqField.PVNO, Asn1Integer.class),
new ExplicitField(ApReqField.MSG_TYPE, Asn1Integer.class),
new ExplicitField(ApReqField.AP_OPTIONS, ApOptions.class),
new ExplicitField(ApReqField.TICKET, Ticket.class),
new ExplicitField(ApReqField.AUTHENTICATOR, EncryptedData.class)
};
/** The decrypted authenticator. Not used atm*/
private Authenticator authenticator;
/**
* Creates a new instance of a AP-REQ message
*/
public ApReq() {
super(KrbMessageType.AP_REQ, fieldInfos);
}
/**
* @return The AP-OPTIONS set
*/
public ApOptions getApOptions() {
return getFieldAs(ApReqField.AP_OPTIONS, ApOptions.class);
}
/**
* Stores the AP-OPTIONS in the message
* @param apOptions The AP-OPTIPNS to set
*/
public void setApOptions(ApOptions apOptions) {
setFieldAs(ApReqField.AP_OPTIONS, apOptions);
}
/**
* @return The Ticket
*/
public Ticket getTicket() {
return getFieldAs(ApReqField.TICKET, Ticket.class);
}
/**
* Stores the ticket in the message
* @param ticket The ticket
*/
public void setTicket(Ticket ticket) {
setFieldAs(ApReqField.TICKET, ticket);
}
/**
* @return the decrypted Authenticator
*/
public Authenticator getAuthenticator() {
return authenticator;
}
/**
* Stores the decrypted Authenticator
* @param authenticator the decrypted Authenticator
*/
public void setAuthenticator(Authenticator authenticator) {
this.authenticator = authenticator;
}
/**
* @return The encrypted Authenticator
*/
public EncryptedData getEncryptedAuthenticator() {
return getFieldAs(ApReqField.AUTHENTICATOR, EncryptedData.class);
}
/**
* Stores the encrypted authenticator in the message
* @param encryptedAuthenticator The encrypted authenticator
*/
public void setEncryptedAuthenticator(EncryptedData encryptedAuthenticator) {
setFieldAs(ApReqField.AUTHENTICATOR, encryptedAuthenticator);
}
}
| 61 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/ApOptions.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.type.Asn1Flags;
/**
* The APOptions container, as defined in RFC 4120 :
*
* <pre>
* APOptions ::= KerberosFlags
* -- reserved(0),
* -- use-session-key(1),
* -- mutual-required(2)
* </pre>
*
* The KerberosFlags element is defined as :
*
* <pre>
* KerberosFlags ::= BIT STRING (SIZE (32..MAX))
* -- minimum number of bits shall be sent,
* -- but no fewer than 32
* </pre>
*
* which defines a 32 bits length for the BIT STRING (it may be longer, but for Kerberos, it won't).
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ApOptions extends Asn1Flags {
/**
* Creates a default ApOptions container, with no bit set
*/
public ApOptions() {
this(0);
}
/**
* Set the flags into the container
*
* @param value The flag as an integer
*/
public ApOptions(int value) {
setFlags(value);
}
}
| 62 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ap/Authenticator.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.ap;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.KrbConstant;
import org.apache.kerby.kerberos.kerb.type.KerberosString;
import org.apache.kerby.kerberos.kerb.type.KerberosTime;
import org.apache.kerby.kerberos.kerb.type.KrbAppSequenceType;
import org.apache.kerby.kerberos.kerb.type.ad.AuthorizationData;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
/**
* The definition of the unencrypted AUthenticator, per RFC 4120, section 5.5.1 :
* <pre>
* Authenticator ::= [APPLICATION 2] SEQUENCE {
* authenticator-vno [0] INTEGER (5),
* crealm [1] Realm,
* cname [2] PrincipalName,
* cksum [3] Checksum OPTIONAL,
* cusec [4] Microseconds,
* ctime [5] KerberosTime,
* subkey [6] EncryptionKey OPTIONAL,
* seq-number [7] UInt32 OPTIONAL,
* authorization-data [8] AuthorizationData OPTIONAL
* }
* </pre>
*/
public class Authenticator extends KrbAppSequenceType {
/** The APPLICATION TAG */
public static final int TAG = 2;
/**
* The possible fields
*/
protected enum AuthenticatorField implements EnumType {
AUTHENTICATOR_VNO,
CREALM,
CNAME,
CKSUM,
CUSEC,
CTIME,
SUBKEY,
SEQ_NUMBER,
AUTHORIZATION_DATA;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The ApReq's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(AuthenticatorField.AUTHENTICATOR_VNO, Asn1Integer.class),
new ExplicitField(AuthenticatorField.CREALM, KerberosString.class),
new ExplicitField(AuthenticatorField.CNAME, PrincipalName.class),
new ExplicitField(AuthenticatorField.CKSUM, CheckSum.class),
new ExplicitField(AuthenticatorField.CUSEC, Asn1Integer.class),
new ExplicitField(AuthenticatorField.CTIME, KerberosTime.class),
new ExplicitField(AuthenticatorField.SUBKEY, EncryptionKey.class),
new ExplicitField(AuthenticatorField.SEQ_NUMBER, Asn1Integer.class),
new ExplicitField(AuthenticatorField.AUTHORIZATION_DATA, AuthorizationData.class)
};
/**
* Creates a new instance of an Authenticator
*/
public Authenticator() {
super(TAG, fieldInfos);
// Default to Version 5
setAuthenticatorVno(KrbConstant.KRB_V5);
}
/**
* @return The Authenticator Version Number
*/
public int getAuthenticatorVno() {
return getFieldAsInt(AuthenticatorField.AUTHENTICATOR_VNO);
}
/**
* Sets the Authenticator version
* @param authenticatorVno The Authenticator version to store
*/
public void setAuthenticatorVno(int authenticatorVno) {
setFieldAsInt(AuthenticatorField.AUTHENTICATOR_VNO, authenticatorVno);
}
/**
* @return The Client Realm
*/
public String getCrealm() {
return getFieldAsString(AuthenticatorField.CREALM);
}
/**
* Sets the Client Realm
* @param crealm The Client Realm to store
*/
public void setCrealm(String crealm) {
setFieldAsString(AuthenticatorField.CREALM, crealm);
}
/**
* @return The client Principal's name
*/
public PrincipalName getCname() {
return getFieldAs(AuthenticatorField.CNAME, PrincipalName.class);
}
/**
* Sets the Client Principal's name
* @param cname The Client Principal's name to store
*/
public void setCname(PrincipalName cname) {
setFieldAs(AuthenticatorField.CNAME, cname);
}
/**
* @return application data checksum
*/
public CheckSum getCksum() {
return getFieldAs(AuthenticatorField.CKSUM, CheckSum.class);
}
/**
* Sets the application data checksum
* @param cksum The application data checksum to store
*/
public void setCksum(CheckSum cksum) {
setFieldAs(AuthenticatorField.CKSUM, cksum);
}
/**
* @return The microsecond part of the client's timestamp
*/
public int getCusec() {
return getFieldAsInt(AuthenticatorField.CUSEC);
}
/**
* Sets the The microsecond part of the client's timestamp
* @param cusec The microsecond part of the client's timestamp to store
*/
public void setCusec(int cusec) {
setFieldAsInt(AuthenticatorField.CUSEC, cusec);
}
/**
* @return The client's host current time
*/
public KerberosTime getCtime() {
return getFieldAsTime(AuthenticatorField.CTIME);
}
/**
* Sets the client's host current time
* @param ctime The client's host current time to store
*/
public void setCtime(KerberosTime ctime) {
setFieldAs(AuthenticatorField.CTIME, ctime);
}
/**
* @return The client's encryption key
*/
public EncryptionKey getSubKey() {
return getFieldAs(AuthenticatorField.SUBKEY, EncryptionKey.class);
}
/**
* Sets the client's encryption key
* @param subKey The client's encryption key to store
*/
public void setSubKey(EncryptionKey subKey) {
setFieldAs(AuthenticatorField.SUBKEY, subKey);
}
/**
* @return The initial sequence number
*/
public int getSeqNumber() {
return getFieldAsInt(AuthenticatorField.SEQ_NUMBER);
}
/**
* Sets the initial sequence number
* @param seqNumber The initial sequence number to store
*/
public void setSeqNumber(Integer seqNumber) {
setFieldAsInt(AuthenticatorField.SEQ_NUMBER, seqNumber);
}
/**
* @return The stored Authorization-Data
*/
public AuthorizationData getAuthorizationData() {
return getFieldAs(AuthenticatorField.AUTHORIZATION_DATA, AuthorizationData.class);
}
/**
* Sets the stored Authorization-Data
* @param authorizationData The Authorization-Data to store
*/
public void setAuthorizationData(AuthorizationData authorizationData) {
setFieldAs(AuthenticatorField.AUTHORIZATION_DATA, authorizationData);
}
}
| 63 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastFinished.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
/**
KrbFastFinished ::= SEQUENCE {
timestamp [0] KerberosTime,
usec [1] Microseconds,
-- timestamp and usec represent the time on the KDC when
-- the reply was generated.
crealm [2] Realm,
cname [3] PrincipalName,
-- Contains the client realm and the client name.
ticket-checksum [4] Checksum,
-- checksum of the ticket in the KDC-REP using the armor
-- and the key usage is KEY_USAGE_FAST_FINISH.
-- The checksum type is the required checksum type
-- of the armor key.
}
*/
public class KrbFastFinished extends KrbSequenceType {
protected enum KrbFastFinishedField implements EnumType {
FAST_OPTIONS,
PADATA,
REQ_BODY;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastFinishedField.FAST_OPTIONS, KrbFastArmor.class),
new ExplicitField(KrbFastFinishedField.PADATA, PaData.class),
new ExplicitField(KrbFastFinishedField.REQ_BODY, EncryptedData.class),
};
public KrbFastFinished() {
super(fieldInfos);
}
public KrbFastArmor getArmor() {
return getFieldAs(KrbFastFinishedField.FAST_OPTIONS, KrbFastArmor.class);
}
public void setArmor(KrbFastArmor armor) {
setFieldAs(KrbFastFinishedField.FAST_OPTIONS, armor);
}
public CheckSum getReqChecksum() {
return getFieldAs(KrbFastFinishedField.PADATA, CheckSum.class);
}
public void setReqChecksum(CheckSum checkSum) {
setFieldAs(KrbFastFinishedField.PADATA, checkSum);
}
public EncryptedData getEncFastReq() {
return getFieldAs(KrbFastFinishedField.REQ_BODY, EncryptedData.class);
}
public void setEncFastReq(EncryptedData encFastReq) {
setFieldAs(KrbFastFinishedField.REQ_BODY, encFastReq);
}
}
| 64 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastResponse.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
/**
KrbFastResponse ::= SEQUENCE {
padata [0] SEQUENCE OF PA-DATA,
-- padata typed holes.
strengthen-key [1] EncryptionKey OPTIONAL,
-- This, if present, strengthens the reply key for AS and
-- TGS. MUST be present for TGS.
-- MUST be absent in KRB-ERROR.
finished [2] KrbFastFinished OPTIONAL,
-- Present in AS or TGS reply; absent otherwise.
nonce [3] UInt32,
-- Nonce from the client request.
}
*/
public class KrbFastResponse extends KrbSequenceType {
protected enum KrbFastResponseField implements EnumType {
PADATA,
STRENGTHEN_KEY,
FINISHED,
NONCE;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastResponseField.PADATA, PaData.class),
new ExplicitField(KrbFastResponseField.STRENGTHEN_KEY, EncryptionKey.class),
new ExplicitField(KrbFastResponseField.FINISHED, KrbFastFinished.class),
new ExplicitField(KrbFastResponseField.NONCE, Asn1Integer.class)
};
public KrbFastResponse() {
super(fieldInfos);
}
public PaData getPaData() {
return getFieldAs(KrbFastResponseField.PADATA, PaData.class);
}
public void setPaData(PaData paData) {
setFieldAs(KrbFastResponseField.PADATA, paData);
}
public EncryptionKey getStrengthenKey() {
return getFieldAs(KrbFastResponseField.STRENGTHEN_KEY, EncryptionKey.class);
}
public void setStrengthenKey(EncryptionKey strengthenKey) {
setFieldAs(KrbFastResponseField.STRENGTHEN_KEY, strengthenKey);
}
public KrbFastFinished getFastFinished() {
return getFieldAs(KrbFastResponseField.FINISHED, KrbFastFinished.class);
}
public void setFastFinished(KrbFastFinished fastFinished) {
setFieldAs(KrbFastResponseField.FINISHED, fastFinished);
}
public int getNonce() {
return getFieldAsInt(KrbFastResponseField.NONCE);
}
public void setNonce(int nonce) {
setFieldAsInt(KrbFastResponseField.NONCE, nonce);
}
}
| 65 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredRep.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
/**
KrbFastArmoredRep ::= SEQUENCE {
enc-fast-rep [0] EncryptedData, -- KrbFastResponse --
-- The encryption key is the armor key in the request, and
-- the key usage number is KEY_USAGE_FAST_REP.
}
*/
public class KrbFastArmoredRep extends KrbSequenceType {
protected enum KrbFastArmoredRepField implements EnumType {
ENC_FAST_REP;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
//private
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastArmoredRepField.ENC_FAST_REP, EncryptedData.class)
};
public KrbFastArmoredRep() {
super(fieldInfos);
}
public EncryptedData getEncFastRep() {
return getFieldAs(KrbFastArmoredRepField.ENC_FAST_REP, EncryptedData.class);
}
public void setEncFastRep(EncryptedData encFastRep) {
setFieldAs(KrbFastArmoredRepField.ENC_FAST_REP, encFastRep);
}
}
| 66 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/PaFxFastRequest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Choice;
/**
PA-FX-FAST-REQUEST ::= CHOICE {
armored-data [0] KrbFastArmoredReq,
}
*/
public class PaFxFastRequest extends Asn1Choice {
protected enum PaFxFastRequestField implements EnumType {
ARMORED_DATA;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaFxFastRequestField.ARMORED_DATA, KrbFastArmoredReq.class)
};
public PaFxFastRequest() {
super(fieldInfos);
}
public KrbFastArmoredReq getFastArmoredReq() {
return getChoiceValueAs(PaFxFastRequestField.ARMORED_DATA, KrbFastArmoredReq.class);
}
public void setFastArmoredReq(KrbFastArmoredReq fastArmoredReq) {
setChoiceValue(PaFxFastRequestField.ARMORED_DATA, fastArmoredReq);
}
}
| 67 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmor.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
KrbFastArmor ::= SEQUENCE {
armor-type [0] Int32,
-- Type of the armor.
armor-value [1] OCTET STRING,
-- Value of the armor.
}
*/
public class KrbFastArmor extends KrbSequenceType {
protected enum KrbFastArmorField implements EnumType {
ARMOR_TYPE,
ARMOR_VALUE;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastArmorField.ARMOR_TYPE, Asn1Integer.class),
new ExplicitField(KrbFastArmorField.ARMOR_VALUE, Asn1OctetString.class)
};
public KrbFastArmor() {
super(fieldInfos);
}
public ArmorType getArmorType() {
Integer value = getFieldAsInteger(KrbFastArmorField.ARMOR_TYPE);
return ArmorType.fromValue(value);
}
public void setArmorType(ArmorType armorType) {
setFieldAsInt(KrbFastArmorField.ARMOR_TYPE, armorType.getValue());
}
public byte[] getArmorValue() {
return getFieldAsOctets(KrbFastArmorField.ARMOR_VALUE);
}
public void setArmorValue(byte[] armorValue) {
setFieldAsOctets(KrbFastArmorField.ARMOR_VALUE, armorValue);
}
}
| 68 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOptions.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.type.Asn1Flags;
public class FastOptions extends Asn1Flags {
public FastOptions() {
this(0);
}
public FastOptions(int value) {
setFlags(value);
}
}
| 69 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredReq.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
/**
KrbFastArmoredReq ::= SEQUENCE {
armor [0] KrbFastArmor OPTIONAL,
-- Contains the armor that identifies the armor key.
-- MUST be present in AS-REQ.
req-checksum [1] Checksum,
-- For AS, contains the checksum performed over the type
-- KDC-REQ-BODY for the req-body field of the KDC-REQ
-- structure;
-- For TGS, contains the checksum performed over the type
-- AP-REQ in the PA-TGS-REQ padata.
-- The checksum key is the armor key, the checksum
-- type is the required checksum type for the enctype of
-- the armor key, and the key usage number is
-- KEY_USAGE_FAST_REQ_CHKSUM.
enc-fast-req [2] EncryptedData, -- KrbFastReq --
-- The encryption key is the armor key, and the key usage
-- number is KEY_USAGE_FAST_ENC.
}
*/
public class KrbFastArmoredReq extends KrbSequenceType {
protected enum KrbFastArmoredReqField implements EnumType {
ARMOR,
REQ_CHECKSUM,
ENC_FAST_REQ;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
private KrbFastReq fastReq;
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastArmoredReqField.ARMOR, KrbFastArmor.class),
new ExplicitField(KrbFastArmoredReqField.REQ_CHECKSUM, CheckSum.class),
new ExplicitField(KrbFastArmoredReqField.ENC_FAST_REQ, EncryptedData.class),
};
public KrbFastArmoredReq() {
super(fieldInfos);
}
public KrbFastArmor getArmor() {
return getFieldAs(KrbFastArmoredReqField.ARMOR, KrbFastArmor.class);
}
public void setArmor(KrbFastArmor armor) {
setFieldAs(KrbFastArmoredReqField.ARMOR, armor);
}
public CheckSum getReqChecksum() {
return getFieldAs(KrbFastArmoredReqField.REQ_CHECKSUM, CheckSum.class);
}
public void setReqChecksum(CheckSum checkSum) {
setFieldAs(KrbFastArmoredReqField.REQ_CHECKSUM, checkSum);
}
public KrbFastReq getFastReq() {
return fastReq;
}
public void setFastReq(KrbFastReq fastReq) {
this.fastReq = fastReq;
}
public EncryptedData getEncryptedFastReq() {
return getFieldAs(KrbFastArmoredReqField.ENC_FAST_REQ, EncryptedData.class);
}
public void setEncryptedFastReq(EncryptedData encFastReq) {
setFieldAs(KrbFastArmoredReqField.ENC_FAST_REQ, encFastReq);
}
}
| 70 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/PaAuthnEntry.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.pa.PaDataType;
/**
PA-AUTHENTICATION-SET-ELEM ::= SEQUENCE {
pa-type [0] Int32,
pa-hint [1] OCTET STRING OPTIONAL,
pa-value [2] OCTET STRING OPTIONAL,
}
*/
public class PaAuthnEntry extends KrbSequenceType {
protected enum PaAuthnEntryField implements EnumType {
PA_TYPE,
PA_HINT,
PA_VALUE;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaAuthnEntryField.PA_TYPE, Asn1Integer.class),
new ExplicitField(PaAuthnEntryField.PA_HINT, Asn1OctetString.class),
new ExplicitField(PaAuthnEntryField.PA_VALUE, Asn1OctetString.class)
};
public PaAuthnEntry() {
super(fieldInfos);
}
public PaAuthnEntry(PaDataType type, byte[] paData) {
this();
setPaType(type);
setPaValue(paData);
}
public PaDataType getPaType() {
Integer value = getFieldAsInteger(PaAuthnEntryField.PA_TYPE);
return PaDataType.fromValue(value);
}
public void setPaType(PaDataType paDataType) {
setFieldAsInt(PaAuthnEntryField.PA_TYPE, paDataType.getValue());
}
public byte[] getPaHint() {
return getFieldAsOctets(PaAuthnEntryField.PA_HINT);
}
public void setPaHint(byte[] paHint) {
setFieldAsOctets(PaAuthnEntryField.PA_HINT, paHint);
}
public byte[] getPaValue() {
return getFieldAsOctets(PaAuthnEntryField.PA_VALUE);
}
public void setPaValue(byte[] paValue) {
setFieldAsOctets(PaAuthnEntryField.PA_VALUE, paValue);
}
}
| 71 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOption.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.EnumType;
public enum FastOption implements EnumType {
NONE(-1),
RESERVED(0),
HIDE_CLIENT_NAMES(1),
KDC_FOLLOW_REFERRALS(16);
private final int value;
FastOption(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
@Override
public String getName() {
return name();
}
public static FastOption fromValue(int value) {
for (EnumType e : values()) {
if (e.getValue() == value) {
return (FastOption) e;
}
}
return NONE;
}
}
| 72 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/ArmorType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.EnumType;
public enum ArmorType implements EnumType {
NONE (0),
ARMOR_AP_REQUEST (1);
private final int value;
ArmorType(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
@Override
public String getName() {
return name();
}
public static ArmorType fromValue(Integer value) {
if (value != null) {
for (EnumType e : values()) {
if (e.getValue() == value.intValue()) {
return (ArmorType) e;
}
}
}
return NONE;
}
}
| 73 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastReq.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
import org.apache.kerby.kerberos.kerb.type.pa.PaData;
/**
KrbFastReq ::= SEQUENCE {
fast-options [0] FastOptions,
-- Additional options.
padata [1] SEQUENCE OF PA-DATA,
-- padata typed holes.
req-body [2] KDC-REQ-BODY,
-- Contains the KDC request body as defined in Section
-- 5.4.1 of [RFC4120].
-- This req-body field is preferred over the outer field
-- in the KDC request.
}
*/
public class KrbFastReq extends KrbSequenceType {
protected enum KrbFastReqField implements EnumType {
FAST_OPTIONS,
PADATA,
REQ_BODY;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KrbFastReqField.FAST_OPTIONS, FastOptions.class),
new ExplicitField(KrbFastReqField.PADATA, PaData.class),
new ExplicitField(KrbFastReqField.REQ_BODY, KdcReqBody.class),
};
public KrbFastReq() {
super(fieldInfos);
}
public FastOptions getFastOptions() {
return getFieldAs(KrbFastReqField.FAST_OPTIONS, FastOptions.class);
}
public void setFastOptions(FastOptions fastOptions) {
setFieldAs(KrbFastReqField.FAST_OPTIONS, fastOptions);
}
public PaData getPaData() {
return getFieldAs(KrbFastReqField.PADATA, PaData.class);
}
public void setPaData(PaData paData) {
setFieldAs(KrbFastReqField.PADATA, paData);
}
public KdcReqBody getKdcReqBody() {
return getFieldAs(KrbFastReqField.REQ_BODY, KdcReqBody.class);
}
public void setKdcReqBody(KdcReqBody kdcReqBody) {
setFieldAs(KrbFastReqField.REQ_BODY, kdcReqBody);
}
} | 74 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/PaAuthnSet.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
PA-AUTHENTICATION-SET ::= SEQUENCE OF PA-AUTHENTICATION-SET-ELEM
*/
public class PaAuthnSet extends KrbSequenceOfType<PaAuthnEntry> {
}
| 75 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/PaFxFastReply.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.fast;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Choice;
/**
PA-FX-FAST-REPLY ::= CHOICE {
armored-data [0] KrbFastArmoredRep,
}
*/
public class PaFxFastReply extends Asn1Choice {
protected enum PaFxFastReplyField implements EnumType {
ARMORED_DATA;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaFxFastReplyField.ARMORED_DATA, KrbFastArmoredRep.class)
};
public PaFxFastReply() {
super(fieldInfos);
}
public KrbFastArmoredRep getFastArmoredRep() {
return getChoiceValueAs(PaFxFastReplyField.ARMORED_DATA, KrbFastArmoredRep.class);
}
public void setFastArmoredRep(KrbFastArmoredRep fastArmoredRep) {
setChoiceValue(PaFxFastReplyField.ARMORED_DATA, fastArmoredRep);
}
}
| 76 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaEncTsEnc.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.kerberos.kerb.type.KerberosTime;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
PA-ENC-TS-ENC ::= SEQUENCE {
patimestamp [0] KerberosTime -- client's time --,
pausec [1] Microseconds OPTIONAL
}
*/
public class PaEncTsEnc extends KrbSequenceType {
protected enum PaEncTsEncField implements EnumType {
PATIMESTAMP,
PAUSEC;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaEncTsEncField.PATIMESTAMP, KerberosTime.class),
new ExplicitField(PaEncTsEncField.PAUSEC, Asn1Integer.class)
};
public PaEncTsEnc() {
super(fieldInfos);
}
public KerberosTime getPaTimestamp() {
return getFieldAsTime(PaEncTsEncField.PATIMESTAMP);
}
public void setPaTimestamp(KerberosTime paTimestamp) {
setFieldAs(PaEncTsEncField.PATIMESTAMP, paTimestamp);
}
public int getPaUsec() {
return getFieldAsInt(PaEncTsEncField.PAUSEC);
}
public void setPaUsec(int paUsec) {
setFieldAsInt(PaEncTsEncField.PAUSEC, paUsec);
}
public KerberosTime getAllTime() {
KerberosTime paTimestamp = getPaTimestamp();
return paTimestamp.extend(getPaUsec() / 1000);
}
}
| 77 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaAuthenticationSet.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
PA-AUTHENTICATION-SET ::= SEQUENCE OF PA-AUTHENTICATION-SET-ELEM
*/
public class PaAuthenticationSet extends KrbSequenceOfType<PaAuthenticationSetElem> {
}
| 78 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaDataEntry.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
* The PaData component as defined in RFC 4120 :
*
* <pre>
* PA-DATA ::= SEQUENCE {
* -- NOTE: first tag is [1], not [0]
* padata-type [1] Int32,
* padata-value [2] OCTET STRING -- might be encoded AP-REQ
* }
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PaDataEntry extends KrbSequenceType {
/**
* The possible fields
*/
protected enum PaDataEntryField implements EnumType {
PADATA_TYPE,
PADATA_VALUE;
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return ordinal();
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
}
/** The PaDataEntrey's fields */
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaDataEntryField.PADATA_TYPE, 1, Asn1Integer.class),
new ExplicitField(PaDataEntryField.PADATA_VALUE, 2, Asn1OctetString.class)
};
/**
* Creates an empty PaDataEntry instance
*/
public PaDataEntry() {
super(fieldInfos);
}
/**
* Creates a PaDataEntry instance with a type and a value
*
* @param type the {@link PaDataType} to use
* @param paData the data to store
*/
public PaDataEntry(PaDataType type, byte[] paData) {
super(fieldInfos);
setPaDataType(type);
setPaDataValue(paData);
}
/**
* @return The {@link PaDataType} for this instance
*/
public PaDataType getPaDataType() {
Integer value = getFieldAsInteger(PaDataEntryField.PADATA_TYPE);
return PaDataType.fromValue(value);
}
/**
* Sets a {@link PaDataType} in this instance
*
* @param paDataType The {@link PaDataType} type to store
*/
public void setPaDataType(PaDataType paDataType) {
setFieldAsInt(PaDataEntryField.PADATA_TYPE, paDataType.getValue());
}
/**
* @return The data stored in this instance
*/
public byte[] getPaDataValue() {
return getFieldAsOctets(PaDataEntryField.PADATA_VALUE);
}
/**
* Sets some data in this instance
*
* @param paDataValue The data to store
*/
public void setPaDataValue(byte[] paDataValue) {
setFieldAsOctets(PaDataEntryField.PADATA_VALUE, paDataValue);
}
}
| 79 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaData.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* The PaData Sequence as defined in RFC 4120, like in :
*
* <pre>
* ...
* padata [3] SEQUENCE OF PA-DATA
* ...
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PaData extends KrbSequenceOfType<PaDataEntry> {
/**
* Find a PaData from its type
*
* @param paType The {@link PaDataType}
* @return An instance of {@link PaDataEntry}, or null if not found
*/
public PaDataEntry findEntry(PaDataType paType) {
for (PaDataEntry pae : getElements()) {
if (pae.getPaDataType() == paType) {
return pae;
}
}
return null;
}
}
| 80 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaAuthenticationSetElem.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1Integer;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
PA-AUTHENTICATION-SET-ELEM ::= SEQUENCE {
pa-type [0] Int32,
-- same as padata-type.
pa-hint [1] OCTET STRING OPTIONAL,
pa-value [2] OCTET STRING OPTIONAL
}
*/
public class PaAuthenticationSetElem extends KrbSequenceType {
protected enum PaAuthenticationSetElemField implements EnumType {
PA_TYPE,
PA_HINT,
PA_VALUE;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaAuthenticationSetElemField.PA_TYPE, Asn1Integer.class),
new ExplicitField(PaAuthenticationSetElemField.PA_HINT, Asn1OctetString.class),
new ExplicitField(PaAuthenticationSetElemField.PA_VALUE, Asn1OctetString.class)
};
public PaAuthenticationSetElem() {
super(fieldInfos);
}
public PaDataType getPaType() {
Integer value = getFieldAsInteger(PaAuthenticationSetElemField.PA_TYPE);
return PaDataType.fromValue(value);
}
public void setPaType(PaDataType paDataType) {
setFieldAsInt(PaAuthenticationSetElemField.PA_TYPE, paDataType.getValue());
}
public byte[] getPaHint() {
return getFieldAsOctets(PaAuthenticationSetElemField.PA_HINT);
}
public void setPaHint(byte[] paHint) {
setFieldAsOctets(PaAuthenticationSetElemField.PA_HINT, paHint);
}
public byte[] getPaValue() {
return getFieldAsOctets(PaAuthenticationSetElemField.PA_VALUE);
}
public void setPaValue(byte[] paDataValue) {
setFieldAsOctets(PaAuthenticationSetElemField.PA_VALUE, paDataValue);
}
}
| 81 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/PaDataType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa;
import org.apache.kerby.asn1.EnumType;
/**
* The various pre-authorization types, as defined in RFC 4120, RFC 3961, RFC 4556, RFC 6820,
* RFC 6112, RFC 6113, RFC 6560 and RFC 6806.
*
* From RFC 4120 :
* <pre>
* 7.5.2. PreAuthentication Data Types
*
* Padata and Data Type Padata-type Comment
* Value
*
* PA-TGS-REQ 1
* PA-ENC-TIMESTAMP 2
* PA-PW-SALT 3
* [reserved] 4
* PA-ENC-UNIX-TIME 5 (deprecated)
* PA-SANDIA-SECUREID 6
* PA-SESAME 7
* PA-OSF-DCE 8
* PA-CYBERSAFE-SECUREID 9
* PA-AFS3-SALT 10
* PA-ETYPE-INFO 11
* PA-SAM-CHALLENGE 12 (sam/otp)
* PA-SAM-RESPONSE 13 (sam/otp)
* PA-PK-AS-REQ_OLD 14 (pkinit)
* PA-PK-AS-REP_OLD 15 (pkinit)
* PA-PK-AS-REQ 16 (pkinit)
* PA-PK-AS-REP 17 (pkinit)
* PA-ETYPE-INFO2 19 (replaces pa-etype-info)
* PA-USE-SPECIFIED-KVNO 20
* PA-SAM-REDIRECT 21 (sam/otp)
* PA-GET-FROM-TYPED-DATA 22 (embedded in typed data)
* TD-PADATA 22 (embeds padata)
* PA-SAM-ETYPE-INFO 23 (sam/otp)
* PA-ALT-PRINC 24 (crawdad@fnal.gov)
* PA-SAM-CHALLENGE2 30 (kenh@pobox.com)
* PA-SAM-RESPONSE2 31 (kenh@pobox.com)
* PA-EXTRA-TGT 41 Reserved extra TGT
* TD-PKINIT-CMS-CERTIFICATES 101 CertificateSet from CMS
* TD-KRB-PRINCIPAL 102 PrincipalName
* TD-KRB-REALM 103 Realm
* TD-TRUSTED-CERTIFIERS 104 from PKINIT
* TD-CERTIFICATE-INDEX 105 from PKINIT
* TD-APP-DEFINED-ERROR 106 application specific
* TD-REQ-NONCE 107 INTEGER
* TD-REQ-SEQ 108 INTEGER
* PA-PAC-REQUEST 128 (jbrezak@exchange.microsoft.com)
* </pre>
*
* From RFC 6113 :
* <pre>
* PA-FOR_USER 129 [MS-KILE]
* PA-FOR-X509-USER 130 [MS-KILE]
* PA-FOR-CHECK_DUPS 131 [MS-KILE]
* PA-AS-CHECKSUM 132 [MS-KILE]
* PA-FX-COOKIE 133 [RFC6113]
* PA-AUTHENTICATION-SET 134 [RFC6113]
* PA-AUTH-SET-SELECTED 135 [RFC6113]
* PA-FX-FAST 136 [RFC6113]
* PA-FX-ERROR 137 [RFC6113]
* PA-ENCRYPTED-CHALLENGE 138 [RFC6113]
* PA-OTP-CHALLENGE 141 (gareth.richards@rsa.com) [OTP-PREAUTH]
* PA-OTP-REQUEST 142 (gareth.richards@rsa.com) [OTP-PREAUTH]
* PA-OTP-CONFIRM 143 (gareth.richards@rsa.com) [OTP-PREAUTH]
* PA-OTP-PIN-CHANGE 144 (gareth.richards@rsa.com) [OTP-PREAUTH]
* PA-EPAK-AS-REQ 145 (sshock@gmail.com) [RFC6113]
* PA-EPAK-AS-REP 146 (sshock@gmail.com) [RFC6113]
* PA_PKINIT_KX 147 [RFC6112]
* PA_PKU2U_NAME 148 [PKU2U]
* PA_PAC_OPTIONS 167 [Microsoft MS-KILE]
* </pre>
*
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public enum PaDataType implements EnumType {
NONE (0),
TGS_REQ (1), // RFC 4120 : DER encoding of AP-REQ
AP_REQ (1), // same
ENC_TIMESTAMP (2), // RFC 4120 : DER encoding of PA-ENC-TIMESTAMP
PW_SALT (3), // RFC 4120 : salt (not ASN.1 encoded)
ENC_ENCKEY (4), // RFC 4120 : [reserved] Key encrypted within itself
ENC_UNIX_TIME (5), // RFC 4120 : deprecated (timestamp encrypted in key )
ENC_SANDIA_SECURID (6), // RFC 4120 : SecureId passcode
SESAME (7), // RFC 4120 : Sesame project
OSF_DCE (8), // RFC 4120 : OSF DCE
CYBERSAFE_SECUREID (9), // RFC 4120 : Cybersafe
AFS3_SALT (10), // RFC 4120 :
ETYPE_INFO (11), // RFC 4120 : DER encoding of ETYPE-INFO
SAM_CHALLENGE (12), // RFC 4120 : SAM/OTP
SAM_RESPONSE (13), // RFC 4120 : SAM/OTP
PK_AS_REQ_OLD (14), // RFC 4120 : pkinit
PK_AS_REP_OLD (15), // RFC 4120 : pkinit
PK_AS_REQ (16), // RFC 4120 : pkinit
PK_AS_REP (17), // RFC 4120 : pkinit
// 18 is undefined
ETYPE_INFO2 (19), // RFC 4120 : DER encoding of ETYPE-INFO2
USE_SPECIFIED_KVNO (20), // RFC 4120
SVR_REFERRAL_INFO (20), // RFC 6806 : Kerberos Principal Name Canonicalization and Cross-Realm Referrals
SAM_REDIRECT (21), // RFC 4120 : SAM/OTP
GET_FROM_TYPED_DATA (22), // RFC 4120 : Embedded in typed data
//SAM_ETYPE_INFO (23), // RFC 4120 : SAM/OTP
//ALT_PRINC (24), // RFC 4120 : crawdad@fnal.gov
REFERRAL (25), // draft-ietf-krb-wg-kerberos-referrals, up to version 11. Removed
// 26 to 29 undefined
SAM_CHALLENGE_2 (30), // kenh@pobox.com
SAM_RESPONSE_2 (31), // kenh@pobox.com
// 32 to 40 are undefined
//EXTRA_TGT (41), // RFC 4120 : Reserved extra TGT
//TD_PKINIT-CMS_CERTIFICATES(101), // RFC 4120 : CertificateSet from CMS
//TD_KRB_PRINCIPAL (102), // RFC 4120 : PrincipalName
//TD_KRB_REALM (103), // RFC 4120 : Realm
//TD_TRUSTED_CERTIFIERS (104), // RFC 4120 : from PKINIT
//TD_CERTIFICATE_INDEX (105), // RFC 4120 : from PKINIT
//TD_APP_DEFINED_ERROR (106), // RFC 4120 : application specific
//TD_REQ_NONCE (107), // RFC 4120 : INTEGER
//TD_REQ_SEQ (108), // RFC 4120 : INTEGER
/* MS-KILE */
PAC_REQUEST (128), // Microsoft, "Kerberos Protocol Extensions"
FOR_USER (129), // Microsoft, "Kerberos Protocol Extensions"
S4U_X509_USER (130), // Microsoft, "Kerberos Protocol Extensions"
// 131 undefined, Microsoft, "Kerberos Protocol Extensions"
AS_CHECKSUM (132), // Microsoft, "Kerberos Protocol Extensions"
FX_COOKIE (133), // RFC 6113 : Managing States for the KDC
// 134 and 135 undefined
//AUTHENTICATION_SET (134), // RFC 6113 : Pre-Authentication Set
//AUTH_SET_SELECTED (135), // RFC 6113 : Pre-Authentication Set
FX_FAST (136), // RFC 6113 : FAST Request
FX_ERROR (137), // RFC 6113 : Authenticated Kerberos Error Messages Using Kerberos FAST
ENCRYPTED_CHALLENGE (138), // RFC 6113 : The Encrypted Challenge FAST Factor
// 139 and 140 undefined
OTP_CHALLENGE (141), // RFC 6560 : One-Time Password pre-auth section 4.1
OTP_REQUEST (142), // RFC 6560 : One-Time Password pre-auth section 4.2
// 143 undefined
OTP_PIN_CHANGE (144), // RFC 6560 : One-Time Password pre-auth section 4.3
// 145 and 146 undefined
PKINIT_KX (147), // RFC 6112 : PKINIT Client Contribution to the Ticket Session Key
TOKEN_REQUEST (148), // [PKU2U]
ENCPADATA_REQ_ENC_PA_REP (149), // RFC 6806 : Negotiation of FAST and Detecting Modified Requests
TOKEN_CHALLENGE (149), // ???
PAC_OPTIONS (167); // Microsoft MS-KILE
/** The inner value */
private final int value;
/**
* Create a new enum instance
*/
PaDataType(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
@Override
public int getValue() {
return value;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name();
}
/**
* Get the PaDataType associated with a value.
*
* @param value The integer value of the PaDataType we are looking for
* @return The associated PaDataType, or NONE if not found or if value is null
*/
public static PaDataType fromValue(Integer value) {
if (value != null) {
for (EnumType e : values()) {
if (e.getValue() == value.intValue()) {
return (PaDataType) e;
}
}
}
return NONE;
}
}
| 82 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/TokenFlag.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.asn1.EnumType;
public enum TokenFlag implements EnumType {
NONE(-1),
ID_TOKEN_REQUIRED(0x40000000),
AC_TOKEN_REQUIRED(0x20000000),
BEARER_TOKEN_REQUIRED(0x10000000),
HOK_TOKEN_REQUIRED(0x08000000);
private final int value;
TokenFlag(int value) {
this.value = value;
}
@Override
public int getValue() {
return value;
}
@Override
public String getName() {
return name();
}
public static TokenFlag fromValue(int value) {
for (EnumType e : values()) {
if (e.getValue() == value) {
return (TokenFlag) e;
}
}
return NONE;
}
}
| 83 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/TokenInfos.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
SEQUENCE (SIZE(1..MAX)) OF TokenInfo,
*/
public class TokenInfos extends KrbSequenceOfType<TokenInfo> {
}
| 84 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/PaTokenRequest.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.KrbTokenBase;
/**
PA-TOKEN-REQUEST ::= SEQUENCE {
token [0] OCTET STRING,
tokenInfo [1] TokenInfo
}
*/
public class PaTokenRequest extends KrbSequenceType {
protected enum PaTokenRequestField implements EnumType {
TOKEN_INFO,
TOKEN;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaTokenRequestField.TOKEN_INFO, TokenInfo.class),
new ExplicitField(PaTokenRequestField.TOKEN, KrbTokenBase.class)
};
public PaTokenRequest() {
super(fieldInfos);
}
public KrbTokenBase getToken() {
return getFieldAs(PaTokenRequestField.TOKEN, KrbTokenBase.class);
}
public void setToken(KrbTokenBase token) {
setFieldAs(PaTokenRequestField.TOKEN, token);
}
public TokenInfo getTokenInfo() {
return getFieldAs(PaTokenRequestField.TOKEN_INFO, TokenInfo.class);
}
public void setTokenInfo(TokenInfo tokenInfo) {
setFieldAs(PaTokenRequestField.TOKEN_INFO, tokenInfo);
}
}
| 85 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/TokenInfo.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.asn1.type.Asn1Utf8String;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
TokenInfo ::= SEQUENCE {
flags [0] TokenFlags,
tokenVendor [1] UTF8String,
}
*/
public class TokenInfo extends KrbSequenceType {
protected enum TokenInfoField implements EnumType {
FLAGS,
TOKEN_VENDOR;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(TokenInfoField.FLAGS, Asn1OctetString.class),
new ExplicitField(TokenInfoField.TOKEN_VENDOR, Asn1Utf8String.class),
};
public TokenInfo() {
super(fieldInfos);
}
public TokenFlags getFlags() {
return getFieldAs(TokenInfoField.FLAGS, TokenFlags.class);
}
public void setFlags(TokenFlags flags) {
setFieldAs(TokenInfoField.FLAGS, flags);
}
public String getTokenVendor() {
return getFieldAsString(TokenInfoField.TOKEN_VENDOR);
}
public void setTokenVendor(String tokenVendor) {
setFieldAs(TokenInfoField.TOKEN_VENDOR, new Asn1Utf8String(tokenVendor));
}
}
| 86 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/TokenFlags.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.asn1.type.Asn1Flags;
import static org.apache.kerby.kerberos.kerb.type.ticket.TicketFlag.INVALID;
public class TokenFlags extends Asn1Flags {
public TokenFlags() {
this(0);
}
public TokenFlags(int value) {
setFlags(value);
}
public boolean isInvalid() {
return isFlagSet(INVALID.getValue());
}
}
| 87 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/token/PaTokenChallenge.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.token;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
PA-TOKEN-CHALLENGE ::= SEQUENCE {
tokenInfos [0] SEQUENCE (SIZE(1..MAX)) OF TokenInfo,
}
*/
public class PaTokenChallenge extends KrbSequenceType {
protected enum PaTokenChallengeField implements EnumType {
TOKENINFOS;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(PaTokenChallengeField.TOKENINFOS, TokenInfos.class)
};
public PaTokenChallenge() {
super(fieldInfos);
}
}
| 88 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/AdInitialVerifiedCas.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
* AD-INITIAL-VERIFIED-CAS ::= SEQUENCE OF ExternalPrincipalIdentifier
*/
public class AdInitialVerifiedCas extends KrbSequenceOfType<ExternalPrincipalIdentifier> {
}
| 89 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/DhRepInfo.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.ImplicitField;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
DhRepInfo ::= SEQUENCE {
dhSignedData [0] IMPLICIT OCTET STRING,
serverDHNonce [1] DHNonce OPTIONAL
kdf [2] KDFAlgorithmId OPTIONAL,
-- The KDF picked by the KDC.
}
*/
public class DhRepInfo extends KrbSequenceType {
protected enum DhRepInfoField implements EnumType {
DH_SIGNED_DATA,
SERVER_DH_NONCE,
KDF_ID;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ImplicitField(DhRepInfoField.DH_SIGNED_DATA, Asn1OctetString.class),
new ExplicitField(DhRepInfoField.SERVER_DH_NONCE, DhNonce.class),
new ExplicitField(DhRepInfoField.KDF_ID, KdfAlgorithmId.class)
};
public DhRepInfo() {
super(fieldInfos);
}
public byte[] getDHSignedData() {
return getFieldAsOctets(DhRepInfoField.DH_SIGNED_DATA);
}
public void setDHSignedData(byte[] dhSignedData) {
setFieldAsOctets(DhRepInfoField.DH_SIGNED_DATA, dhSignedData);
}
public DhNonce getServerDhNonce() {
return getFieldAs(DhRepInfoField.SERVER_DH_NONCE, DhNonce.class);
}
public void setServerDhNonce(DhNonce dhNonce) {
setFieldAs(DhRepInfoField.SERVER_DH_NONCE, dhNonce);
}
public KdfAlgorithmId getKdfId() {
return getFieldAs(DhRepInfoField.KDF_ID, KdfAlgorithmId.class);
}
public void setKdfId(KdfAlgorithmId kdfId) {
setFieldAs(DhRepInfoField.KDF_ID, kdfId);
}
}
| 90 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/AlgorithmIdentifiers.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
import org.apache.kerby.x509.type.AlgorithmIdentifier;
/**
trustedCertifiers SEQUENCE OF AlgorithmIdentifier OPTIONAL,
*/
public class AlgorithmIdentifiers extends KrbSequenceOfType<AlgorithmIdentifier> {
}
| 91 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/ReplyKeyPack.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
/**
ReplyKeyPack ::= SEQUENCE {
replyKey [0] EncryptionKey,
asChecksum [1] Checksum,
}
*/
public class ReplyKeyPack extends KrbSequenceType {
protected enum ReplyKeyPackField implements EnumType {
REPLY_KEY,
AS_CHECKSUM;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(ReplyKeyPackField.REPLY_KEY, EncryptionKey.class),
new ExplicitField(ReplyKeyPackField.AS_CHECKSUM, CheckSum.class)
};
public ReplyKeyPack() {
super(fieldInfos);
}
public EncryptionKey getReplyKey() {
return getFieldAs(ReplyKeyPackField.REPLY_KEY, EncryptionKey.class);
}
public void setReplyKey(EncryptionKey replyKey) {
setFieldAs(ReplyKeyPackField.REPLY_KEY, replyKey);
}
public CheckSum getAsChecksum() {
return getFieldAs(ReplyKeyPackField.AS_CHECKSUM, CheckSum.class);
}
public void setAsChecksum(CheckSum checkSum) {
setFieldAs(ReplyKeyPackField.AS_CHECKSUM, checkSum);
}
}
| 92 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/AuthPack.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
import org.apache.kerby.x509.type.SubjectPublicKeyInfo;
/**
AuthPack ::= SEQUENCE {
pkAuthenticator [0] PKAuthenticator,
clientPublicValue [1] SubjectPublicKeyInfo OPTIONAL,
supportedCMSTypes [2] SEQUENCE OF AlgorithmIdentifier OPTIONAL,
clientDHNonce [3] DHNonce OPTIONAL
supportedKDFs [4] SEQUENCE OF KDFAlgorithmId OPTIONAL,
-- Contains an unordered set of KDFs supported by the client.
KDFAlgorithmId ::= SEQUENCE {
kdf-id [0] OBJECT IDENTIFIER,
-- The object identifier of the KDF
}
*/
public class AuthPack extends KrbSequenceType {
protected enum AuthPackField implements EnumType {
PK_AUTHENTICATOR,
CLIENT_PUBLIC_VALUE,
SUPPORTED_CMS_TYPES,
CLIENT_DH_NONCE,
SUPPORTED_KDFS;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(AuthPackField.PK_AUTHENTICATOR, PkAuthenticator.class),
new ExplicitField(AuthPackField.CLIENT_PUBLIC_VALUE, SubjectPublicKeyInfo.class),
new ExplicitField(AuthPackField.SUPPORTED_CMS_TYPES, AlgorithmIdentifiers.class),
new ExplicitField(AuthPackField.CLIENT_DH_NONCE, DhNonce.class),
new ExplicitField(AuthPackField.SUPPORTED_KDFS, SupportedKdfs.class)
};
public AuthPack() {
super(fieldInfos);
}
public PkAuthenticator getPkAuthenticator() {
return getFieldAs(AuthPackField.PK_AUTHENTICATOR, PkAuthenticator.class);
}
public void setPkAuthenticator(PkAuthenticator pkAuthenticator) {
setFieldAs(AuthPackField.PK_AUTHENTICATOR, pkAuthenticator);
}
public SubjectPublicKeyInfo getClientPublicValue() {
return getFieldAs(AuthPackField.CLIENT_PUBLIC_VALUE, SubjectPublicKeyInfo.class);
}
public void setClientPublicValue(SubjectPublicKeyInfo clientPublicValue) {
setFieldAs(AuthPackField.CLIENT_PUBLIC_VALUE, clientPublicValue);
}
public AlgorithmIdentifiers getsupportedCmsTypes() {
return getFieldAs(AuthPackField.SUPPORTED_CMS_TYPES, AlgorithmIdentifiers.class);
}
public void setsupportedCmsTypes(AlgorithmIdentifiers supportedCMSTypes) {
setFieldAs(AuthPackField.SUPPORTED_CMS_TYPES, supportedCMSTypes);
}
public DhNonce getClientDhNonce() {
return getFieldAs(AuthPackField.CLIENT_DH_NONCE, DhNonce.class);
}
public void setClientDhNonce(DhNonce dhNonce) {
setFieldAs(AuthPackField.CLIENT_DH_NONCE, dhNonce);
}
public SupportedKdfs getsupportedKDFs() {
return getFieldAs(AuthPackField.SUPPORTED_KDFS, SupportedKdfs.class);
}
public void setsupportedKDFs(SupportedKdfs supportedKdfs) {
setFieldAs(AuthPackField.SUPPORTED_KDFS, supportedKdfs);
}
}
| 93 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/KdfAlgorithmId.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.type.Asn1ObjectIdentifier;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/*
KDFAlgorithmId ::= SEQUENCE {
kdf-id [0] OBJECT IDENTIFIER,
-- The object identifier of the KDF
}
*/
public class KdfAlgorithmId extends KrbSequenceType {
protected enum KdfAlgorithmIdField implements EnumType {
KDF_ID;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ExplicitField(KdfAlgorithmIdField.KDF_ID, Asn1ObjectIdentifier.class)
};
public KdfAlgorithmId() {
super(fieldInfos);
}
public String getKdfId() {
return getFieldAsObjId(KdfAlgorithmIdField.KDF_ID);
}
public void setKdfId(String kdfId) {
setFieldAsObjId(KdfAlgorithmIdField.KDF_ID, kdfId);
}
}
| 94 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/PaPkAsReq.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ExplicitField;
import org.apache.kerby.asn1.ImplicitField;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
PA-PK-AS-REQ ::= SEQUENCE {
signedAuthPack [0] IMPLICIT OCTET STRING,
trustedCertifiers [1] SEQUENCE OF ExternalPrincipalIdentifier OPTIONAL,
kdcPkId [2] IMPLICIT OCTET STRING OPTIONAL
}
*/
public class PaPkAsReq extends KrbSequenceType {
protected enum PaPkAsReqField implements EnumType {
SIGNED_AUTH_PACK,
TRUSTED_CERTIFIERS,
KDC_PKID;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ImplicitField(PaPkAsReqField.SIGNED_AUTH_PACK, Asn1OctetString.class),
new ExplicitField(PaPkAsReqField.TRUSTED_CERTIFIERS, TrustedCertifiers.class),
new ImplicitField(PaPkAsReqField.KDC_PKID, Asn1OctetString.class)
};
public PaPkAsReq() {
super(fieldInfos);
}
public byte[] getSignedAuthPack() {
return getFieldAsOctets(PaPkAsReqField.SIGNED_AUTH_PACK);
}
public void setSignedAuthPack(byte[] signedAuthPack) {
setFieldAsOctets(PaPkAsReqField.SIGNED_AUTH_PACK, signedAuthPack);
}
public TrustedCertifiers getTrustedCertifiers() {
return getFieldAs(PaPkAsReqField.TRUSTED_CERTIFIERS, TrustedCertifiers.class);
}
public void setTrustedCertifiers(TrustedCertifiers trustedCertifiers) {
setFieldAs(PaPkAsReqField.TRUSTED_CERTIFIERS, trustedCertifiers);
}
public byte[] getKdcPkId() {
return getFieldAsOctets(PaPkAsReqField.KDC_PKID);
}
public void setKdcPkId(byte[] kdcPkId) {
setFieldAsOctets(PaPkAsReqField.KDC_PKID, kdcPkId);
}
}
| 95 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/DhNonce.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.type.Asn1OctetString;
/**
* DHNonce ::= OCTET STRING
*/
public class DhNonce extends Asn1OctetString {
}
| 96 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/SupportedKdfs.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
public class SupportedKdfs extends KrbSequenceOfType<KdfAlgorithmId> {
}
| 97 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/ExternalPrincipalIdentifier.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.asn1.Asn1FieldInfo;
import org.apache.kerby.asn1.EnumType;
import org.apache.kerby.asn1.ImplicitField;
import org.apache.kerby.asn1.type.Asn1OctetString;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
/**
ExternalPrincipalIdentifier ::= SEQUENCE {
subjectName [0] IMPLICIT OCTET STRING OPTIONAL,
issuerAndSerialNumber [1] IMPLICIT OCTET STRING OPTIONAL,
subjectKeyIdentifier [2] IMPLICIT OCTET STRING OPTIONAL
}
*/
public class ExternalPrincipalIdentifier extends KrbSequenceType {
protected enum ExternalPrincipalIdentifierField implements EnumType {
SUBJECT_NAME,
ISSUER_AND_SERIAL_NUMBER,
SUBJECT_KEY_IDENTIFIER;
@Override
public int getValue() {
return ordinal();
}
@Override
public String getName() {
return name();
}
}
static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
new ImplicitField(ExternalPrincipalIdentifierField.SUBJECT_NAME, Asn1OctetString.class),
new ImplicitField(ExternalPrincipalIdentifierField.ISSUER_AND_SERIAL_NUMBER, Asn1OctetString.class),
new ImplicitField(ExternalPrincipalIdentifierField.SUBJECT_KEY_IDENTIFIER, Asn1OctetString.class)
};
public ExternalPrincipalIdentifier() {
super(fieldInfos);
}
public byte[] getSubjectName() {
return getFieldAsOctets(ExternalPrincipalIdentifierField.SUBJECT_NAME);
}
public void setSubjectName(byte[] subjectName) {
setFieldAsOctets(ExternalPrincipalIdentifierField.SUBJECT_NAME, subjectName);
}
public byte[] getIssuerSerialNumber() {
return getFieldAsOctets(ExternalPrincipalIdentifierField.ISSUER_AND_SERIAL_NUMBER);
}
public void setIssuerSerialNumber(byte[] issuerSerialNumber) {
setFieldAsOctets(ExternalPrincipalIdentifierField.ISSUER_AND_SERIAL_NUMBER, issuerSerialNumber);
}
public byte[] getSubjectKeyIdentifier() {
return getFieldAsOctets(ExternalPrincipalIdentifierField.SUBJECT_KEY_IDENTIFIER);
}
public void setSubjectKeyIdentifier(byte[] subjectKeyIdentifier) {
setFieldAsOctets(ExternalPrincipalIdentifierField.SUBJECT_KEY_IDENTIFIER, subjectKeyIdentifier);
}
}
| 98 |
0 | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa | Create_ds/directory-kerby/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/pa/pkinit/TrustedCertifiers.java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.kerby.kerberos.kerb.type.pa.pkinit;
import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
/**
trustedCertifiers SEQUENCE OF ExternalPrincipalIdentifier OPTIONAL,
*/
public class TrustedCertifiers extends KrbSequenceOfType<ExternalPrincipalIdentifier> {
}
| 99 |