id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
21,200
rubenlagus/TelegramBots
telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/DefaultBotCommand.java
DefaultBotCommand.execute
@Override public final void execute(AbsSender absSender, User user, Chat chat, String[] arguments) { }
java
@Override public final void execute(AbsSender absSender, User user, Chat chat, String[] arguments) { }
[ "@", "Override", "public", "final", "void", "execute", "(", "AbsSender", "absSender", ",", "User", "user", ",", "Chat", "chat", ",", "String", "[", "]", "arguments", ")", "{", "}" ]
We'll override this method here for not repeating it in DefaultBotCommand's children
[ "We", "ll", "override", "this", "method", "here", "for", "not", "repeating", "it", "in", "DefaultBotCommand", "s", "children" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-extensions/src/main/java/org/telegram/telegrambots/extensions/bots/commandbot/commands/DefaultBotCommand.java#L39-L41
21,201
rubenlagus/TelegramBots
telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java
DefaultAbsSender.execute
@Override public final Message execute(SendDocument sendDocument) throws TelegramApiException { assertParamNotNull(sendDocument, "sendDocument"); sendDocument.validate(); try { String url = getBaseUrl() + SendDocument.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setLaxMode(); builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId(), TEXT_PLAIN_CONTENT_TYPE); addInputFile(builder, sendDocument.getDocument(), SendDocument.DOCUMENT_FIELD, true); if (sendDocument.getReplyMarkup() != null) { builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendDocument.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getReplyToMessageId() != null) { builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getCaption() != null) { builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getParseMode() != null) { builder.addTextBody(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode(), TEXT_PLAIN_CONTENT_TYPE); } } if (sendDocument.getDisableNotification() != null) { builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getThumb() != null) { addInputFile(builder, sendDocument.getThumb(), SendDocument.THUMB_FIELD, false); builder.addTextBody(SendDocument.THUMB_FIELD, sendDocument.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); return sendDocument.deserializeResponse(sendHttpPostRequest(httppost)); } catch (IOException e) { throw new TelegramApiException("Unable to send document", e); } }
java
@Override public final Message execute(SendDocument sendDocument) throws TelegramApiException { assertParamNotNull(sendDocument, "sendDocument"); sendDocument.validate(); try { String url = getBaseUrl() + SendDocument.PATH; HttpPost httppost = configuredHttpPost(url); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setLaxMode(); builder.setCharset(StandardCharsets.UTF_8); builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId(), TEXT_PLAIN_CONTENT_TYPE); addInputFile(builder, sendDocument.getDocument(), SendDocument.DOCUMENT_FIELD, true); if (sendDocument.getReplyMarkup() != null) { builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, objectMapper.writeValueAsString(sendDocument.getReplyMarkup()), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getReplyToMessageId() != null) { builder.addTextBody(SendDocument.REPLYTOMESSAGEID_FIELD, sendDocument.getReplyToMessageId().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getCaption() != null) { builder.addTextBody(SendDocument.CAPTION_FIELD, sendDocument.getCaption(), TEXT_PLAIN_CONTENT_TYPE); if (sendDocument.getParseMode() != null) { builder.addTextBody(SendDocument.PARSEMODE_FIELD, sendDocument.getParseMode(), TEXT_PLAIN_CONTENT_TYPE); } } if (sendDocument.getDisableNotification() != null) { builder.addTextBody(SendDocument.DISABLENOTIFICATION_FIELD, sendDocument.getDisableNotification().toString(), TEXT_PLAIN_CONTENT_TYPE); } if (sendDocument.getThumb() != null) { addInputFile(builder, sendDocument.getThumb(), SendDocument.THUMB_FIELD, false); builder.addTextBody(SendDocument.THUMB_FIELD, sendDocument.getThumb().getAttachName(), TEXT_PLAIN_CONTENT_TYPE); } HttpEntity multipart = builder.build(); httppost.setEntity(multipart); return sendDocument.deserializeResponse(sendHttpPostRequest(httppost)); } catch (IOException e) { throw new TelegramApiException("Unable to send document", e); } }
[ "@", "Override", "public", "final", "Message", "execute", "(", "SendDocument", "sendDocument", ")", "throws", "TelegramApiException", "{", "assertParamNotNull", "(", "sendDocument", ",", "\"sendDocument\"", ")", ";", "sendDocument", ".", "validate", "(", ")", ";", "try", "{", "String", "url", "=", "getBaseUrl", "(", ")", "+", "SendDocument", ".", "PATH", ";", "HttpPost", "httppost", "=", "configuredHttpPost", "(", "url", ")", ";", "MultipartEntityBuilder", "builder", "=", "MultipartEntityBuilder", ".", "create", "(", ")", ";", "builder", ".", "setLaxMode", "(", ")", ";", "builder", ".", "setCharset", "(", "StandardCharsets", ".", "UTF_8", ")", ";", "builder", ".", "addTextBody", "(", "SendDocument", ".", "CHATID_FIELD", ",", "sendDocument", ".", "getChatId", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "addInputFile", "(", "builder", ",", "sendDocument", ".", "getDocument", "(", ")", ",", "SendDocument", ".", "DOCUMENT_FIELD", ",", "true", ")", ";", "if", "(", "sendDocument", ".", "getReplyMarkup", "(", ")", "!=", "null", ")", "{", "builder", ".", "addTextBody", "(", "SendDocument", ".", "REPLYMARKUP_FIELD", ",", "objectMapper", ".", "writeValueAsString", "(", "sendDocument", ".", "getReplyMarkup", "(", ")", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "}", "if", "(", "sendDocument", ".", "getReplyToMessageId", "(", ")", "!=", "null", ")", "{", "builder", ".", "addTextBody", "(", "SendDocument", ".", "REPLYTOMESSAGEID_FIELD", ",", "sendDocument", ".", "getReplyToMessageId", "(", ")", ".", "toString", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "}", "if", "(", "sendDocument", ".", "getCaption", "(", ")", "!=", "null", ")", "{", "builder", ".", "addTextBody", "(", "SendDocument", ".", "CAPTION_FIELD", ",", "sendDocument", ".", "getCaption", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "if", "(", "sendDocument", ".", "getParseMode", "(", ")", "!=", "null", ")", "{", "builder", ".", "addTextBody", "(", "SendDocument", ".", "PARSEMODE_FIELD", ",", "sendDocument", ".", "getParseMode", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "}", "}", "if", "(", "sendDocument", ".", "getDisableNotification", "(", ")", "!=", "null", ")", "{", "builder", ".", "addTextBody", "(", "SendDocument", ".", "DISABLENOTIFICATION_FIELD", ",", "sendDocument", ".", "getDisableNotification", "(", ")", ".", "toString", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "}", "if", "(", "sendDocument", ".", "getThumb", "(", ")", "!=", "null", ")", "{", "addInputFile", "(", "builder", ",", "sendDocument", ".", "getThumb", "(", ")", ",", "SendDocument", ".", "THUMB_FIELD", ",", "false", ")", ";", "builder", ".", "addTextBody", "(", "SendDocument", ".", "THUMB_FIELD", ",", "sendDocument", ".", "getThumb", "(", ")", ".", "getAttachName", "(", ")", ",", "TEXT_PLAIN_CONTENT_TYPE", ")", ";", "}", "HttpEntity", "multipart", "=", "builder", ".", "build", "(", ")", ";", "httppost", ".", "setEntity", "(", "multipart", ")", ";", "return", "sendDocument", ".", "deserializeResponse", "(", "sendHttpPostRequest", "(", "httppost", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "TelegramApiException", "(", "\"Unable to send document\"", ",", "e", ")", ";", "}", "}" ]
Specific Send Requests
[ "Specific", "Send", "Requests" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java#L147-L191
21,202
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java
AbilityUtils.getUser
public static User getUser(Update update) { if (MESSAGE.test(update)) { return update.getMessage().getFrom(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getFrom(); } else if (INLINE_QUERY.test(update)) { return update.getInlineQuery().getFrom(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().getFrom(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().getFrom(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().getFrom(); } else if (CHOSEN_INLINE_QUERY.test(update)) { return update.getChosenInlineQuery().getFrom(); } else { throw new IllegalStateException("Could not retrieve originating user from update"); } }
java
public static User getUser(Update update) { if (MESSAGE.test(update)) { return update.getMessage().getFrom(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getFrom(); } else if (INLINE_QUERY.test(update)) { return update.getInlineQuery().getFrom(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().getFrom(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().getFrom(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().getFrom(); } else if (CHOSEN_INLINE_QUERY.test(update)) { return update.getChosenInlineQuery().getFrom(); } else { throw new IllegalStateException("Could not retrieve originating user from update"); } }
[ "public", "static", "User", "getUser", "(", "Update", "update", ")", "{", "if", "(", "MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getMessage", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "CALLBACK_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getCallbackQuery", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "INLINE_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getInlineQuery", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getChannelPost", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "EDITED_CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedChannelPost", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "EDITED_MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedMessage", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "if", "(", "CHOSEN_INLINE_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getChosenInlineQuery", "(", ")", ".", "getFrom", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"Could not retrieve originating user from update\"", ")", ";", "}", "}" ]
Fetches the user who caused the update. @param update a Telegram {@link Update} @return the originating user @throws IllegalStateException if the user could not be found
[ "Fetches", "the", "user", "who", "caused", "the", "update", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java#L57-L75
21,203
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java
AbilityUtils.isGroupUpdate
public static boolean isGroupUpdate(Update update) { if (MESSAGE.test(update)) { return update.getMessage().isGroupMessage(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().isGroupMessage(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().isGroupMessage(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().isGroupMessage(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().isGroupMessage(); } else { return false; } }
java
public static boolean isGroupUpdate(Update update) { if (MESSAGE.test(update)) { return update.getMessage().isGroupMessage(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().isGroupMessage(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().isGroupMessage(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().isGroupMessage(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().isGroupMessage(); } else { return false; } }
[ "public", "static", "boolean", "isGroupUpdate", "(", "Update", "update", ")", "{", "if", "(", "MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getMessage", "(", ")", ".", "isGroupMessage", "(", ")", ";", "}", "else", "if", "(", "CALLBACK_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getCallbackQuery", "(", ")", ".", "getMessage", "(", ")", ".", "isGroupMessage", "(", ")", ";", "}", "else", "if", "(", "CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getChannelPost", "(", ")", ".", "isGroupMessage", "(", ")", ";", "}", "else", "if", "(", "EDITED_CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedChannelPost", "(", ")", ".", "isGroupMessage", "(", ")", ";", "}", "else", "if", "(", "EDITED_MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedMessage", "(", ")", ".", "isGroupMessage", "(", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
A "best-effort" boolean stating whether the update is a group message or not. @param update a Telegram {@link Update} @return whether the update is linked to a group
[ "A", "best", "-", "effort", "boolean", "stating", "whether", "the", "update", "is", "a", "group", "message", "or", "not", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java#L83-L97
21,204
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java
AbilityUtils.isSuperGroupUpdate
public static boolean isSuperGroupUpdate(Update update) { if (MESSAGE.test(update)) { return update.getMessage().isSuperGroupMessage(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().isSuperGroupMessage(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().isSuperGroupMessage(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().isSuperGroupMessage(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().isSuperGroupMessage(); } else { return false; } }
java
public static boolean isSuperGroupUpdate(Update update) { if (MESSAGE.test(update)) { return update.getMessage().isSuperGroupMessage(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().isSuperGroupMessage(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().isSuperGroupMessage(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().isSuperGroupMessage(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().isSuperGroupMessage(); } else { return false; } }
[ "public", "static", "boolean", "isSuperGroupUpdate", "(", "Update", "update", ")", "{", "if", "(", "MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getMessage", "(", ")", ".", "isSuperGroupMessage", "(", ")", ";", "}", "else", "if", "(", "CALLBACK_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getCallbackQuery", "(", ")", ".", "getMessage", "(", ")", ".", "isSuperGroupMessage", "(", ")", ";", "}", "else", "if", "(", "CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getChannelPost", "(", ")", ".", "isSuperGroupMessage", "(", ")", ";", "}", "else", "if", "(", "EDITED_CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedChannelPost", "(", ")", ".", "isSuperGroupMessage", "(", ")", ";", "}", "else", "if", "(", "EDITED_MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedMessage", "(", ")", ".", "isSuperGroupMessage", "(", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
A "best-effort" boolean stating whether the update is a super-group message or not. @param update a Telegram {@link Update} @return whether the update is linked to a group
[ "A", "best", "-", "effort", "boolean", "stating", "whether", "the", "update", "is", "a", "super", "-", "group", "message", "or", "not", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java#L105-L119
21,205
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java
AbilityUtils.getChatId
public static Long getChatId(Update update) { if (MESSAGE.test(update)) { return update.getMessage().getChatId(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().getChatId(); } else if (INLINE_QUERY.test(update)) { return (long) update.getInlineQuery().getFrom().getId(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().getChatId(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().getChatId(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().getChatId(); } else if (CHOSEN_INLINE_QUERY.test(update)) { return (long) update.getChosenInlineQuery().getFrom().getId(); } else { throw new IllegalStateException("Could not retrieve originating chat ID from update"); } }
java
public static Long getChatId(Update update) { if (MESSAGE.test(update)) { return update.getMessage().getChatId(); } else if (CALLBACK_QUERY.test(update)) { return update.getCallbackQuery().getMessage().getChatId(); } else if (INLINE_QUERY.test(update)) { return (long) update.getInlineQuery().getFrom().getId(); } else if (CHANNEL_POST.test(update)) { return update.getChannelPost().getChatId(); } else if (EDITED_CHANNEL_POST.test(update)) { return update.getEditedChannelPost().getChatId(); } else if (EDITED_MESSAGE.test(update)) { return update.getEditedMessage().getChatId(); } else if (CHOSEN_INLINE_QUERY.test(update)) { return (long) update.getChosenInlineQuery().getFrom().getId(); } else { throw new IllegalStateException("Could not retrieve originating chat ID from update"); } }
[ "public", "static", "Long", "getChatId", "(", "Update", "update", ")", "{", "if", "(", "MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getMessage", "(", ")", ".", "getChatId", "(", ")", ";", "}", "else", "if", "(", "CALLBACK_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getCallbackQuery", "(", ")", ".", "getMessage", "(", ")", ".", "getChatId", "(", ")", ";", "}", "else", "if", "(", "INLINE_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "(", "long", ")", "update", ".", "getInlineQuery", "(", ")", ".", "getFrom", "(", ")", ".", "getId", "(", ")", ";", "}", "else", "if", "(", "CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getChannelPost", "(", ")", ".", "getChatId", "(", ")", ";", "}", "else", "if", "(", "EDITED_CHANNEL_POST", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedChannelPost", "(", ")", ".", "getChatId", "(", ")", ";", "}", "else", "if", "(", "EDITED_MESSAGE", ".", "test", "(", "update", ")", ")", "{", "return", "update", ".", "getEditedMessage", "(", ")", ".", "getChatId", "(", ")", ";", "}", "else", "if", "(", "CHOSEN_INLINE_QUERY", ".", "test", "(", "update", ")", ")", "{", "return", "(", "long", ")", "update", ".", "getChosenInlineQuery", "(", ")", ".", "getFrom", "(", ")", ".", "getId", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"Could not retrieve originating chat ID from update\"", ")", ";", "}", "}" ]
Fetches the direct chat ID of the specified update. @param update a Telegram {@link Update} @return the originating chat ID @throws IllegalStateException if the chat ID could not be found
[ "Fetches", "the", "direct", "chat", "ID", "of", "the", "specified", "update", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java#L128-L146
21,206
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java
AbilityUtils.fullName
public static String fullName(User user) { StringJoiner name = new StringJoiner(" "); if (!isEmpty(user.getFirstName())) name.add(user.getFirstName()); if (!isEmpty(user.getLastName())) name.add(user.getLastName()); return name.toString(); }
java
public static String fullName(User user) { StringJoiner name = new StringJoiner(" "); if (!isEmpty(user.getFirstName())) name.add(user.getFirstName()); if (!isEmpty(user.getLastName())) name.add(user.getLastName()); return name.toString(); }
[ "public", "static", "String", "fullName", "(", "User", "user", ")", "{", "StringJoiner", "name", "=", "new", "StringJoiner", "(", "\" \"", ")", ";", "if", "(", "!", "isEmpty", "(", "user", ".", "getFirstName", "(", ")", ")", ")", "name", ".", "add", "(", "user", ".", "getFirstName", "(", ")", ")", ";", "if", "(", "!", "isEmpty", "(", "user", ".", "getLastName", "(", ")", ")", ")", "name", ".", "add", "(", "user", ".", "getLastName", "(", ")", ")", ";", "return", "name", ".", "toString", "(", ")", ";", "}" ]
The full name is identified as the concatenation of the first and last name, separated by a space. This method can return an empty name if both first and last name are empty. @return the full name of the user @param user
[ "The", "full", "name", "is", "identified", "as", "the", "concatenation", "of", "the", "first", "and", "last", "name", "separated", "by", "a", "space", ".", "This", "method", "can", "return", "an", "empty", "name", "if", "both", "first", "and", "last", "name", "are", "empty", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/util/AbilityUtils.java#L237-L246
21,207
rubenlagus/TelegramBots
telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java
SendAudio.setAudio
public SendAudio setAudio(File file) { Objects.requireNonNull(file, "file cannot be null!"); this.audio = new InputFile(file, file.getName()); return this; }
java
public SendAudio setAudio(File file) { Objects.requireNonNull(file, "file cannot be null!"); this.audio = new InputFile(file, file.getName()); return this; }
[ "public", "SendAudio", "setAudio", "(", "File", "file", ")", "{", "Objects", ".", "requireNonNull", "(", "file", ",", "\"file cannot be null!\"", ")", ";", "this", ".", "audio", "=", "new", "InputFile", "(", "file", ",", "file", ".", "getName", "(", ")", ")", ";", "return", "this", ";", "}" ]
Use this method to set the audio to a new file @param file New audio file
[ "Use", "this", "method", "to", "set", "the", "audio", "to", "a", "new", "file" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendAudio.java#L108-L112
21,208
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java
BaseAbilityBot.getUser
protected User getUser(String username) { Integer id = userIds().get(username.toLowerCase()); if (id == null) { throw new IllegalStateException(format("Could not find ID corresponding to username [%s]", username)); } return getUser(id); }
java
protected User getUser(String username) { Integer id = userIds().get(username.toLowerCase()); if (id == null) { throw new IllegalStateException(format("Could not find ID corresponding to username [%s]", username)); } return getUser(id); }
[ "protected", "User", "getUser", "(", "String", "username", ")", "{", "Integer", "id", "=", "userIds", "(", ")", ".", "get", "(", "username", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "format", "(", "\"Could not find ID corresponding to username [%s]\"", ",", "username", ")", ")", ";", "}", "return", "getUser", "(", "id", ")", ";", "}" ]
Gets the user with the specified username. @param username the username of the required user @return the user
[ "Gets", "the", "user", "with", "the", "specified", "username", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java#L248-L255
21,209
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java
BaseAbilityBot.getUser
protected User getUser(int id) { User user = users().get(id); if (user == null) { throw new IllegalStateException(format("Could not find user corresponding to id [%d]", id)); } return user; }
java
protected User getUser(int id) { User user = users().get(id); if (user == null) { throw new IllegalStateException(format("Could not find user corresponding to id [%d]", id)); } return user; }
[ "protected", "User", "getUser", "(", "int", "id", ")", "{", "User", "user", "=", "users", "(", ")", ".", "get", "(", "id", ")", ";", "if", "(", "user", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "format", "(", "\"Could not find user corresponding to id [%d]\"", ",", "id", ")", ")", ";", "}", "return", "user", ";", "}" ]
Gets the user with the specified ID. @param id the id of the required user @return the user
[ "Gets", "the", "user", "with", "the", "specified", "ID", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java#L263-L270
21,210
rubenlagus/TelegramBots
telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java
BaseAbilityBot.getUserIdSendError
protected int getUserIdSendError(String username, MessageContext ctx) { try { return getUser(username).getId(); } catch (IllegalStateException ex) { silent.send(getLocalizedMessage(USER_NOT_FOUND, ctx.user().getLanguageCode(), username), ctx.chatId()); throw propagate(ex); } }
java
protected int getUserIdSendError(String username, MessageContext ctx) { try { return getUser(username).getId(); } catch (IllegalStateException ex) { silent.send(getLocalizedMessage(USER_NOT_FOUND, ctx.user().getLanguageCode(), username), ctx.chatId()); throw propagate(ex); } }
[ "protected", "int", "getUserIdSendError", "(", "String", "username", ",", "MessageContext", "ctx", ")", "{", "try", "{", "return", "getUser", "(", "username", ")", ".", "getId", "(", ")", ";", "}", "catch", "(", "IllegalStateException", "ex", ")", "{", "silent", ".", "send", "(", "getLocalizedMessage", "(", "USER_NOT_FOUND", ",", "ctx", ".", "user", "(", ")", ".", "getLanguageCode", "(", ")", ",", "username", ")", ",", "ctx", ".", "chatId", "(", ")", ")", ";", "throw", "propagate", "(", "ex", ")", ";", "}", "}" ]
Gets the user with the specified username. If user was not found, the bot will send a message on Telegram. @param username the username of the required user @param ctx the message context with the originating user @return the id of the user
[ "Gets", "the", "user", "with", "the", "specified", "username", ".", "If", "user", "was", "not", "found", "the", "bot", "will", "send", "a", "message", "on", "Telegram", "." ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/BaseAbilityBot.java#L279-L286
21,211
rubenlagus/TelegramBots
telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java
AbsSender.executeAsync
public <T extends Serializable, Method extends BotApiMethod<T>, Callback extends SentCallback<T>> void executeAsync(Method method, Callback callback) throws TelegramApiException { if (method == null) { throw new TelegramApiException("Parameter method can not be null"); } if (callback == null) { throw new TelegramApiException("Parameter callback can not be null"); } sendApiMethodAsync(method, callback); }
java
public <T extends Serializable, Method extends BotApiMethod<T>, Callback extends SentCallback<T>> void executeAsync(Method method, Callback callback) throws TelegramApiException { if (method == null) { throw new TelegramApiException("Parameter method can not be null"); } if (callback == null) { throw new TelegramApiException("Parameter callback can not be null"); } sendApiMethodAsync(method, callback); }
[ "public", "<", "T", "extends", "Serializable", ",", "Method", "extends", "BotApiMethod", "<", "T", ">", ",", "Callback", "extends", "SentCallback", "<", "T", ">", ">", "void", "executeAsync", "(", "Method", "method", ",", "Callback", "callback", ")", "throws", "TelegramApiException", "{", "if", "(", "method", "==", "null", ")", "{", "throw", "new", "TelegramApiException", "(", "\"Parameter method can not be null\"", ")", ";", "}", "if", "(", "callback", "==", "null", ")", "{", "throw", "new", "TelegramApiException", "(", "\"Parameter callback can not be null\"", ")", ";", "}", "sendApiMethodAsync", "(", "method", ",", "callback", ")", ";", "}" ]
General methods to execute BotApiMethods
[ "General", "methods", "to", "execute", "BotApiMethods" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java#L33-L41
21,212
rubenlagus/TelegramBots
telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java
AbsSender.getMeAsync
public final void getMeAsync(SentCallback<User> sentCallback) throws TelegramApiException { if (sentCallback == null) { throw new TelegramApiException("Parameter sentCallback can not be null"); } sendApiMethodAsync(new GetMe(), sentCallback); }
java
public final void getMeAsync(SentCallback<User> sentCallback) throws TelegramApiException { if (sentCallback == null) { throw new TelegramApiException("Parameter sentCallback can not be null"); } sendApiMethodAsync(new GetMe(), sentCallback); }
[ "public", "final", "void", "getMeAsync", "(", "SentCallback", "<", "User", ">", "sentCallback", ")", "throws", "TelegramApiException", "{", "if", "(", "sentCallback", "==", "null", ")", "{", "throw", "new", "TelegramApiException", "(", "\"Parameter sentCallback can not be null\"", ")", ";", "}", "sendApiMethodAsync", "(", "new", "GetMe", "(", ")", ",", "sentCallback", ")", ";", "}" ]
Send Requests Async
[ "Send", "Requests", "Async" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/bots/AbsSender.java#L64-L69
21,213
rubenlagus/TelegramBots
telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java
SendDocument.setDocument
public SendDocument setDocument(File file) { Objects.requireNonNull(file, "documentName cannot be null!"); this.document = new InputFile(file, file.getName()); return this; }
java
public SendDocument setDocument(File file) { Objects.requireNonNull(file, "documentName cannot be null!"); this.document = new InputFile(file, file.getName()); return this; }
[ "public", "SendDocument", "setDocument", "(", "File", "file", ")", "{", "Objects", ".", "requireNonNull", "(", "file", ",", "\"documentName cannot be null!\"", ")", ";", "this", ".", "document", "=", "new", "InputFile", "(", "file", ",", "file", ".", "getName", "(", ")", ")", ";", "return", "this", ";", "}" ]
Use this method to set the document to a new file @param file New document file
[ "Use", "this", "method", "to", "set", "the", "document", "to", "a", "new", "file" ]
d62354915d7664597a40fd9858f16bce67ef1478
https://github.com/rubenlagus/TelegramBots/blob/d62354915d7664597a40fd9858f16bce67ef1478/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/methods/send/SendDocument.java#L89-L93
21,214
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/authentication/AuthzAuthenticationFilter.java
AuthzAuthenticationFilter.setMethods
public void setMethods(Set<String> methods) { this.methods = new HashSet<>(); for (String method : methods) { this.methods.add(method.toUpperCase()); } }
java
public void setMethods(Set<String> methods) { this.methods = new HashSet<>(); for (String method : methods) { this.methods.add(method.toUpperCase()); } }
[ "public", "void", "setMethods", "(", "Set", "<", "String", ">", "methods", ")", "{", "this", ".", "methods", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "String", "method", ":", "methods", ")", "{", "this", ".", "methods", ".", "add", "(", "method", ".", "toUpperCase", "(", ")", ")", ";", "}", "}" ]
The filter fails on requests that don't have one of these HTTP methods. @param methods the methods to set (defaults to POST)
[ "The", "filter", "fails", "on", "requests", "that", "don", "t", "have", "one", "of", "these", "HTTP", "methods", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/authentication/AuthzAuthenticationFilter.java#L89-L94
21,215
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/AuthorizationAttributesParser.java
AuthorizationAttributesParser.getAdditionalAuthorizationAttributes
public Map<String, String> getAdditionalAuthorizationAttributes(String authoritiesJson) { if (StringUtils.hasLength(authoritiesJson)) { try { Map<String, Object> authorities = JsonUtils.readValue(authoritiesJson, new TypeReference<Map<String, Object>>() {}); Object az_attr = authorities.get("az_attr"); if(az_attr == null) return null; // validate az_attr content with Map<String, String>> Map<String, String> additionalAuthorizationAttributes = JsonUtils.readValue(JsonUtils.writeValueAsBytes(az_attr), new TypeReference<Map<String, String>>() {}); return additionalAuthorizationAttributes; } catch (Throwable t) { logger.error("Unable to read additionalAuthorizationAttributes", t); } } return null; }
java
public Map<String, String> getAdditionalAuthorizationAttributes(String authoritiesJson) { if (StringUtils.hasLength(authoritiesJson)) { try { Map<String, Object> authorities = JsonUtils.readValue(authoritiesJson, new TypeReference<Map<String, Object>>() {}); Object az_attr = authorities.get("az_attr"); if(az_attr == null) return null; // validate az_attr content with Map<String, String>> Map<String, String> additionalAuthorizationAttributes = JsonUtils.readValue(JsonUtils.writeValueAsBytes(az_attr), new TypeReference<Map<String, String>>() {}); return additionalAuthorizationAttributes; } catch (Throwable t) { logger.error("Unable to read additionalAuthorizationAttributes", t); } } return null; }
[ "public", "Map", "<", "String", ",", "String", ">", "getAdditionalAuthorizationAttributes", "(", "String", "authoritiesJson", ")", "{", "if", "(", "StringUtils", ".", "hasLength", "(", "authoritiesJson", ")", ")", "{", "try", "{", "Map", "<", "String", ",", "Object", ">", "authorities", "=", "JsonUtils", ".", "readValue", "(", "authoritiesJson", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "Object", ">", ">", "(", ")", "{", "}", ")", ";", "Object", "az_attr", "=", "authorities", ".", "get", "(", "\"az_attr\"", ")", ";", "if", "(", "az_attr", "==", "null", ")", "return", "null", ";", "// validate az_attr content with Map<String, String>>", "Map", "<", "String", ",", "String", ">", "additionalAuthorizationAttributes", "=", "JsonUtils", ".", "readValue", "(", "JsonUtils", ".", "writeValueAsBytes", "(", "az_attr", ")", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", "{", "}", ")", ";", "return", "additionalAuthorizationAttributes", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"Unable to read additionalAuthorizationAttributes\"", ",", "t", ")", ";", "}", "}", "return", "null", ";", "}" ]
This method searches the authorities in the request for additionalAuthorizationAttributes and returns a map of these attributes that will later be added to the token @param authoritiesJson @return
[ "This", "method", "searches", "the", "authorities", "in", "the", "request", "for", "additionalAuthorizationAttributes", "and", "returns", "a", "map", "of", "these", "attributes", "that", "will", "later", "be", "added", "to", "the", "token" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/oauth/AuthorizationAttributesParser.java#L23-L41
21,216
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java
ScimUserBootstrap.addUser
protected void addUser(UaaUser user) { ScimUser scimUser = getScimUser(user); if (scimUser==null) { if (isEmpty(user.getPassword()) && user.getOrigin().equals(OriginKeys.UAA)) { logger.debug("User's password cannot be empty"); throw new InvalidPasswordException("Password cannot be empty", BAD_REQUEST); } createNewUser(user); } else { if (override) { updateUser(scimUser, user); } else { logger.debug("Override flag not set. Not registering existing user: " + user); } } }
java
protected void addUser(UaaUser user) { ScimUser scimUser = getScimUser(user); if (scimUser==null) { if (isEmpty(user.getPassword()) && user.getOrigin().equals(OriginKeys.UAA)) { logger.debug("User's password cannot be empty"); throw new InvalidPasswordException("Password cannot be empty", BAD_REQUEST); } createNewUser(user); } else { if (override) { updateUser(scimUser, user); } else { logger.debug("Override flag not set. Not registering existing user: " + user); } } }
[ "protected", "void", "addUser", "(", "UaaUser", "user", ")", "{", "ScimUser", "scimUser", "=", "getScimUser", "(", "user", ")", ";", "if", "(", "scimUser", "==", "null", ")", "{", "if", "(", "isEmpty", "(", "user", ".", "getPassword", "(", ")", ")", "&&", "user", ".", "getOrigin", "(", ")", ".", "equals", "(", "OriginKeys", ".", "UAA", ")", ")", "{", "logger", ".", "debug", "(", "\"User's password cannot be empty\"", ")", ";", "throw", "new", "InvalidPasswordException", "(", "\"Password cannot be empty\"", ",", "BAD_REQUEST", ")", ";", "}", "createNewUser", "(", "user", ")", ";", "}", "else", "{", "if", "(", "override", ")", "{", "updateUser", "(", "scimUser", ",", "user", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "\"Override flag not set. Not registering existing user: \"", "+", "user", ")", ";", "}", "}", "}" ]
Add a user account from the properties provided. @param user a UaaUser
[ "Add", "a", "user", "account", "from", "the", "properties", "provided", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java#L172-L188
21,217
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java
ScimUserBootstrap.convertToScimUser
private ScimUser convertToScimUser(UaaUser user) { ScimUser scim = new ScimUser(user.getId(), user.getUsername(), user.getGivenName(), user.getFamilyName()); scim.addPhoneNumber(user.getPhoneNumber()); scim.addEmail(user.getEmail()); scim.setOrigin(user.getOrigin()); scim.setExternalId(user.getExternalId()); scim.setVerified(user.isVerified()); return scim; }
java
private ScimUser convertToScimUser(UaaUser user) { ScimUser scim = new ScimUser(user.getId(), user.getUsername(), user.getGivenName(), user.getFamilyName()); scim.addPhoneNumber(user.getPhoneNumber()); scim.addEmail(user.getEmail()); scim.setOrigin(user.getOrigin()); scim.setExternalId(user.getExternalId()); scim.setVerified(user.isVerified()); return scim; }
[ "private", "ScimUser", "convertToScimUser", "(", "UaaUser", "user", ")", "{", "ScimUser", "scim", "=", "new", "ScimUser", "(", "user", ".", "getId", "(", ")", ",", "user", ".", "getUsername", "(", ")", ",", "user", ".", "getGivenName", "(", ")", ",", "user", ".", "getFamilyName", "(", ")", ")", ";", "scim", ".", "addPhoneNumber", "(", "user", ".", "getPhoneNumber", "(", ")", ")", ";", "scim", ".", "addEmail", "(", "user", ".", "getEmail", "(", ")", ")", ";", "scim", ".", "setOrigin", "(", "user", ".", "getOrigin", "(", ")", ")", ";", "scim", ".", "setExternalId", "(", "user", ".", "getExternalId", "(", ")", ")", ";", "scim", ".", "setVerified", "(", "user", ".", "isVerified", "(", ")", ")", ";", "return", "scim", ";", "}" ]
Convert UaaUser to SCIM data.
[ "Convert", "UaaUser", "to", "SCIM", "data", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java#L346-L354
21,218
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java
ScimUserBootstrap.convertToGroups
private Collection<String> convertToGroups(List<? extends GrantedAuthority> authorities) { List<String> groups = new ArrayList<String>(); for (GrantedAuthority authority : authorities) { groups.add(authority.getAuthority()); } return groups; }
java
private Collection<String> convertToGroups(List<? extends GrantedAuthority> authorities) { List<String> groups = new ArrayList<String>(); for (GrantedAuthority authority : authorities) { groups.add(authority.getAuthority()); } return groups; }
[ "private", "Collection", "<", "String", ">", "convertToGroups", "(", "List", "<", "?", "extends", "GrantedAuthority", ">", "authorities", ")", "{", "List", "<", "String", ">", "groups", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "GrantedAuthority", "authority", ":", "authorities", ")", "{", "groups", ".", "add", "(", "authority", ".", "getAuthority", "(", ")", ")", ";", "}", "return", "groups", ";", "}" ]
Convert authorities to group names.
[ "Convert", "authorities", "to", "group", "names", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimUserBootstrap.java#L359-L365
21,219
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/authentication/manager/CommonLoginPolicy.java
CommonLoginPolicy.sequentialFailureCount
private int sequentialFailureCount(List<AuditEvent> events) { int failureCount = 0; for (AuditEvent event : events) { if (event.getType() == failureEventType) { failureCount++; } else if (event.getType() == successEventType) { // Successful authentication occurred within last allowable // failures, so ignore break; } } return failureCount; }
java
private int sequentialFailureCount(List<AuditEvent> events) { int failureCount = 0; for (AuditEvent event : events) { if (event.getType() == failureEventType) { failureCount++; } else if (event.getType() == successEventType) { // Successful authentication occurred within last allowable // failures, so ignore break; } } return failureCount; }
[ "private", "int", "sequentialFailureCount", "(", "List", "<", "AuditEvent", ">", "events", ")", "{", "int", "failureCount", "=", "0", ";", "for", "(", "AuditEvent", "event", ":", "events", ")", "{", "if", "(", "event", ".", "getType", "(", ")", "==", "failureEventType", ")", "{", "failureCount", "++", ";", "}", "else", "if", "(", "event", ".", "getType", "(", ")", "==", "successEventType", ")", "{", "// Successful authentication occurred within last allowable", "// failures, so ignore", "break", ";", "}", "}", "return", "failureCount", ";", "}" ]
Counts the number of failures that occurred without an intervening successful login.
[ "Counts", "the", "number", "of", "failures", "that", "occurred", "without", "an", "intervening", "successful", "login", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/authentication/manager/CommonLoginPolicy.java#L77-L89
21,220
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/security/web/CorsFilter.java
CorsFilter.isXhrRequest
protected boolean isXhrRequest(final HttpServletRequest request) { if (StringUtils.hasText(request.getHeader(X_REQUESTED_WITH))) { //the X-Requested-With header is present. This is a XHR request return true; } String accessControlRequestHeaders = request.getHeader(ACCESS_CONTROL_REQUEST_HEADERS); //One of the requested headers is X-Requested-With so we treat is as XHR request return StringUtils.hasText(accessControlRequestHeaders) && containsHeader(accessControlRequestHeaders, X_REQUESTED_WITH); }
java
protected boolean isXhrRequest(final HttpServletRequest request) { if (StringUtils.hasText(request.getHeader(X_REQUESTED_WITH))) { //the X-Requested-With header is present. This is a XHR request return true; } String accessControlRequestHeaders = request.getHeader(ACCESS_CONTROL_REQUEST_HEADERS); //One of the requested headers is X-Requested-With so we treat is as XHR request return StringUtils.hasText(accessControlRequestHeaders) && containsHeader(accessControlRequestHeaders, X_REQUESTED_WITH); }
[ "protected", "boolean", "isXhrRequest", "(", "final", "HttpServletRequest", "request", ")", "{", "if", "(", "StringUtils", ".", "hasText", "(", "request", ".", "getHeader", "(", "X_REQUESTED_WITH", ")", ")", ")", "{", "//the X-Requested-With header is present. This is a XHR request", "return", "true", ";", "}", "String", "accessControlRequestHeaders", "=", "request", ".", "getHeader", "(", "ACCESS_CONTROL_REQUEST_HEADERS", ")", ";", "//One of the requested headers is X-Requested-With so we treat is as XHR request", "return", "StringUtils", ".", "hasText", "(", "accessControlRequestHeaders", ")", "&&", "containsHeader", "(", "accessControlRequestHeaders", ",", "X_REQUESTED_WITH", ")", ";", "}" ]
Returns true if we believe this is an XHR request We look for the presence of the X-Requested-With header or that the X-Requested-With header is listed as a value in the Access-Control-Request-Headers header. @param request the HTTP servlet request @return true if we believe this is an XHR request
[ "Returns", "true", "if", "we", "believe", "this", "is", "an", "XHR", "request", "We", "look", "for", "the", "presence", "of", "the", "X", "-", "Requested", "-", "With", "header", "or", "that", "the", "X", "-", "Requested", "-", "With", "header", "is", "listed", "as", "a", "value", "in", "the", "Access", "-", "Control", "-", "Request", "-", "Headers", "header", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/security/web/CorsFilter.java#L222-L231
21,221
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/impl/config/CustomPropertyConstructor.java
CustomPropertyConstructor.addPropertyAlias
protected final void addPropertyAlias(String alias, Class<?> type, String name) { Map<String, Property> typeMap = properties.get(type); if (typeMap == null) { typeMap = new HashMap<String, Property>(); properties.put(type, typeMap); } try { typeMap.put(alias, propertyUtils.getProperty(type, name)); } catch (IntrospectionException e) { throw new RuntimeException(e); } }
java
protected final void addPropertyAlias(String alias, Class<?> type, String name) { Map<String, Property> typeMap = properties.get(type); if (typeMap == null) { typeMap = new HashMap<String, Property>(); properties.put(type, typeMap); } try { typeMap.put(alias, propertyUtils.getProperty(type, name)); } catch (IntrospectionException e) { throw new RuntimeException(e); } }
[ "protected", "final", "void", "addPropertyAlias", "(", "String", "alias", ",", "Class", "<", "?", ">", "type", ",", "String", "name", ")", "{", "Map", "<", "String", ",", "Property", ">", "typeMap", "=", "properties", ".", "get", "(", "type", ")", ";", "if", "(", "typeMap", "==", "null", ")", "{", "typeMap", "=", "new", "HashMap", "<", "String", ",", "Property", ">", "(", ")", ";", "properties", ".", "put", "(", "type", ",", "typeMap", ")", ";", "}", "try", "{", "typeMap", ".", "put", "(", "alias", ",", "propertyUtils", ".", "getProperty", "(", "type", ",", "name", ")", ")", ";", "}", "catch", "(", "IntrospectionException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Adds an alias for a Javabean property name on a particular type. The values of YAML keys with the alias name will be mapped to the Javabean property. @param alias the bean property alias @param type the bean property type @param name the bean property name
[ "Adds", "an", "alias", "for", "a", "Javabean", "property", "name", "on", "a", "particular", "type", ".", "The", "values", "of", "YAML", "keys", "with", "the", "alias", "name", "will", "be", "mapped", "to", "the", "Javabean", "property", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/impl/config/CustomPropertyConstructor.java#L50-L63
21,222
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaTokenServices.java
UaaTokenServices.readAccessToken
@Override public OAuth2AccessToken readAccessToken(String accessToken) { TokenValidation tokenValidation = tokenValidationService.validateToken(accessToken, true).checkJti(); Map<String, Object> claims = tokenValidation.getClaims(); accessToken = tokenValidation.getJwt().getEncoded(); // Expiry is verified by check_token CompositeToken token = new CompositeToken(accessToken); token.setTokenType(OAuth2AccessToken.BEARER_TYPE); token.setExpiration(new Date(Long.valueOf(claims.get(EXP).toString()) * 1000L)); @SuppressWarnings("unchecked") ArrayList<String> scopes = (ArrayList<String>) claims.get(SCOPE); if (null != scopes && scopes.size() > 0) { token.setScope(new HashSet<>(scopes)); } String clientId = (String)claims.get(CID); String userId = (String)claims.get(USER_ID); BaseClientDetails client = (BaseClientDetails) clientDetailsService.loadClientByClientId(clientId, IdentityZoneHolder.get().getId()); // Only check user access tokens if (null != userId) { @SuppressWarnings("unchecked") ArrayList<String> tokenScopes = (ArrayList<String>) claims.get(SCOPE); approvalService.ensureRequiredApprovals(userId, tokenScopes, (String) claims.get(GRANT_TYPE), client); } return token; }
java
@Override public OAuth2AccessToken readAccessToken(String accessToken) { TokenValidation tokenValidation = tokenValidationService.validateToken(accessToken, true).checkJti(); Map<String, Object> claims = tokenValidation.getClaims(); accessToken = tokenValidation.getJwt().getEncoded(); // Expiry is verified by check_token CompositeToken token = new CompositeToken(accessToken); token.setTokenType(OAuth2AccessToken.BEARER_TYPE); token.setExpiration(new Date(Long.valueOf(claims.get(EXP).toString()) * 1000L)); @SuppressWarnings("unchecked") ArrayList<String> scopes = (ArrayList<String>) claims.get(SCOPE); if (null != scopes && scopes.size() > 0) { token.setScope(new HashSet<>(scopes)); } String clientId = (String)claims.get(CID); String userId = (String)claims.get(USER_ID); BaseClientDetails client = (BaseClientDetails) clientDetailsService.loadClientByClientId(clientId, IdentityZoneHolder.get().getId()); // Only check user access tokens if (null != userId) { @SuppressWarnings("unchecked") ArrayList<String> tokenScopes = (ArrayList<String>) claims.get(SCOPE); approvalService.ensureRequiredApprovals(userId, tokenScopes, (String) claims.get(GRANT_TYPE), client); } return token; }
[ "@", "Override", "public", "OAuth2AccessToken", "readAccessToken", "(", "String", "accessToken", ")", "{", "TokenValidation", "tokenValidation", "=", "tokenValidationService", ".", "validateToken", "(", "accessToken", ",", "true", ")", ".", "checkJti", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "claims", "=", "tokenValidation", ".", "getClaims", "(", ")", ";", "accessToken", "=", "tokenValidation", ".", "getJwt", "(", ")", ".", "getEncoded", "(", ")", ";", "// Expiry is verified by check_token", "CompositeToken", "token", "=", "new", "CompositeToken", "(", "accessToken", ")", ";", "token", ".", "setTokenType", "(", "OAuth2AccessToken", ".", "BEARER_TYPE", ")", ";", "token", ".", "setExpiration", "(", "new", "Date", "(", "Long", ".", "valueOf", "(", "claims", ".", "get", "(", "EXP", ")", ".", "toString", "(", ")", ")", "*", "1000L", ")", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "ArrayList", "<", "String", ">", "scopes", "=", "(", "ArrayList", "<", "String", ">", ")", "claims", ".", "get", "(", "SCOPE", ")", ";", "if", "(", "null", "!=", "scopes", "&&", "scopes", ".", "size", "(", ")", ">", "0", ")", "{", "token", ".", "setScope", "(", "new", "HashSet", "<>", "(", "scopes", ")", ")", ";", "}", "String", "clientId", "=", "(", "String", ")", "claims", ".", "get", "(", "CID", ")", ";", "String", "userId", "=", "(", "String", ")", "claims", ".", "get", "(", "USER_ID", ")", ";", "BaseClientDetails", "client", "=", "(", "BaseClientDetails", ")", "clientDetailsService", ".", "loadClientByClientId", "(", "clientId", ",", "IdentityZoneHolder", ".", "get", "(", ")", ".", "getId", "(", ")", ")", ";", "// Only check user access tokens", "if", "(", "null", "!=", "userId", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "ArrayList", "<", "String", ">", "tokenScopes", "=", "(", "ArrayList", "<", "String", ">", ")", "claims", ".", "get", "(", "SCOPE", ")", ";", "approvalService", ".", "ensureRequiredApprovals", "(", "userId", ",", "tokenScopes", ",", "(", "String", ")", "claims", ".", "get", "(", "GRANT_TYPE", ")", ",", "client", ")", ";", "}", "return", "token", ";", "}" ]
This method is implemented to support older API calls that assume the presence of a token store
[ "This", "method", "is", "implemented", "to", "support", "older", "API", "calls", "that", "assume", "the", "presence", "of", "a", "token", "store" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaTokenServices.java#L851-L880
21,223
cloudfoundry/uaa
samples/api/src/main/java/org/cloudfoundry/identity/api/web/ContentTypeFilter.java
ContentTypeFilter.doFilter
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; for (String path : mediaTypes.keySet()) { if (matches(httpServletRequest, path)) { response.setContentType(mediaTypes.get(path)); break; } } chain.doFilter(request, response); }
java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; for (String path : mediaTypes.keySet()) { if (matches(httpServletRequest, path)) { response.setContentType(mediaTypes.get(path)); break; } } chain.doFilter(request, response); }
[ "@", "Override", "public", "void", "doFilter", "(", "ServletRequest", "request", ",", "ServletResponse", "response", ",", "FilterChain", "chain", ")", "throws", "IOException", ",", "ServletException", "{", "HttpServletRequest", "httpServletRequest", "=", "(", "HttpServletRequest", ")", "request", ";", "for", "(", "String", "path", ":", "mediaTypes", ".", "keySet", "(", ")", ")", "{", "if", "(", "matches", "(", "httpServletRequest", ",", "path", ")", ")", "{", "response", ".", "setContentType", "(", "mediaTypes", ".", "get", "(", "path", ")", ")", ";", "break", ";", "}", "}", "chain", ".", "doFilter", "(", "request", ",", "response", ")", ";", "}" ]
Add a content type header to any request whose path matches one of the supplied paths.
[ "Add", "a", "content", "type", "header", "to", "any", "request", "whose", "path", "matches", "one", "of", "the", "supplied", "paths", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/samples/api/src/main/java/org/cloudfoundry/identity/api/web/ContentTypeFilter.java#L59-L71
21,224
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/refresh/RefreshTokenCreator.java
RefreshTokenCreator.isRefreshTokenSupported
protected boolean isRefreshTokenSupported(String grantType, Set<String> scope) { if (!isRestrictRefreshGrant) { return GRANT_TYPE_AUTHORIZATION_CODE.equals(grantType) || GRANT_TYPE_PASSWORD.equals(grantType) || GRANT_TYPE_USER_TOKEN.equals(grantType) || GRANT_TYPE_REFRESH_TOKEN.equals(grantType) || GRANT_TYPE_SAML2_BEARER.equals(grantType); } else { return scope.contains(UAA_REFRESH_TOKEN); } }
java
protected boolean isRefreshTokenSupported(String grantType, Set<String> scope) { if (!isRestrictRefreshGrant) { return GRANT_TYPE_AUTHORIZATION_CODE.equals(grantType) || GRANT_TYPE_PASSWORD.equals(grantType) || GRANT_TYPE_USER_TOKEN.equals(grantType) || GRANT_TYPE_REFRESH_TOKEN.equals(grantType) || GRANT_TYPE_SAML2_BEARER.equals(grantType); } else { return scope.contains(UAA_REFRESH_TOKEN); } }
[ "protected", "boolean", "isRefreshTokenSupported", "(", "String", "grantType", ",", "Set", "<", "String", ">", "scope", ")", "{", "if", "(", "!", "isRestrictRefreshGrant", ")", "{", "return", "GRANT_TYPE_AUTHORIZATION_CODE", ".", "equals", "(", "grantType", ")", "||", "GRANT_TYPE_PASSWORD", ".", "equals", "(", "grantType", ")", "||", "GRANT_TYPE_USER_TOKEN", ".", "equals", "(", "grantType", ")", "||", "GRANT_TYPE_REFRESH_TOKEN", ".", "equals", "(", "grantType", ")", "||", "GRANT_TYPE_SAML2_BEARER", ".", "equals", "(", "grantType", ")", ";", "}", "else", "{", "return", "scope", ".", "contains", "(", "UAA_REFRESH_TOKEN", ")", ";", "}", "}" ]
Check the current authorization request to indicate whether a refresh token should be issued or not. @param grantType the current grant type @param scope @return boolean to indicate if refresh token is supported
[ "Check", "the", "current", "authorization", "request", "to", "indicate", "whether", "a", "refresh", "token", "should", "be", "issued", "or", "not", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/oauth/refresh/RefreshTokenCreator.java#L145-L155
21,225
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGeneratorFilter.java
IdpMetadataGeneratorFilter.processMetadataInitialization
protected void processMetadataInitialization(HttpServletRequest request) throws ServletException { // In case the hosted IdP metadata weren't initialized, let's do it now if (manager.getHostedIdpName() == null) { synchronized (IdpMetadataManager.class) { if (manager.getHostedIdpName() == null) { try { log.info( "No default metadata configured, generating with default values, please pre-configure metadata for production use"); // Defaults String alias = generator.getEntityAlias(); String baseURL = getDefaultBaseURL(request); // Use default baseURL if not set if (generator.getEntityBaseURL() == null) { log.warn( "Generated default entity base URL {} based on values in the first server request. Please set property entityBaseURL on MetadataGenerator bean to fixate the value.", baseURL); generator.setEntityBaseURL(baseURL); } else { baseURL = generator.getEntityBaseURL(); } // Use default entityID if not set if (generator.getEntityId() == null) { generator.setEntityId(getDefaultEntityID(baseURL, alias)); } // Ensure supported nameID formats in uaa are listed in the metadata Collection<String> supportedNameID = Arrays.asList(NameIDType.EMAIL, NameIDType.PERSISTENT, NameIDType.UNSPECIFIED); generator.setNameID(supportedNameID); EntityDescriptor descriptor = generator.generateMetadata(); ExtendedMetadata extendedMetadata = generator.generateExtendedMetadata(); log.info("Created default metadata for system with entityID: " + descriptor.getEntityID()); MetadataMemoryProvider memoryProvider = new MetadataMemoryProvider(descriptor); memoryProvider.initialize(); MetadataProvider metadataProvider = new ExtendedMetadataDelegate(memoryProvider, extendedMetadata); manager.addMetadataProvider(metadataProvider); manager.setHostedIdpName(descriptor.getEntityID()); manager.refreshMetadata(); } catch (MetadataProviderException e) { log.error("Error generating system metadata", e); throw new ServletException("Error generating system metadata", e); } } } } }
java
protected void processMetadataInitialization(HttpServletRequest request) throws ServletException { // In case the hosted IdP metadata weren't initialized, let's do it now if (manager.getHostedIdpName() == null) { synchronized (IdpMetadataManager.class) { if (manager.getHostedIdpName() == null) { try { log.info( "No default metadata configured, generating with default values, please pre-configure metadata for production use"); // Defaults String alias = generator.getEntityAlias(); String baseURL = getDefaultBaseURL(request); // Use default baseURL if not set if (generator.getEntityBaseURL() == null) { log.warn( "Generated default entity base URL {} based on values in the first server request. Please set property entityBaseURL on MetadataGenerator bean to fixate the value.", baseURL); generator.setEntityBaseURL(baseURL); } else { baseURL = generator.getEntityBaseURL(); } // Use default entityID if not set if (generator.getEntityId() == null) { generator.setEntityId(getDefaultEntityID(baseURL, alias)); } // Ensure supported nameID formats in uaa are listed in the metadata Collection<String> supportedNameID = Arrays.asList(NameIDType.EMAIL, NameIDType.PERSISTENT, NameIDType.UNSPECIFIED); generator.setNameID(supportedNameID); EntityDescriptor descriptor = generator.generateMetadata(); ExtendedMetadata extendedMetadata = generator.generateExtendedMetadata(); log.info("Created default metadata for system with entityID: " + descriptor.getEntityID()); MetadataMemoryProvider memoryProvider = new MetadataMemoryProvider(descriptor); memoryProvider.initialize(); MetadataProvider metadataProvider = new ExtendedMetadataDelegate(memoryProvider, extendedMetadata); manager.addMetadataProvider(metadataProvider); manager.setHostedIdpName(descriptor.getEntityID()); manager.refreshMetadata(); } catch (MetadataProviderException e) { log.error("Error generating system metadata", e); throw new ServletException("Error generating system metadata", e); } } } } }
[ "protected", "void", "processMetadataInitialization", "(", "HttpServletRequest", "request", ")", "throws", "ServletException", "{", "// In case the hosted IdP metadata weren't initialized, let's do it now", "if", "(", "manager", ".", "getHostedIdpName", "(", ")", "==", "null", ")", "{", "synchronized", "(", "IdpMetadataManager", ".", "class", ")", "{", "if", "(", "manager", ".", "getHostedIdpName", "(", ")", "==", "null", ")", "{", "try", "{", "log", ".", "info", "(", "\"No default metadata configured, generating with default values, please pre-configure metadata for production use\"", ")", ";", "// Defaults", "String", "alias", "=", "generator", ".", "getEntityAlias", "(", ")", ";", "String", "baseURL", "=", "getDefaultBaseURL", "(", "request", ")", ";", "// Use default baseURL if not set", "if", "(", "generator", ".", "getEntityBaseURL", "(", ")", "==", "null", ")", "{", "log", ".", "warn", "(", "\"Generated default entity base URL {} based on values in the first server request. Please set property entityBaseURL on MetadataGenerator bean to fixate the value.\"", ",", "baseURL", ")", ";", "generator", ".", "setEntityBaseURL", "(", "baseURL", ")", ";", "}", "else", "{", "baseURL", "=", "generator", ".", "getEntityBaseURL", "(", ")", ";", "}", "// Use default entityID if not set", "if", "(", "generator", ".", "getEntityId", "(", ")", "==", "null", ")", "{", "generator", ".", "setEntityId", "(", "getDefaultEntityID", "(", "baseURL", ",", "alias", ")", ")", ";", "}", "// Ensure supported nameID formats in uaa are listed in the metadata", "Collection", "<", "String", ">", "supportedNameID", "=", "Arrays", ".", "asList", "(", "NameIDType", ".", "EMAIL", ",", "NameIDType", ".", "PERSISTENT", ",", "NameIDType", ".", "UNSPECIFIED", ")", ";", "generator", ".", "setNameID", "(", "supportedNameID", ")", ";", "EntityDescriptor", "descriptor", "=", "generator", ".", "generateMetadata", "(", ")", ";", "ExtendedMetadata", "extendedMetadata", "=", "generator", ".", "generateExtendedMetadata", "(", ")", ";", "log", ".", "info", "(", "\"Created default metadata for system with entityID: \"", "+", "descriptor", ".", "getEntityID", "(", ")", ")", ";", "MetadataMemoryProvider", "memoryProvider", "=", "new", "MetadataMemoryProvider", "(", "descriptor", ")", ";", "memoryProvider", ".", "initialize", "(", ")", ";", "MetadataProvider", "metadataProvider", "=", "new", "ExtendedMetadataDelegate", "(", "memoryProvider", ",", "extendedMetadata", ")", ";", "manager", ".", "addMetadataProvider", "(", "metadataProvider", ")", ";", "manager", ".", "setHostedIdpName", "(", "descriptor", ".", "getEntityID", "(", ")", ")", ";", "manager", ".", "refreshMetadata", "(", ")", ";", "}", "catch", "(", "MetadataProviderException", "e", ")", "{", "log", ".", "error", "(", "\"Error generating system metadata\"", ",", "e", ")", ";", "throw", "new", "ServletException", "(", "\"Error generating system metadata\"", ",", "e", ")", ";", "}", "}", "}", "}", "}" ]
Verifies whether generation is needed and if so the metadata document is created and stored in metadata manager. @param request request @throws javax.servlet.ServletException error
[ "Verifies", "whether", "generation", "is", "needed", "and", "if", "so", "the", "metadata", "document", "is", "created", "and", "stored", "in", "metadata", "manager", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGeneratorFilter.java#L101-L163
21,226
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGeneratorFilter.java
IdpMetadataGeneratorFilter.afterPropertiesSet
@Override public void afterPropertiesSet() throws ServletException { super.afterPropertiesSet(); Assert.notNull(generator, "Metadata generator"); Assert.notNull(manager, "MetadataManager must be set"); }
java
@Override public void afterPropertiesSet() throws ServletException { super.afterPropertiesSet(); Assert.notNull(generator, "Metadata generator"); Assert.notNull(manager, "MetadataManager must be set"); }
[ "@", "Override", "public", "void", "afterPropertiesSet", "(", ")", "throws", "ServletException", "{", "super", ".", "afterPropertiesSet", "(", ")", ";", "Assert", ".", "notNull", "(", "generator", ",", "\"Metadata generator\"", ")", ";", "Assert", ".", "notNull", "(", "manager", ",", "\"MetadataManager must be set\"", ")", ";", "}" ]
Verifies that required entities were autowired or set.
[ "Verifies", "that", "required", "entities", "were", "autowired", "or", "set", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGeneratorFilter.java#L227-L232
21,227
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/client/ClientAdminBootstrap.java
ClientAdminBootstrap.updateAutoApproveClients
private void updateAutoApproveClients() { autoApproveClients.removeAll(clientsToDelete); for (String clientId : autoApproveClients) { try { BaseClientDetails base = (BaseClientDetails) clientRegistrationService.loadClientByClientId(clientId, IdentityZone.getUaaZoneId()); base.addAdditionalInformation(ClientConstants.AUTO_APPROVE, true); logger.debug("Adding autoapprove flag to client: " + clientId); clientRegistrationService.updateClientDetails(base, IdentityZone.getUaaZoneId()); } catch (NoSuchClientException n) { logger.debug("Client not found, unable to set autoapprove: " + clientId); } } }
java
private void updateAutoApproveClients() { autoApproveClients.removeAll(clientsToDelete); for (String clientId : autoApproveClients) { try { BaseClientDetails base = (BaseClientDetails) clientRegistrationService.loadClientByClientId(clientId, IdentityZone.getUaaZoneId()); base.addAdditionalInformation(ClientConstants.AUTO_APPROVE, true); logger.debug("Adding autoapprove flag to client: " + clientId); clientRegistrationService.updateClientDetails(base, IdentityZone.getUaaZoneId()); } catch (NoSuchClientException n) { logger.debug("Client not found, unable to set autoapprove: " + clientId); } } }
[ "private", "void", "updateAutoApproveClients", "(", ")", "{", "autoApproveClients", ".", "removeAll", "(", "clientsToDelete", ")", ";", "for", "(", "String", "clientId", ":", "autoApproveClients", ")", "{", "try", "{", "BaseClientDetails", "base", "=", "(", "BaseClientDetails", ")", "clientRegistrationService", ".", "loadClientByClientId", "(", "clientId", ",", "IdentityZone", ".", "getUaaZoneId", "(", ")", ")", ";", "base", ".", "addAdditionalInformation", "(", "ClientConstants", ".", "AUTO_APPROVE", ",", "true", ")", ";", "logger", ".", "debug", "(", "\"Adding autoapprove flag to client: \"", "+", "clientId", ")", ";", "clientRegistrationService", ".", "updateClientDetails", "(", "base", ",", "IdentityZone", ".", "getUaaZoneId", "(", ")", ")", ";", "}", "catch", "(", "NoSuchClientException", "n", ")", "{", "logger", ".", "debug", "(", "\"Client not found, unable to set autoapprove: \"", "+", "clientId", ")", ";", "}", "}", "}" ]
Explicitly override autoapprove in all clients that were provided in the whitelist.
[ "Explicitly", "override", "autoapprove", "in", "all", "clients", "that", "were", "provided", "in", "the", "whitelist", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/client/ClientAdminBootstrap.java#L91-L103
21,228
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SPWebSSOProfileImpl.java
SPWebSSOProfileImpl.isEndpointSupported
@Override protected boolean isEndpointSupported(SingleSignOnService endpoint) throws MetadataProviderException { return SAML2_POST_BINDING_URI.equals(endpoint.getBinding()) || SAML2_REDIRECT_BINDING_URI.equals(endpoint.getBinding()); }
java
@Override protected boolean isEndpointSupported(SingleSignOnService endpoint) throws MetadataProviderException { return SAML2_POST_BINDING_URI.equals(endpoint.getBinding()) || SAML2_REDIRECT_BINDING_URI.equals(endpoint.getBinding()); }
[ "@", "Override", "protected", "boolean", "isEndpointSupported", "(", "SingleSignOnService", "endpoint", ")", "throws", "MetadataProviderException", "{", "return", "SAML2_POST_BINDING_URI", ".", "equals", "(", "endpoint", ".", "getBinding", "(", ")", ")", "||", "SAML2_REDIRECT_BINDING_URI", ".", "equals", "(", "endpoint", ".", "getBinding", "(", ")", ")", ";", "}" ]
Determines whether given SingleSignOn service can be used together with this profile. Bindings POST, Artifact and Redirect are supported for WebSSO. @param endpoint endpoint @return true if endpoint is supported @throws MetadataProviderException in case system can't verify whether endpoint is supported or not
[ "Determines", "whether", "given", "SingleSignOn", "service", "can", "be", "used", "together", "with", "this", "profile", ".", "Bindings", "POST", "Artifact", "and", "Redirect", "are", "supported", "for", "WebSSO", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SPWebSSOProfileImpl.java#L42-L47
21,229
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimGroupBootstrap.java
ScimGroupBootstrap.setGroups
public void setGroups(Map<String,String> groups) { if(groups==null) { groups = Collections.EMPTY_MAP; } groups.entrySet().forEach(e -> { if(!StringUtils.hasText(e.getValue())) { e.setValue((String) getMessageSource().getProperty(String.format(messagePropertyNameTemplate, e.getKey()))); } }); this.configuredGroups = groups; setCombinedGroups(); }
java
public void setGroups(Map<String,String> groups) { if(groups==null) { groups = Collections.EMPTY_MAP; } groups.entrySet().forEach(e -> { if(!StringUtils.hasText(e.getValue())) { e.setValue((String) getMessageSource().getProperty(String.format(messagePropertyNameTemplate, e.getKey()))); } }); this.configuredGroups = groups; setCombinedGroups(); }
[ "public", "void", "setGroups", "(", "Map", "<", "String", ",", "String", ">", "groups", ")", "{", "if", "(", "groups", "==", "null", ")", "{", "groups", "=", "Collections", ".", "EMPTY_MAP", ";", "}", "groups", ".", "entrySet", "(", ")", ".", "forEach", "(", "e", "->", "{", "if", "(", "!", "StringUtils", ".", "hasText", "(", "e", ".", "getValue", "(", ")", ")", ")", "{", "e", ".", "setValue", "(", "(", "String", ")", "getMessageSource", "(", ")", ".", "getProperty", "(", "String", ".", "format", "(", "messagePropertyNameTemplate", ",", "e", ".", "getKey", "(", ")", ")", ")", ")", ";", "}", "}", ")", ";", "this", ".", "configuredGroups", "=", "groups", ";", "setCombinedGroups", "(", ")", ";", "}" ]
Specify the list of groups to create as a comma-separated list of group-names @param groups
[ "Specify", "the", "list", "of", "groups", "to", "create", "as", "a", "comma", "-", "separated", "list", "of", "group", "-", "names" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/bootstrap/ScimGroupBootstrap.java#L114-L121
21,230
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.mapAliases
protected Collection<String> mapAliases(Collection<String> values) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (String value : values) { String alias = aliases.get(value); if (alias != null) { result.add(alias); } else { log.warn("Unsupported value " + value + " found"); } } return result; }
java
protected Collection<String> mapAliases(Collection<String> values) { LinkedHashSet<String> result = new LinkedHashSet<String>(); for (String value : values) { String alias = aliases.get(value); if (alias != null) { result.add(alias); } else { log.warn("Unsupported value " + value + " found"); } } return result; }
[ "protected", "Collection", "<", "String", ">", "mapAliases", "(", "Collection", "<", "String", ">", "values", ")", "{", "LinkedHashSet", "<", "String", ">", "result", "=", "new", "LinkedHashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "String", "alias", "=", "aliases", ".", "get", "(", "value", ")", ";", "if", "(", "alias", "!=", "null", ")", "{", "result", ".", "add", "(", "alias", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "\"Unsupported value \"", "+", "value", "+", "\" found\"", ")", ";", "}", "}", "return", "result", ";", "}" ]
Method iterates all values in the input, for each tries to resolve correct alias. When alias value is found, it is entered into the return collection, otherwise warning is logged. Values are returned in order of input with all duplicities removed. @param values input collection @return result with resolved aliases
[ "Method", "iterates", "all", "values", "in", "the", "input", "for", "each", "tries", "to", "resolve", "correct", "alias", ".", "When", "alias", "value", "is", "found", "it", "is", "entered", "into", "the", "return", "collection", "otherwise", "warning", "is", "logged", ".", "Values", "are", "returned", "in", "order", "of", "input", "with", "all", "duplicities", "removed", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L358-L369
21,231
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.setBindingsSSO
public void setBindingsSSO(Collection<String> bindingsSSO) { if (bindingsSSO == null) { this.bindingsSSO = Collections.emptyList(); } else { this.bindingsSSO = bindingsSSO; } }
java
public void setBindingsSSO(Collection<String> bindingsSSO) { if (bindingsSSO == null) { this.bindingsSSO = Collections.emptyList(); } else { this.bindingsSSO = bindingsSSO; } }
[ "public", "void", "setBindingsSSO", "(", "Collection", "<", "String", ">", "bindingsSSO", ")", "{", "if", "(", "bindingsSSO", "==", "null", ")", "{", "this", ".", "bindingsSSO", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "this", ".", "bindingsSSO", "=", "bindingsSSO", ";", "}", "}" ]
List of bindings to be included in the generated metadata for Web Single Sign-On. Ordering of bindings affects inclusion in the generated metadata. Supported values are: "post" (or "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"). The following bindings are included by default: "post" @param bindingsSSO bindings for web single sign-on
[ "List", "of", "bindings", "to", "be", "included", "in", "the", "generated", "metadata", "for", "Web", "Single", "Sign", "-", "On", ".", "Ordering", "of", "bindings", "affects", "inclusion", "in", "the", "generated", "metadata", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L668-L674
21,232
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.setBindingsSLO
public void setBindingsSLO(Collection<String> bindingsSLO) { if (bindingsSLO == null) { this.bindingsSLO = Collections.emptyList(); } else { this.bindingsSLO = bindingsSLO; } }
java
public void setBindingsSLO(Collection<String> bindingsSLO) { if (bindingsSLO == null) { this.bindingsSLO = Collections.emptyList(); } else { this.bindingsSLO = bindingsSLO; } }
[ "public", "void", "setBindingsSLO", "(", "Collection", "<", "String", ">", "bindingsSLO", ")", "{", "if", "(", "bindingsSLO", "==", "null", ")", "{", "this", ".", "bindingsSLO", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "this", ".", "bindingsSLO", "=", "bindingsSLO", ";", "}", "}" ]
List of bindings to be included in the generated metadata for Single Logout. Ordering of bindings affects inclusion in the generated metadata. Supported values are: "post" (or "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST") and "redirect" (or "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"). The following bindings are included by default: "post", "redirect" @param bindingsSLO bindings for single logout
[ "List", "of", "bindings", "to", "be", "included", "in", "the", "generated", "metadata", "for", "Single", "Logout", ".", "Ordering", "of", "bindings", "affects", "inclusion", "in", "the", "generated", "metadata", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L692-L698
21,233
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.setBindingsHoKSSO
public void setBindingsHoKSSO(Collection<String> bindingsHoKSSO) { if (bindingsHoKSSO == null) { this.bindingsHoKSSO = Collections.emptyList(); } else { this.bindingsHoKSSO = bindingsHoKSSO; } }
java
public void setBindingsHoKSSO(Collection<String> bindingsHoKSSO) { if (bindingsHoKSSO == null) { this.bindingsHoKSSO = Collections.emptyList(); } else { this.bindingsHoKSSO = bindingsHoKSSO; } }
[ "public", "void", "setBindingsHoKSSO", "(", "Collection", "<", "String", ">", "bindingsHoKSSO", ")", "{", "if", "(", "bindingsHoKSSO", "==", "null", ")", "{", "this", ".", "bindingsHoKSSO", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "this", ".", "bindingsHoKSSO", "=", "bindingsHoKSSO", ";", "}", "}" ]
List of bindings to be included in the generated metadata for Web Single Sign-On Holder of Key. Ordering of bindings affects inclusion in the generated metadata. "post" (or "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"). By default there are no included bindings for the profile. @param bindingsHoKSSO bindings for web single sign-on holder-of-key
[ "List", "of", "bindings", "to", "be", "included", "in", "the", "generated", "metadata", "for", "Web", "Single", "Sign", "-", "On", "Holder", "of", "Key", ".", "Ordering", "of", "bindings", "affects", "inclusion", "in", "the", "generated", "metadata", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L716-L722
21,234
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.getDiscoveryURL
protected String getDiscoveryURL(String entityBaseURL, String entityAlias) { if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryURL() != null && extendedMetadata.getIdpDiscoveryURL().length() > 0) { return extendedMetadata.getIdpDiscoveryURL(); } else { return getServerURL(entityBaseURL, entityAlias, getSAMLDiscoveryPath()); } }
java
protected String getDiscoveryURL(String entityBaseURL, String entityAlias) { if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryURL() != null && extendedMetadata.getIdpDiscoveryURL().length() > 0) { return extendedMetadata.getIdpDiscoveryURL(); } else { return getServerURL(entityBaseURL, entityAlias, getSAMLDiscoveryPath()); } }
[ "protected", "String", "getDiscoveryURL", "(", "String", "entityBaseURL", ",", "String", "entityAlias", ")", "{", "if", "(", "extendedMetadata", "!=", "null", "&&", "extendedMetadata", ".", "getIdpDiscoveryURL", "(", ")", "!=", "null", "&&", "extendedMetadata", ".", "getIdpDiscoveryURL", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "return", "extendedMetadata", ".", "getIdpDiscoveryURL", "(", ")", ";", "}", "else", "{", "return", "getServerURL", "(", "entityBaseURL", ",", "entityAlias", ",", "getSAMLDiscoveryPath", "(", ")", ")", ";", "}", "}" ]
Provides set discovery request url or generates a default when none was provided. Primarily value set on extenedMetadata property idpDiscoveryURL is used, when empty local property customDiscoveryURL is used, when empty URL is automatically generated. @param entityBaseURL base URL for generation of endpoints @param entityAlias alias of entity, or null when there's no alias required @return URL to use for IDP discovery request
[ "Provides", "set", "discovery", "request", "url", "or", "generates", "a", "default", "when", "none", "was", "provided", ".", "Primarily", "value", "set", "on", "extenedMetadata", "property", "idpDiscoveryURL", "is", "used", "when", "empty", "local", "property", "customDiscoveryURL", "is", "used", "when", "empty", "URL", "is", "automatically", "generated", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L775-L782
21,235
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.getDiscoveryResponseURL
protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) { if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null && extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) { return extendedMetadata.getIdpDiscoveryResponseURL(); } else { Map<String, String> params = new HashMap<String, String>(); params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true"); return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params); } }
java
protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) { if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null && extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) { return extendedMetadata.getIdpDiscoveryResponseURL(); } else { Map<String, String> params = new HashMap<String, String>(); params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true"); return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params); } }
[ "protected", "String", "getDiscoveryResponseURL", "(", "String", "entityBaseURL", ",", "String", "entityAlias", ")", "{", "if", "(", "extendedMetadata", "!=", "null", "&&", "extendedMetadata", ".", "getIdpDiscoveryResponseURL", "(", ")", "!=", "null", "&&", "extendedMetadata", ".", "getIdpDiscoveryResponseURL", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "return", "extendedMetadata", ".", "getIdpDiscoveryResponseURL", "(", ")", ";", "}", "else", "{", "Map", "<", "String", ",", "String", ">", "params", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "params", ".", "put", "(", "SAMLEntryPoint", ".", "DISCOVERY_RESPONSE_PARAMETER", ",", "\"true\"", ")", ";", "return", "getServerURL", "(", "entityBaseURL", ",", "entityAlias", ",", "getSAMLEntryPointPath", "(", ")", ",", "params", ")", ";", "}", "}" ]
Provides set discovery response url or generates a default when none was provided. Primarily value set on extenedMetadata property idpDiscoveryResponseURL is used, when empty local property customDiscoveryResponseURL is used, when empty URL is automatically generated. @param entityBaseURL base URL for generation of endpoints @param entityAlias alias of entity, or null when there's no alias required @return URL to use for IDP discovery response
[ "Provides", "set", "discovery", "response", "url", "or", "generates", "a", "default", "when", "none", "was", "provided", ".", "Primarily", "value", "set", "on", "extenedMetadata", "property", "idpDiscoveryResponseURL", "is", "used", "when", "empty", "local", "property", "customDiscoveryResponseURL", "is", "used", "when", "empty", "URL", "is", "automatically", "generated", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L795-L804
21,236
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.getSigningKey
protected String getSigningKey() { if (extendedMetadata != null && extendedMetadata.getSigningKey() != null) { return extendedMetadata.getSigningKey(); } else { return keyManager.getDefaultCredentialName(); } }
java
protected String getSigningKey() { if (extendedMetadata != null && extendedMetadata.getSigningKey() != null) { return extendedMetadata.getSigningKey(); } else { return keyManager.getDefaultCredentialName(); } }
[ "protected", "String", "getSigningKey", "(", ")", "{", "if", "(", "extendedMetadata", "!=", "null", "&&", "extendedMetadata", ".", "getSigningKey", "(", ")", "!=", "null", ")", "{", "return", "extendedMetadata", ".", "getSigningKey", "(", ")", ";", "}", "else", "{", "return", "keyManager", ".", "getDefaultCredentialName", "(", ")", ";", "}", "}" ]
Provides key used for signing from extended metadata. Uses default key when key is not specified. @return signing key
[ "Provides", "key", "used", "for", "signing", "from", "extended", "metadata", ".", "Uses", "default", "key", "when", "key", "is", "not", "specified", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L811-L817
21,237
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java
IdpMetadataGenerator.getEncryptionKey
protected String getEncryptionKey() { if (extendedMetadata != null && extendedMetadata.getEncryptionKey() != null) { return extendedMetadata.getEncryptionKey(); } else { return keyManager.getDefaultCredentialName(); } }
java
protected String getEncryptionKey() { if (extendedMetadata != null && extendedMetadata.getEncryptionKey() != null) { return extendedMetadata.getEncryptionKey(); } else { return keyManager.getDefaultCredentialName(); } }
[ "protected", "String", "getEncryptionKey", "(", ")", "{", "if", "(", "extendedMetadata", "!=", "null", "&&", "extendedMetadata", ".", "getEncryptionKey", "(", ")", "!=", "null", ")", "{", "return", "extendedMetadata", ".", "getEncryptionKey", "(", ")", ";", "}", "else", "{", "return", "keyManager", ".", "getDefaultCredentialName", "(", ")", ";", "}", "}" ]
Provides key used for encryption from extended metadata. Uses default when key is not specified. @return encryption key
[ "Provides", "key", "used", "for", "encryption", "from", "extended", "metadata", ".", "Uses", "default", "when", "key", "is", "not", "specified", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/idp/IdpMetadataGenerator.java#L824-L830
21,238
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/util/ScimUtils.java
ScimUtils.getExpiringCode
public static ExpiringCode getExpiringCode( ExpiringCodeStore codeStore, String userId, String email, String clientId, String redirectUri, ExpiringCodeType intent, String currentZoneId) { Assert.notNull(codeStore, "codeStore must not be null"); Assert.notNull(userId, "userId must not be null"); Assert.notNull(email, "email must not be null"); Assert.notNull(intent, "intent must not be null"); Map<String, String> codeData = new HashMap<>(); codeData.put("user_id", userId); codeData.put("email", email); codeData.put("client_id", clientId); if (redirectUri != null) { codeData.put("redirect_uri", redirectUri); } String codeDataString = JsonUtils.writeValueAsString(codeData); Timestamp expiresAt = new Timestamp(System.currentTimeMillis() + (60 * 60 * 1000)); // 1 hour return codeStore.generateCode( codeDataString, expiresAt, intent.name(), currentZoneId); }
java
public static ExpiringCode getExpiringCode( ExpiringCodeStore codeStore, String userId, String email, String clientId, String redirectUri, ExpiringCodeType intent, String currentZoneId) { Assert.notNull(codeStore, "codeStore must not be null"); Assert.notNull(userId, "userId must not be null"); Assert.notNull(email, "email must not be null"); Assert.notNull(intent, "intent must not be null"); Map<String, String> codeData = new HashMap<>(); codeData.put("user_id", userId); codeData.put("email", email); codeData.put("client_id", clientId); if (redirectUri != null) { codeData.put("redirect_uri", redirectUri); } String codeDataString = JsonUtils.writeValueAsString(codeData); Timestamp expiresAt = new Timestamp(System.currentTimeMillis() + (60 * 60 * 1000)); // 1 hour return codeStore.generateCode( codeDataString, expiresAt, intent.name(), currentZoneId); }
[ "public", "static", "ExpiringCode", "getExpiringCode", "(", "ExpiringCodeStore", "codeStore", ",", "String", "userId", ",", "String", "email", ",", "String", "clientId", ",", "String", "redirectUri", ",", "ExpiringCodeType", "intent", ",", "String", "currentZoneId", ")", "{", "Assert", ".", "notNull", "(", "codeStore", ",", "\"codeStore must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "userId", ",", "\"userId must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "email", ",", "\"email must not be null\"", ")", ";", "Assert", ".", "notNull", "(", "intent", ",", "\"intent must not be null\"", ")", ";", "Map", "<", "String", ",", "String", ">", "codeData", "=", "new", "HashMap", "<>", "(", ")", ";", "codeData", ".", "put", "(", "\"user_id\"", ",", "userId", ")", ";", "codeData", ".", "put", "(", "\"email\"", ",", "email", ")", ";", "codeData", ".", "put", "(", "\"client_id\"", ",", "clientId", ")", ";", "if", "(", "redirectUri", "!=", "null", ")", "{", "codeData", ".", "put", "(", "\"redirect_uri\"", ",", "redirectUri", ")", ";", "}", "String", "codeDataString", "=", "JsonUtils", ".", "writeValueAsString", "(", "codeData", ")", ";", "Timestamp", "expiresAt", "=", "new", "Timestamp", "(", "System", ".", "currentTimeMillis", "(", ")", "+", "(", "60", "*", "60", "*", "1000", ")", ")", ";", "// 1 hour", "return", "codeStore", ".", "generateCode", "(", "codeDataString", ",", "expiresAt", ",", "intent", ".", "name", "(", ")", ",", "currentZoneId", ")", ";", "}" ]
Generates a 1 hour expiring code. @param codeStore the code store to use, must not be null @param userId the user id that will be included in the code's data, must not be null @param email the email that will be included in the code's data, must not be null @param clientId client id that will be included in the code's data, must not be null @param redirectUri the redirect uri that will be included in the code's data, may be null @param intent the intended purpose of the generated code @param currentZoneId the ID of the current IdentityZone @return the expiring code
[ "Generates", "a", "1", "hour", "expiring", "code", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/util/ScimUtils.java#L44-L72
21,239
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/util/ScimUtils.java
ScimUtils.getVerificationURL
public static URL getVerificationURL( ExpiringCode expiringCode, IdentityZone currentIdentityZone) { String url = ""; try { url = UaaUrlUtils.getUaaUrl("/verify_user", true, currentIdentityZone); if (expiringCode != null) { url += "?code=" + expiringCode.getCode(); } return new URL(url); } catch (MalformedURLException mfue) { logger.error(String.format("Unexpected error creating user verification URL from %s", url), mfue); } throw new IllegalStateException(); }
java
public static URL getVerificationURL( ExpiringCode expiringCode, IdentityZone currentIdentityZone) { String url = ""; try { url = UaaUrlUtils.getUaaUrl("/verify_user", true, currentIdentityZone); if (expiringCode != null) { url += "?code=" + expiringCode.getCode(); } return new URL(url); } catch (MalformedURLException mfue) { logger.error(String.format("Unexpected error creating user verification URL from %s", url), mfue); } throw new IllegalStateException(); }
[ "public", "static", "URL", "getVerificationURL", "(", "ExpiringCode", "expiringCode", ",", "IdentityZone", "currentIdentityZone", ")", "{", "String", "url", "=", "\"\"", ";", "try", "{", "url", "=", "UaaUrlUtils", ".", "getUaaUrl", "(", "\"/verify_user\"", ",", "true", ",", "currentIdentityZone", ")", ";", "if", "(", "expiringCode", "!=", "null", ")", "{", "url", "+=", "\"?code=\"", "+", "expiringCode", ".", "getCode", "(", ")", ";", "}", "return", "new", "URL", "(", "url", ")", ";", "}", "catch", "(", "MalformedURLException", "mfue", ")", "{", "logger", ".", "error", "(", "String", ".", "format", "(", "\"Unexpected error creating user verification URL from %s\"", ",", "url", ")", ",", "mfue", ")", ";", "}", "throw", "new", "IllegalStateException", "(", ")", ";", "}" ]
Returns a verification URL that may be sent to a user. @param expiringCode the expiring code to include on the URL, may be null @param currentIdentityZone the current IdentityZone @return the verification URL
[ "Returns", "a", "verification", "URL", "that", "may", "be", "sent", "to", "a", "user", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/util/ScimUtils.java#L81-L97
21,240
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SamlIdentityProviderConfigurator.java
SamlIdentityProviderConfigurator.validateSamlIdentityProviderDefinition
public synchronized void validateSamlIdentityProviderDefinition(SamlIdentityProviderDefinition providerDefinition) throws MetadataProviderException { ExtendedMetadataDelegate added, deleted = null; if (providerDefinition == null) { throw new NullPointerException(); } if (!hasText(providerDefinition.getIdpEntityAlias())) { throw new NullPointerException("SAML IDP Alias must be set"); } if (!hasText(providerDefinition.getZoneId())) { throw new NullPointerException("IDP Zone Id must be set"); } SamlIdentityProviderDefinition clone = providerDefinition.clone(); added = getExtendedMetadataDelegate(clone); String entityIDToBeAdded = ((ConfigMetadataProvider) added.getDelegate()).getEntityID(); if (!StringUtils.hasText(entityIDToBeAdded)) { throw new MetadataProviderException("Emtpy entityID for SAML provider with zoneId:" + providerDefinition.getZoneId() + " and origin:" + providerDefinition.getIdpEntityAlias()); } boolean entityIDexists = false; for (SamlIdentityProviderDefinition existing : getIdentityProviderDefinitions()) { ConfigMetadataProvider existingProvider = (ConfigMetadataProvider) getExtendedMetadataDelegate(existing).getDelegate(); if (entityIDToBeAdded.equals(existingProvider.getEntityID()) && !(existing.getUniqueAlias().equals(clone.getUniqueAlias()))) { entityIDexists = true; break; } } if (entityIDexists) { throw new MetadataProviderException("Duplicate entity ID:" + entityIDToBeAdded); } }
java
public synchronized void validateSamlIdentityProviderDefinition(SamlIdentityProviderDefinition providerDefinition) throws MetadataProviderException { ExtendedMetadataDelegate added, deleted = null; if (providerDefinition == null) { throw new NullPointerException(); } if (!hasText(providerDefinition.getIdpEntityAlias())) { throw new NullPointerException("SAML IDP Alias must be set"); } if (!hasText(providerDefinition.getZoneId())) { throw new NullPointerException("IDP Zone Id must be set"); } SamlIdentityProviderDefinition clone = providerDefinition.clone(); added = getExtendedMetadataDelegate(clone); String entityIDToBeAdded = ((ConfigMetadataProvider) added.getDelegate()).getEntityID(); if (!StringUtils.hasText(entityIDToBeAdded)) { throw new MetadataProviderException("Emtpy entityID for SAML provider with zoneId:" + providerDefinition.getZoneId() + " and origin:" + providerDefinition.getIdpEntityAlias()); } boolean entityIDexists = false; for (SamlIdentityProviderDefinition existing : getIdentityProviderDefinitions()) { ConfigMetadataProvider existingProvider = (ConfigMetadataProvider) getExtendedMetadataDelegate(existing).getDelegate(); if (entityIDToBeAdded.equals(existingProvider.getEntityID()) && !(existing.getUniqueAlias().equals(clone.getUniqueAlias()))) { entityIDexists = true; break; } } if (entityIDexists) { throw new MetadataProviderException("Duplicate entity ID:" + entityIDToBeAdded); } }
[ "public", "synchronized", "void", "validateSamlIdentityProviderDefinition", "(", "SamlIdentityProviderDefinition", "providerDefinition", ")", "throws", "MetadataProviderException", "{", "ExtendedMetadataDelegate", "added", ",", "deleted", "=", "null", ";", "if", "(", "providerDefinition", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "if", "(", "!", "hasText", "(", "providerDefinition", ".", "getIdpEntityAlias", "(", ")", ")", ")", "{", "throw", "new", "NullPointerException", "(", "\"SAML IDP Alias must be set\"", ")", ";", "}", "if", "(", "!", "hasText", "(", "providerDefinition", ".", "getZoneId", "(", ")", ")", ")", "{", "throw", "new", "NullPointerException", "(", "\"IDP Zone Id must be set\"", ")", ";", "}", "SamlIdentityProviderDefinition", "clone", "=", "providerDefinition", ".", "clone", "(", ")", ";", "added", "=", "getExtendedMetadataDelegate", "(", "clone", ")", ";", "String", "entityIDToBeAdded", "=", "(", "(", "ConfigMetadataProvider", ")", "added", ".", "getDelegate", "(", ")", ")", ".", "getEntityID", "(", ")", ";", "if", "(", "!", "StringUtils", ".", "hasText", "(", "entityIDToBeAdded", ")", ")", "{", "throw", "new", "MetadataProviderException", "(", "\"Emtpy entityID for SAML provider with zoneId:\"", "+", "providerDefinition", ".", "getZoneId", "(", ")", "+", "\" and origin:\"", "+", "providerDefinition", ".", "getIdpEntityAlias", "(", ")", ")", ";", "}", "boolean", "entityIDexists", "=", "false", ";", "for", "(", "SamlIdentityProviderDefinition", "existing", ":", "getIdentityProviderDefinitions", "(", ")", ")", "{", "ConfigMetadataProvider", "existingProvider", "=", "(", "ConfigMetadataProvider", ")", "getExtendedMetadataDelegate", "(", "existing", ")", ".", "getDelegate", "(", ")", ";", "if", "(", "entityIDToBeAdded", ".", "equals", "(", "existingProvider", ".", "getEntityID", "(", ")", ")", "&&", "!", "(", "existing", ".", "getUniqueAlias", "(", ")", ".", "equals", "(", "clone", ".", "getUniqueAlias", "(", ")", ")", ")", ")", "{", "entityIDexists", "=", "true", ";", "break", ";", "}", "}", "if", "(", "entityIDexists", ")", "{", "throw", "new", "MetadataProviderException", "(", "\"Duplicate entity ID:\"", "+", "entityIDToBeAdded", ")", ";", "}", "}" ]
adds or replaces a SAML identity proviider @param providerDefinition - the provider to be added @throws MetadataProviderException if the system fails to fetch meta data for this provider
[ "adds", "or", "replaces", "a", "SAML", "identity", "proviider" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/SamlIdentityProviderConfigurator.java#L79-L111
21,241
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioning.java
JdbcScimUserProvisioning.checkPasswordMatches
public boolean checkPasswordMatches(String id, String password, String zoneId) { String currentPassword; try { currentPassword = jdbcTemplate.queryForObject( READ_PASSWORD_SQL, new Object[] { id, zoneId}, new int[] { VARCHAR, VARCHAR }, String.class ); } catch (IncorrectResultSizeDataAccessException e) { throw new ScimResourceNotFoundException("User " + id + " does not exist"); } return passwordEncoder.matches(password, currentPassword); }
java
public boolean checkPasswordMatches(String id, String password, String zoneId) { String currentPassword; try { currentPassword = jdbcTemplate.queryForObject( READ_PASSWORD_SQL, new Object[] { id, zoneId}, new int[] { VARCHAR, VARCHAR }, String.class ); } catch (IncorrectResultSizeDataAccessException e) { throw new ScimResourceNotFoundException("User " + id + " does not exist"); } return passwordEncoder.matches(password, currentPassword); }
[ "public", "boolean", "checkPasswordMatches", "(", "String", "id", ",", "String", "password", ",", "String", "zoneId", ")", "{", "String", "currentPassword", ";", "try", "{", "currentPassword", "=", "jdbcTemplate", ".", "queryForObject", "(", "READ_PASSWORD_SQL", ",", "new", "Object", "[", "]", "{", "id", ",", "zoneId", "}", ",", "new", "int", "[", "]", "{", "VARCHAR", ",", "VARCHAR", "}", ",", "String", ".", "class", ")", ";", "}", "catch", "(", "IncorrectResultSizeDataAccessException", "e", ")", "{", "throw", "new", "ScimResourceNotFoundException", "(", "\"User \"", "+", "id", "+", "\" does not exist\"", ")", ";", "}", "return", "passwordEncoder", ".", "matches", "(", "password", ",", "currentPassword", ")", ";", "}" ]
Checks the existing password for a user
[ "Checks", "the", "existing", "password", "for", "a", "user" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioning.java#L308-L323
21,242
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioning.java
JdbcScimUserProvisioning.setUsernamePattern
public void setUsernamePattern(String usernamePattern) { Assert.hasText(usernamePattern, "Username pattern must not be empty"); this.usernamePattern = Pattern.compile(usernamePattern); }
java
public void setUsernamePattern(String usernamePattern) { Assert.hasText(usernamePattern, "Username pattern must not be empty"); this.usernamePattern = Pattern.compile(usernamePattern); }
[ "public", "void", "setUsernamePattern", "(", "String", "usernamePattern", ")", "{", "Assert", ".", "hasText", "(", "usernamePattern", ",", "\"Username pattern must not be empty\"", ")", ";", "this", ".", "usernamePattern", "=", "Pattern", ".", "compile", "(", "usernamePattern", ")", ";", "}" ]
Sets the regular expression which will be used to validate the username.
[ "Sets", "the", "regular", "expression", "which", "will", "be", "used", "to", "validate", "the", "username", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/jdbc/JdbcScimUserProvisioning.java#L424-L427
21,243
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaPagingUtils.java
UaaPagingUtils.subList
public static <T> List<T> subList(List<T> input, int startIndex, int count) { int fromIndex = startIndex - 1; int toIndex = fromIndex + count; if (toIndex >= input.size()) { toIndex = input.size(); } if (fromIndex >= toIndex) { return Collections.emptyList(); } return input.subList(fromIndex, toIndex); }
java
public static <T> List<T> subList(List<T> input, int startIndex, int count) { int fromIndex = startIndex - 1; int toIndex = fromIndex + count; if (toIndex >= input.size()) { toIndex = input.size(); } if (fromIndex >= toIndex) { return Collections.emptyList(); } return input.subList(fromIndex, toIndex); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "subList", "(", "List", "<", "T", ">", "input", ",", "int", "startIndex", ",", "int", "count", ")", "{", "int", "fromIndex", "=", "startIndex", "-", "1", ";", "int", "toIndex", "=", "fromIndex", "+", "count", ";", "if", "(", "toIndex", ">=", "input", ".", "size", "(", ")", ")", "{", "toIndex", "=", "input", ".", "size", "(", ")", ";", "}", "if", "(", "fromIndex", ">=", "toIndex", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "return", "input", ".", "subList", "(", "fromIndex", ",", "toIndex", ")", ";", "}" ]
Calculates the substring of a list based on a 1 based start index never exceeding the bounds of the list. @param input @param startIndex @param count @return
[ "Calculates", "the", "substring", "of", "a", "list", "based", "on", "a", "1", "based", "start", "index", "never", "exceeding", "the", "bounds", "of", "the", "list", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaPagingUtils.java#L30-L40
21,244
cloudfoundry/uaa
model/src/main/java/org/cloudfoundry/identity/uaa/provider/ExternalIdentityProviderDefinition.java
ExternalIdentityProviderDefinition.addAttributeMapping
@JsonIgnore public void addAttributeMapping(String key, Object value) { attributeMappings.put(key, value); }
java
@JsonIgnore public void addAttributeMapping(String key, Object value) { attributeMappings.put(key, value); }
[ "@", "JsonIgnore", "public", "void", "addAttributeMapping", "(", "String", "key", ",", "Object", "value", ")", "{", "attributeMappings", ".", "put", "(", "key", ",", "value", ")", ";", "}" ]
adds an attribute mapping, where the key is known to the UAA and the value represents the attribute name on the IDP @param key - known to the UAA, such as {@link #EMAIL_ATTRIBUTE_NAME}, {@link #GROUP_ATTRIBUTE_NAME}, {@link #PHONE_NUMBER_ATTRIBUTE_NAME} @param value - the name of the attribute on the IDP side, for example <code>emailAddress</code>
[ "adds", "an", "attribute", "mapping", "where", "the", "key", "is", "known", "to", "the", "UAA", "and", "the", "value", "represents", "the", "attribute", "name", "on", "the", "IDP" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/model/src/main/java/org/cloudfoundry/identity/uaa/provider/ExternalIdentityProviderDefinition.java#L75-L78
21,245
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/authentication/SamlAssertionDecoder.java
SamlAssertionDecoder.getBase64DecodedMessage
protected InputStream getBase64DecodedMessage(HTTPInTransport transport) throws MessageDecodingException { log.debug("Getting Base64 encoded message from request"); String encodedMessage = transport.getParameterValue("assertion"); if (DatatypeHelper.isEmpty(encodedMessage)) { log.error("Request did not contain either a SAMLRequest or " + "SAMLResponse paramter. Invalid request for SAML 2 HTTP POST binding."); throw new MessageDecodingException("No SAML message present in request"); } log.trace("Base64 decoding SAML message:\n{}", encodedMessage); byte[] decodedBytes = org.apache.commons.codec.binary.Base64.decodeBase64(encodedMessage.getBytes(StandardCharsets.UTF_8)); if(decodedBytes == null){ log.error("Unable to Base64 decode SAML message"); throw new MessageDecodingException("Unable to Base64 decode SAML message"); } log.trace("Decoded SAML message:\n{}", new String(decodedBytes)); return new ByteArrayInputStream(decodedBytes); }
java
protected InputStream getBase64DecodedMessage(HTTPInTransport transport) throws MessageDecodingException { log.debug("Getting Base64 encoded message from request"); String encodedMessage = transport.getParameterValue("assertion"); if (DatatypeHelper.isEmpty(encodedMessage)) { log.error("Request did not contain either a SAMLRequest or " + "SAMLResponse paramter. Invalid request for SAML 2 HTTP POST binding."); throw new MessageDecodingException("No SAML message present in request"); } log.trace("Base64 decoding SAML message:\n{}", encodedMessage); byte[] decodedBytes = org.apache.commons.codec.binary.Base64.decodeBase64(encodedMessage.getBytes(StandardCharsets.UTF_8)); if(decodedBytes == null){ log.error("Unable to Base64 decode SAML message"); throw new MessageDecodingException("Unable to Base64 decode SAML message"); } log.trace("Decoded SAML message:\n{}", new String(decodedBytes)); return new ByteArrayInputStream(decodedBytes); }
[ "protected", "InputStream", "getBase64DecodedMessage", "(", "HTTPInTransport", "transport", ")", "throws", "MessageDecodingException", "{", "log", ".", "debug", "(", "\"Getting Base64 encoded message from request\"", ")", ";", "String", "encodedMessage", "=", "transport", ".", "getParameterValue", "(", "\"assertion\"", ")", ";", "if", "(", "DatatypeHelper", ".", "isEmpty", "(", "encodedMessage", ")", ")", "{", "log", ".", "error", "(", "\"Request did not contain either a SAMLRequest or \"", "+", "\"SAMLResponse paramter. Invalid request for SAML 2 HTTP POST binding.\"", ")", ";", "throw", "new", "MessageDecodingException", "(", "\"No SAML message present in request\"", ")", ";", "}", "log", ".", "trace", "(", "\"Base64 decoding SAML message:\\n{}\"", ",", "encodedMessage", ")", ";", "byte", "[", "]", "decodedBytes", "=", "org", ".", "apache", ".", "commons", ".", "codec", ".", "binary", ".", "Base64", ".", "decodeBase64", "(", "encodedMessage", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ")", ";", "if", "(", "decodedBytes", "==", "null", ")", "{", "log", ".", "error", "(", "\"Unable to Base64 decode SAML message\"", ")", ";", "throw", "new", "MessageDecodingException", "(", "\"Unable to Base64 decode SAML message\"", ")", ";", "}", "log", ".", "trace", "(", "\"Decoded SAML message:\\n{}\"", ",", "new", "String", "(", "decodedBytes", ")", ")", ";", "return", "new", "ByteArrayInputStream", "(", "decodedBytes", ")", ";", "}" ]
Gets the Base64 encoded message from the request and decodes it. @param transport inbound message transport @return decoded message @throws MessageDecodingException thrown if the message does not contain a base64 encoded SAML message
[ "Gets", "the", "Base64", "encoded", "message", "from", "the", "request", "and", "decodes", "it", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/authentication/SamlAssertionDecoder.java#L115-L135
21,246
cloudfoundry/uaa
model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java
ScimUser.addEmail
public void addEmail(String newEmail) { Assert.hasText(newEmail, "Attempted to add null or empty email string to user."); if (emails == null) { emails = new ArrayList<>(1); } for (Email email : emails) { if (email.value.equals(newEmail)) { throw new IllegalArgumentException("Already contains email " + newEmail); } } Email e = new Email(); e.setValue(newEmail); emails.add(e); }
java
public void addEmail(String newEmail) { Assert.hasText(newEmail, "Attempted to add null or empty email string to user."); if (emails == null) { emails = new ArrayList<>(1); } for (Email email : emails) { if (email.value.equals(newEmail)) { throw new IllegalArgumentException("Already contains email " + newEmail); } } Email e = new Email(); e.setValue(newEmail); emails.add(e); }
[ "public", "void", "addEmail", "(", "String", "newEmail", ")", "{", "Assert", ".", "hasText", "(", "newEmail", ",", "\"Attempted to add null or empty email string to user.\"", ")", ";", "if", "(", "emails", "==", "null", ")", "{", "emails", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "}", "for", "(", "Email", "email", ":", "emails", ")", "{", "if", "(", "email", ".", "value", ".", "equals", "(", "newEmail", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Already contains email \"", "+", "newEmail", ")", ";", "}", "}", "Email", "e", "=", "new", "Email", "(", ")", ";", "e", ".", "setValue", "(", "newEmail", ")", ";", "emails", ".", "add", "(", "e", ")", ";", "}" ]
Adds a new email address, ignoring "type" and "primary" fields, which we don't need yet
[ "Adds", "a", "new", "email", "address", "ignoring", "type", "and", "primary", "fields", "which", "we", "don", "t", "need", "yet" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java#L637-L652
21,247
cloudfoundry/uaa
model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java
ScimUser.addPhoneNumber
public void addPhoneNumber(String newPhoneNumber) { if (newPhoneNumber==null || newPhoneNumber.trim().length()==0) { return; } if (phoneNumbers == null) { phoneNumbers = new ArrayList<>(1); } for (PhoneNumber phoneNumber : phoneNumbers) { if (phoneNumber.value.equals(newPhoneNumber) && phoneNumber.getType() == null) { throw new IllegalArgumentException("Already contains phoneNumber " + newPhoneNumber); } } PhoneNumber number = new PhoneNumber(); number.setValue(newPhoneNumber); phoneNumbers.add(number); }
java
public void addPhoneNumber(String newPhoneNumber) { if (newPhoneNumber==null || newPhoneNumber.trim().length()==0) { return; } if (phoneNumbers == null) { phoneNumbers = new ArrayList<>(1); } for (PhoneNumber phoneNumber : phoneNumbers) { if (phoneNumber.value.equals(newPhoneNumber) && phoneNumber.getType() == null) { throw new IllegalArgumentException("Already contains phoneNumber " + newPhoneNumber); } } PhoneNumber number = new PhoneNumber(); number.setValue(newPhoneNumber); phoneNumbers.add(number); }
[ "public", "void", "addPhoneNumber", "(", "String", "newPhoneNumber", ")", "{", "if", "(", "newPhoneNumber", "==", "null", "||", "newPhoneNumber", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "return", ";", "}", "if", "(", "phoneNumbers", "==", "null", ")", "{", "phoneNumbers", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "}", "for", "(", "PhoneNumber", "phoneNumber", ":", "phoneNumbers", ")", "{", "if", "(", "phoneNumber", ".", "value", ".", "equals", "(", "newPhoneNumber", ")", "&&", "phoneNumber", ".", "getType", "(", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Already contains phoneNumber \"", "+", "newPhoneNumber", ")", ";", "}", "}", "PhoneNumber", "number", "=", "new", "PhoneNumber", "(", ")", ";", "number", ".", "setValue", "(", "newPhoneNumber", ")", ";", "phoneNumbers", ".", "add", "(", "number", ")", ";", "}" ]
Adds a new phone number with null type. @param newPhoneNumber
[ "Adds", "a", "new", "phone", "number", "with", "null", "type", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java#L659-L676
21,248
cloudfoundry/uaa
model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java
ScimUser.wordList
List<String> wordList() { List<String> words = new ArrayList<>(); if (userName != null) { words.add(userName); } if (name != null) { if (name.givenName != null) { words.add(name.givenName); } if (name.familyName != null) { words.add(name.familyName); } if (nickName != null) { words.add(nickName); } } if (emails != null) { for (Email email : emails) { words.add(email.getValue()); } } return words; }
java
List<String> wordList() { List<String> words = new ArrayList<>(); if (userName != null) { words.add(userName); } if (name != null) { if (name.givenName != null) { words.add(name.givenName); } if (name.familyName != null) { words.add(name.familyName); } if (nickName != null) { words.add(nickName); } } if (emails != null) { for (Email email : emails) { words.add(email.getValue()); } } return words; }
[ "List", "<", "String", ">", "wordList", "(", ")", "{", "List", "<", "String", ">", "words", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "userName", "!=", "null", ")", "{", "words", ".", "add", "(", "userName", ")", ";", "}", "if", "(", "name", "!=", "null", ")", "{", "if", "(", "name", ".", "givenName", "!=", "null", ")", "{", "words", ".", "add", "(", "name", ".", "givenName", ")", ";", "}", "if", "(", "name", ".", "familyName", "!=", "null", ")", "{", "words", ".", "add", "(", "name", ".", "familyName", ")", ";", "}", "if", "(", "nickName", "!=", "null", ")", "{", "words", ".", "add", "(", "nickName", ")", ";", "}", "}", "if", "(", "emails", "!=", "null", ")", "{", "for", "(", "Email", "email", ":", "emails", ")", "{", "words", ".", "add", "(", "email", ".", "getValue", "(", ")", ")", ";", "}", "}", "return", "words", ";", "}" ]
Creates a word list from the user data for use in password checking implementations
[ "Creates", "a", "word", "list", "from", "the", "user", "data", "for", "use", "in", "password", "checking", "implementations" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/model/src/main/java/org/cloudfoundry/identity/uaa/scim/ScimUser.java#L682-L708
21,249
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/NonSnarlMetadataManager.java
NonSnarlMetadataManager.addDescriptor
private void addDescriptor(List<String> result, EntityDescriptor descriptor) throws MetadataProviderException { String entityID = descriptor.getEntityID(); log.debug("Found metadata EntityDescriptor with ID", entityID); result.add(entityID); }
java
private void addDescriptor(List<String> result, EntityDescriptor descriptor) throws MetadataProviderException { String entityID = descriptor.getEntityID(); log.debug("Found metadata EntityDescriptor with ID", entityID); result.add(entityID); }
[ "private", "void", "addDescriptor", "(", "List", "<", "String", ">", "result", ",", "EntityDescriptor", "descriptor", ")", "throws", "MetadataProviderException", "{", "String", "entityID", "=", "descriptor", ".", "getEntityID", "(", ")", ";", "log", ".", "debug", "(", "\"Found metadata EntityDescriptor with ID\"", ",", "entityID", ")", ";", "result", ".", "add", "(", "entityID", ")", ";", "}" ]
Parses entityID from the descriptor and adds it to the result set. Signatures on all found entities are verified using the given policy and trust engine. @param result result set @param descriptor descriptor to parse @throws MetadataProviderException in case signature validation fails
[ "Parses", "entityID", "from", "the", "descriptor", "and", "adds", "it", "to", "the", "result", "set", ".", "Signatures", "on", "all", "found", "entities", "are", "verified", "using", "the", "given", "policy", "and", "trust", "engine", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/saml/NonSnarlMetadataManager.java#L384-L390
21,250
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/account/ProfileController.java
ProfileController.get
@RequestMapping(value = "/profile", method = RequestMethod.GET) public String get(Authentication authentication, Model model) { Map<String, List<DescribedApproval>> approvals = getCurrentApprovalsForUser(getCurrentUserId()); Map<String, String> clientNames = getClientNames(approvals); model.addAttribute("clientnames", clientNames); model.addAttribute("approvals", approvals); model.addAttribute("isUaaManagedUser", isUaaManagedUser(authentication)); return "approvals"; }
java
@RequestMapping(value = "/profile", method = RequestMethod.GET) public String get(Authentication authentication, Model model) { Map<String, List<DescribedApproval>> approvals = getCurrentApprovalsForUser(getCurrentUserId()); Map<String, String> clientNames = getClientNames(approvals); model.addAttribute("clientnames", clientNames); model.addAttribute("approvals", approvals); model.addAttribute("isUaaManagedUser", isUaaManagedUser(authentication)); return "approvals"; }
[ "@", "RequestMapping", "(", "value", "=", "\"/profile\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "String", "get", "(", "Authentication", "authentication", ",", "Model", "model", ")", "{", "Map", "<", "String", ",", "List", "<", "DescribedApproval", ">", ">", "approvals", "=", "getCurrentApprovalsForUser", "(", "getCurrentUserId", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "clientNames", "=", "getClientNames", "(", "approvals", ")", ";", "model", ".", "addAttribute", "(", "\"clientnames\"", ",", "clientNames", ")", ";", "model", ".", "addAttribute", "(", "\"approvals\"", ",", "approvals", ")", ";", "model", ".", "addAttribute", "(", "\"isUaaManagedUser\"", ",", "isUaaManagedUser", "(", "authentication", ")", ")", ";", "return", "\"approvals\"", ";", "}" ]
Display the current user's approvals
[ "Display", "the", "current", "user", "s", "approvals" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/account/ProfileController.java#L76-L84
21,251
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/account/ProfileController.java
ProfileController.post
@RequestMapping(value = "/profile", method = RequestMethod.POST) public String post(@RequestParam(required = false) Collection<String> checkedScopes, @RequestParam(required = false) String update, @RequestParam(required = false) String delete, @RequestParam(required = false) String clientId) { String userId = getCurrentUserId(); if (null != update) { Map<String, List<DescribedApproval>> approvalsByClientId = getCurrentApprovalsForUser(userId); List<DescribedApproval> allApprovals = new ArrayList<>(); for (List<DescribedApproval> clientApprovals : approvalsByClientId.values()) { allApprovals.addAll(clientApprovals); } if (hasText(clientId)) { allApprovals.removeIf(da -> !clientId.equals(da.getClientId())); } for (Approval approval : allApprovals) { String namespacedScope = approval.getClientId() + "-" + approval.getScope(); if (checkedScopes != null && checkedScopes.contains(namespacedScope)) { approval.setStatus(Approval.ApprovalStatus.APPROVED); } else { approval.setStatus(Approval.ApprovalStatus.DENIED); } } updateApprovals(allApprovals); } else if (null != delete) { deleteApprovalsForClient(userId, clientId); } return "redirect:profile"; }
java
@RequestMapping(value = "/profile", method = RequestMethod.POST) public String post(@RequestParam(required = false) Collection<String> checkedScopes, @RequestParam(required = false) String update, @RequestParam(required = false) String delete, @RequestParam(required = false) String clientId) { String userId = getCurrentUserId(); if (null != update) { Map<String, List<DescribedApproval>> approvalsByClientId = getCurrentApprovalsForUser(userId); List<DescribedApproval> allApprovals = new ArrayList<>(); for (List<DescribedApproval> clientApprovals : approvalsByClientId.values()) { allApprovals.addAll(clientApprovals); } if (hasText(clientId)) { allApprovals.removeIf(da -> !clientId.equals(da.getClientId())); } for (Approval approval : allApprovals) { String namespacedScope = approval.getClientId() + "-" + approval.getScope(); if (checkedScopes != null && checkedScopes.contains(namespacedScope)) { approval.setStatus(Approval.ApprovalStatus.APPROVED); } else { approval.setStatus(Approval.ApprovalStatus.DENIED); } } updateApprovals(allApprovals); } else if (null != delete) { deleteApprovalsForClient(userId, clientId); } return "redirect:profile"; }
[ "@", "RequestMapping", "(", "value", "=", "\"/profile\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "String", "post", "(", "@", "RequestParam", "(", "required", "=", "false", ")", "Collection", "<", "String", ">", "checkedScopes", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "String", "update", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "String", "delete", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "String", "clientId", ")", "{", "String", "userId", "=", "getCurrentUserId", "(", ")", ";", "if", "(", "null", "!=", "update", ")", "{", "Map", "<", "String", ",", "List", "<", "DescribedApproval", ">", ">", "approvalsByClientId", "=", "getCurrentApprovalsForUser", "(", "userId", ")", ";", "List", "<", "DescribedApproval", ">", "allApprovals", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "List", "<", "DescribedApproval", ">", "clientApprovals", ":", "approvalsByClientId", ".", "values", "(", ")", ")", "{", "allApprovals", ".", "addAll", "(", "clientApprovals", ")", ";", "}", "if", "(", "hasText", "(", "clientId", ")", ")", "{", "allApprovals", ".", "removeIf", "(", "da", "->", "!", "clientId", ".", "equals", "(", "da", ".", "getClientId", "(", ")", ")", ")", ";", "}", "for", "(", "Approval", "approval", ":", "allApprovals", ")", "{", "String", "namespacedScope", "=", "approval", ".", "getClientId", "(", ")", "+", "\"-\"", "+", "approval", ".", "getScope", "(", ")", ";", "if", "(", "checkedScopes", "!=", "null", "&&", "checkedScopes", ".", "contains", "(", "namespacedScope", ")", ")", "{", "approval", ".", "setStatus", "(", "Approval", ".", "ApprovalStatus", ".", "APPROVED", ")", ";", "}", "else", "{", "approval", ".", "setStatus", "(", "Approval", ".", "ApprovalStatus", ".", "DENIED", ")", ";", "}", "}", "updateApprovals", "(", "allApprovals", ")", ";", "}", "else", "if", "(", "null", "!=", "delete", ")", "{", "deleteApprovalsForClient", "(", "userId", ",", "clientId", ")", ";", "}", "return", "\"redirect:profile\"", ";", "}" ]
Handle form post for revoking chosen approvals
[ "Handle", "form", "post", "for", "revoking", "chosen", "approvals" ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/account/ProfileController.java#L102-L135
21,252
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaAuthorizationRequestManager.java
UaaAuthorizationRequestManager.validateParameters
public void validateParameters(Map<String, String> parameters, ClientDetails clientDetails) { if (parameters.containsKey("scope")) { Set<String> validScope = clientDetails.getScope(); if (GRANT_TYPE_CLIENT_CREDENTIALS.equals(parameters.get("grant_type"))) { validScope = AuthorityUtils.authorityListToSet(clientDetails.getAuthorities()); } Set<Pattern> validWildcards = constructWildcards(validScope); Set<String> scopes = OAuth2Utils.parseParameterList(parameters.get("scope")); for (String scope : scopes) { if (!matches(validWildcards, scope)) { throw new InvalidScopeException(scope + " is invalid. Please use a valid scope name in the request"); } } } }
java
public void validateParameters(Map<String, String> parameters, ClientDetails clientDetails) { if (parameters.containsKey("scope")) { Set<String> validScope = clientDetails.getScope(); if (GRANT_TYPE_CLIENT_CREDENTIALS.equals(parameters.get("grant_type"))) { validScope = AuthorityUtils.authorityListToSet(clientDetails.getAuthorities()); } Set<Pattern> validWildcards = constructWildcards(validScope); Set<String> scopes = OAuth2Utils.parseParameterList(parameters.get("scope")); for (String scope : scopes) { if (!matches(validWildcards, scope)) { throw new InvalidScopeException(scope + " is invalid. Please use a valid scope name in the request"); } } } }
[ "public", "void", "validateParameters", "(", "Map", "<", "String", ",", "String", ">", "parameters", ",", "ClientDetails", "clientDetails", ")", "{", "if", "(", "parameters", ".", "containsKey", "(", "\"scope\"", ")", ")", "{", "Set", "<", "String", ">", "validScope", "=", "clientDetails", ".", "getScope", "(", ")", ";", "if", "(", "GRANT_TYPE_CLIENT_CREDENTIALS", ".", "equals", "(", "parameters", ".", "get", "(", "\"grant_type\"", ")", ")", ")", "{", "validScope", "=", "AuthorityUtils", ".", "authorityListToSet", "(", "clientDetails", ".", "getAuthorities", "(", ")", ")", ";", "}", "Set", "<", "Pattern", ">", "validWildcards", "=", "constructWildcards", "(", "validScope", ")", ";", "Set", "<", "String", ">", "scopes", "=", "OAuth2Utils", ".", "parseParameterList", "(", "parameters", ".", "get", "(", "\"scope\"", ")", ")", ";", "for", "(", "String", "scope", ":", "scopes", ")", "{", "if", "(", "!", "matches", "(", "validWildcards", ",", "scope", ")", ")", "{", "throw", "new", "InvalidScopeException", "(", "scope", "+", "\" is invalid. Please use a valid scope name in the request\"", ")", ";", "}", "}", "}", "}" ]
Apply UAA rules to validate the requested scopes scope. For client credentials grants the valid requested scopes are actually in the authorities of the client.
[ "Apply", "UAA", "rules", "to", "validate", "the", "requested", "scopes", "scope", ".", "For", "client", "credentials", "grants", "the", "valid", "requested", "scopes", "are", "actually", "in", "the", "authorities", "of", "the", "client", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaAuthorizationRequestManager.java#L205-L219
21,253
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaTokenUtils.java
UaaTokenUtils.murmurhash3x8632
public static int murmurhash3x8632(byte[] data, int offset, int len, int seed) { int c1 = 0xcc9e2d51; int c2 = 0x1b873593; int h1 = seed; int roundedEnd = offset + (len & 0xfffffffc); // round down to 4 byte block for (int i = offset; i < roundedEnd; i += 4) { // little endian load order int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24); k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; } // tail int k1 = 0; switch(len & 0x03) { case 3: k1 = (data[roundedEnd + 2] & 0xff) << 16; // fallthrough case 2: k1 |= (data[roundedEnd + 1] & 0xff) << 8; // fallthrough case 1: k1 |= data[roundedEnd] & 0xff; k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; default: } // finalization h1 ^= len; // fmix(h1); h1 ^= h1 >>> 16; h1 *= 0x85ebca6b; h1 ^= h1 >>> 13; h1 *= 0xc2b2ae35; h1 ^= h1 >>> 16; return h1; }
java
public static int murmurhash3x8632(byte[] data, int offset, int len, int seed) { int c1 = 0xcc9e2d51; int c2 = 0x1b873593; int h1 = seed; int roundedEnd = offset + (len & 0xfffffffc); // round down to 4 byte block for (int i = offset; i < roundedEnd; i += 4) { // little endian load order int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24); k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1 * 5 + 0xe6546b64; } // tail int k1 = 0; switch(len & 0x03) { case 3: k1 = (data[roundedEnd + 2] & 0xff) << 16; // fallthrough case 2: k1 |= (data[roundedEnd + 1] & 0xff) << 8; // fallthrough case 1: k1 |= data[roundedEnd] & 0xff; k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; h1 ^= k1; default: } // finalization h1 ^= len; // fmix(h1); h1 ^= h1 >>> 16; h1 *= 0x85ebca6b; h1 ^= h1 >>> 13; h1 *= 0xc2b2ae35; h1 ^= h1 >>> 16; return h1; }
[ "public", "static", "int", "murmurhash3x8632", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "int", "len", ",", "int", "seed", ")", "{", "int", "c1", "=", "0xcc9e2d51", ";", "int", "c2", "=", "0x1b873593", ";", "int", "h1", "=", "seed", ";", "int", "roundedEnd", "=", "offset", "+", "(", "len", "&", "0xfffffffc", ")", ";", "// round down to 4 byte block", "for", "(", "int", "i", "=", "offset", ";", "i", "<", "roundedEnd", ";", "i", "+=", "4", ")", "{", "// little endian load order", "int", "k1", "=", "(", "data", "[", "i", "]", "&", "0xff", ")", "|", "(", "(", "data", "[", "i", "+", "1", "]", "&", "0xff", ")", "<<", "8", ")", "|", "(", "(", "data", "[", "i", "+", "2", "]", "&", "0xff", ")", "<<", "16", ")", "|", "(", "data", "[", "i", "+", "3", "]", "<<", "24", ")", ";", "k1", "*=", "c1", ";", "k1", "=", "(", "k1", "<<", "15", ")", "|", "(", "k1", ">>>", "17", ")", ";", "// ROTL32(k1,15);", "k1", "*=", "c2", ";", "h1", "^=", "k1", ";", "h1", "=", "(", "h1", "<<", "13", ")", "|", "(", "h1", ">>>", "19", ")", ";", "// ROTL32(h1,13);", "h1", "=", "h1", "*", "5", "+", "0xe6546b64", ";", "}", "// tail", "int", "k1", "=", "0", ";", "switch", "(", "len", "&", "0x03", ")", "{", "case", "3", ":", "k1", "=", "(", "data", "[", "roundedEnd", "+", "2", "]", "&", "0xff", ")", "<<", "16", ";", "// fallthrough", "case", "2", ":", "k1", "|=", "(", "data", "[", "roundedEnd", "+", "1", "]", "&", "0xff", ")", "<<", "8", ";", "// fallthrough", "case", "1", ":", "k1", "|=", "data", "[", "roundedEnd", "]", "&", "0xff", ";", "k1", "*=", "c1", ";", "k1", "=", "(", "k1", "<<", "15", ")", "|", "(", "k1", ">>>", "17", ")", ";", "// ROTL32(k1,15);", "k1", "*=", "c2", ";", "h1", "^=", "k1", ";", "default", ":", "}", "// finalization", "h1", "^=", "len", ";", "// fmix(h1);", "h1", "^=", "h1", ">>>", "16", ";", "h1", "*=", "0x85ebca6b", ";", "h1", "^=", "h1", ">>>", "13", ";", "h1", "*=", "0xc2b2ae35", ";", "h1", "^=", "h1", ">>>", "16", ";", "return", "h1", ";", "}" ]
This code is public domain. The MurmurHash3 algorithm was created by Austin Appleby and put into the public domain. @see <a href="http://code.google.com/p/smhasher">http://code.google.com/p/smhasher</a> @see <a href="https://github.com/yonik/java_util/blob/master/src/util/hash/MurmurHash3.java">https://github.com/yonik/java_util/blob/master/src/util/hash/MurmurHash3.java</a>
[ "This", "code", "is", "public", "domain", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaTokenUtils.java#L75-L125
21,254
cloudfoundry/uaa
model/src/main/java/org/cloudfoundry/identity/uaa/util/UaaStringUtils.java
UaaStringUtils.getMapFromProperties
public static Map<String, ?> getMapFromProperties(Properties properties, String prefix) { Map<String, Object> result = new HashMap<String, Object>(); for (String key : properties.stringPropertyNames()) { if (key.startsWith(prefix)) { String name = key.substring(prefix.length()); result.put(name, properties.getProperty(key)); } } return result; }
java
public static Map<String, ?> getMapFromProperties(Properties properties, String prefix) { Map<String, Object> result = new HashMap<String, Object>(); for (String key : properties.stringPropertyNames()) { if (key.startsWith(prefix)) { String name = key.substring(prefix.length()); result.put(name, properties.getProperty(key)); } } return result; }
[ "public", "static", "Map", "<", "String", ",", "?", ">", "getMapFromProperties", "(", "Properties", "properties", ",", "String", "prefix", ")", "{", "Map", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "for", "(", "String", "key", ":", "properties", ".", "stringPropertyNames", "(", ")", ")", "{", "if", "(", "key", ".", "startsWith", "(", "prefix", ")", ")", "{", "String", "name", "=", "key", ".", "substring", "(", "prefix", ".", "length", "(", ")", ")", ";", "result", ".", "put", "(", "name", ",", "properties", ".", "getProperty", "(", "key", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Extract a Map from some properties by removing a prefix from the key names. @param properties the properties to use @param prefix the prefix to strip from key names @return a map of String values
[ "Extract", "a", "Map", "from", "some", "properties", "by", "removing", "a", "prefix", "from", "the", "key", "names", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/model/src/main/java/org/cloudfoundry/identity/uaa/util/UaaStringUtils.java#L212-L221
21,255
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java
DefaultLdapAuthoritiesPopulator.getGrantedAuthorities
public Collection<GrantedAuthority> getGrantedAuthorities(DirContextOperations user, String username) { String userDn = user.getNameInNamespace(); if (logger.isDebugEnabled()) { logger.debug("Getting authorities for user " + userDn); } Set<GrantedAuthority> roles = getGroupMembershipRoles(userDn, username); Set<GrantedAuthority> extraRoles = getAdditionalRoles(user, username); if (extraRoles != null) { roles.addAll(extraRoles); } if (defaultRole != null) { roles.add(defaultRole); } List<GrantedAuthority> result = new ArrayList<GrantedAuthority>(roles.size()); result.addAll(roles); return result; }
java
public Collection<GrantedAuthority> getGrantedAuthorities(DirContextOperations user, String username) { String userDn = user.getNameInNamespace(); if (logger.isDebugEnabled()) { logger.debug("Getting authorities for user " + userDn); } Set<GrantedAuthority> roles = getGroupMembershipRoles(userDn, username); Set<GrantedAuthority> extraRoles = getAdditionalRoles(user, username); if (extraRoles != null) { roles.addAll(extraRoles); } if (defaultRole != null) { roles.add(defaultRole); } List<GrantedAuthority> result = new ArrayList<GrantedAuthority>(roles.size()); result.addAll(roles); return result; }
[ "public", "Collection", "<", "GrantedAuthority", ">", "getGrantedAuthorities", "(", "DirContextOperations", "user", ",", "String", "username", ")", "{", "String", "userDn", "=", "user", ".", "getNameInNamespace", "(", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Getting authorities for user \"", "+", "userDn", ")", ";", "}", "Set", "<", "GrantedAuthority", ">", "roles", "=", "getGroupMembershipRoles", "(", "userDn", ",", "username", ")", ";", "Set", "<", "GrantedAuthority", ">", "extraRoles", "=", "getAdditionalRoles", "(", "user", ",", "username", ")", ";", "if", "(", "extraRoles", "!=", "null", ")", "{", "roles", ".", "addAll", "(", "extraRoles", ")", ";", "}", "if", "(", "defaultRole", "!=", "null", ")", "{", "roles", ".", "add", "(", "defaultRole", ")", ";", "}", "List", "<", "GrantedAuthority", ">", "result", "=", "new", "ArrayList", "<", "GrantedAuthority", ">", "(", "roles", ".", "size", "(", ")", ")", ";", "result", ".", "addAll", "(", "roles", ")", ";", "return", "result", ";", "}" ]
Obtains the authorities for the user who's directory entry is represented by the supplied LdapUserDetails object. @param user the user who's authorities are required @return the set of roles granted to the user.
[ "Obtains", "the", "authorities", "for", "the", "user", "who", "s", "directory", "entry", "is", "represented", "by", "the", "supplied", "LdapUserDetails", "object", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java#L184-L207
21,256
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java
DefaultLdapAuthoritiesPopulator.setDefaultRole
@Deprecated public void setDefaultRole(String defaultRole) { Assert.notNull(defaultRole, "The defaultRole property cannot be set to null"); this.defaultRole = new SimpleGrantedAuthority(defaultRole); }
java
@Deprecated public void setDefaultRole(String defaultRole) { Assert.notNull(defaultRole, "The defaultRole property cannot be set to null"); this.defaultRole = new SimpleGrantedAuthority(defaultRole); }
[ "@", "Deprecated", "public", "void", "setDefaultRole", "(", "String", "defaultRole", ")", "{", "Assert", ".", "notNull", "(", "defaultRole", ",", "\"The defaultRole property cannot be set to null\"", ")", ";", "this", ".", "defaultRole", "=", "new", "SimpleGrantedAuthority", "(", "defaultRole", ")", ";", "}" ]
The default role which will be assigned to all users. @param defaultRole the role name, including any desired prefix. @deprecated Assign a default role in the {@code AuthenticationProvider} using a {@code GrantedAuthoritiesMapper}.
[ "The", "default", "role", "which", "will", "be", "assigned", "to", "all", "users", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java#L262-L266
21,257
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java
DefaultLdapAuthoritiesPopulator.setSearchSubtree
public void setSearchSubtree(boolean searchSubtree) { int searchScope = searchSubtree ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE; searchControls.setSearchScope(searchScope); }
java
public void setSearchSubtree(boolean searchSubtree) { int searchScope = searchSubtree ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE; searchControls.setSearchScope(searchScope); }
[ "public", "void", "setSearchSubtree", "(", "boolean", "searchSubtree", ")", "{", "int", "searchScope", "=", "searchSubtree", "?", "SearchControls", ".", "SUBTREE_SCOPE", ":", "SearchControls", ".", "ONELEVEL_SCOPE", ";", "searchControls", ".", "setSearchScope", "(", "searchScope", ")", ";", "}" ]
If set to true, a subtree scope search will be performed. If false a single-level search is used. @param searchSubtree set to true to enable searching of the entire tree below the <tt>groupSearchBase</tt>.
[ "If", "set", "to", "true", "a", "subtree", "scope", "search", "will", "be", "performed", ".", "If", "false", "a", "single", "-", "level", "search", "is", "used", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/DefaultLdapAuthoritiesPopulator.java#L295-L298
21,258
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/scim/endpoints/UserIdConversionEndpoints.java
UserIdConversionEndpoints.checkFilter
private boolean checkFilter(SCIMFilter filter) { switch (filter.getFilterType()) { case AND: case OR: return checkFilter(filter.getFilterComponents().get(0)) | checkFilter(filter.getFilterComponents().get(1)); case EQUALITY: String name = filter.getFilterAttribute().getAttributeName(); if ("id".equalsIgnoreCase(name) || "userName".equalsIgnoreCase(name)) { return true; } else if (OriginKeys.ORIGIN.equalsIgnoreCase(name)) { return false; } else { throw new ScimException("Invalid filter attribute.", HttpStatus.BAD_REQUEST); } case PRESENCE: case STARTS_WITH: case CONTAINS: throw new ScimException("Wildcards are not allowed in filter.", HttpStatus.BAD_REQUEST); case GREATER_THAN: case GREATER_OR_EQUAL: case LESS_THAN: case LESS_OR_EQUAL: throw new ScimException("Invalid operator.", HttpStatus.BAD_REQUEST); } return false; }
java
private boolean checkFilter(SCIMFilter filter) { switch (filter.getFilterType()) { case AND: case OR: return checkFilter(filter.getFilterComponents().get(0)) | checkFilter(filter.getFilterComponents().get(1)); case EQUALITY: String name = filter.getFilterAttribute().getAttributeName(); if ("id".equalsIgnoreCase(name) || "userName".equalsIgnoreCase(name)) { return true; } else if (OriginKeys.ORIGIN.equalsIgnoreCase(name)) { return false; } else { throw new ScimException("Invalid filter attribute.", HttpStatus.BAD_REQUEST); } case PRESENCE: case STARTS_WITH: case CONTAINS: throw new ScimException("Wildcards are not allowed in filter.", HttpStatus.BAD_REQUEST); case GREATER_THAN: case GREATER_OR_EQUAL: case LESS_THAN: case LESS_OR_EQUAL: throw new ScimException("Invalid operator.", HttpStatus.BAD_REQUEST); } return false; }
[ "private", "boolean", "checkFilter", "(", "SCIMFilter", "filter", ")", "{", "switch", "(", "filter", ".", "getFilterType", "(", ")", ")", "{", "case", "AND", ":", "case", "OR", ":", "return", "checkFilter", "(", "filter", ".", "getFilterComponents", "(", ")", ".", "get", "(", "0", ")", ")", "|", "checkFilter", "(", "filter", ".", "getFilterComponents", "(", ")", ".", "get", "(", "1", ")", ")", ";", "case", "EQUALITY", ":", "String", "name", "=", "filter", ".", "getFilterAttribute", "(", ")", ".", "getAttributeName", "(", ")", ";", "if", "(", "\"id\"", ".", "equalsIgnoreCase", "(", "name", ")", "||", "\"userName\"", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "OriginKeys", ".", "ORIGIN", ".", "equalsIgnoreCase", "(", "name", ")", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "new", "ScimException", "(", "\"Invalid filter attribute.\"", ",", "HttpStatus", ".", "BAD_REQUEST", ")", ";", "}", "case", "PRESENCE", ":", "case", "STARTS_WITH", ":", "case", "CONTAINS", ":", "throw", "new", "ScimException", "(", "\"Wildcards are not allowed in filter.\"", ",", "HttpStatus", ".", "BAD_REQUEST", ")", ";", "case", "GREATER_THAN", ":", "case", "GREATER_OR_EQUAL", ":", "case", "LESS_THAN", ":", "case", "LESS_OR_EQUAL", ":", "throw", "new", "ScimException", "(", "\"Invalid operator.\"", ",", "HttpStatus", ".", "BAD_REQUEST", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if the field 'id' or 'userName' are present in the query. @param filter @return
[ "Returns", "true", "if", "the", "field", "id", "or", "userName", "are", "present", "in", "the", "query", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/scim/endpoints/UserIdConversionEndpoints.java#L151-L177
21,259
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaAuthorizationEndpoint.java
UaaAuthorizationEndpoint.getUserApprovalPageResponse
private ModelAndView getUserApprovalPageResponse(Map<String, Object> model, AuthorizationRequest authorizationRequest, Authentication principal) { logger.debug("Loading user approval page: " + userApprovalPage); model.putAll(userApprovalHandler.getUserApprovalRequest(authorizationRequest, principal)); return new ModelAndView(userApprovalPage, model); }
java
private ModelAndView getUserApprovalPageResponse(Map<String, Object> model, AuthorizationRequest authorizationRequest, Authentication principal) { logger.debug("Loading user approval page: " + userApprovalPage); model.putAll(userApprovalHandler.getUserApprovalRequest(authorizationRequest, principal)); return new ModelAndView(userApprovalPage, model); }
[ "private", "ModelAndView", "getUserApprovalPageResponse", "(", "Map", "<", "String", ",", "Object", ">", "model", ",", "AuthorizationRequest", "authorizationRequest", ",", "Authentication", "principal", ")", "{", "logger", ".", "debug", "(", "\"Loading user approval page: \"", "+", "userApprovalPage", ")", ";", "model", ".", "putAll", "(", "userApprovalHandler", ".", "getUserApprovalRequest", "(", "authorizationRequest", ",", "principal", ")", ")", ";", "return", "new", "ModelAndView", "(", "userApprovalPage", ",", "model", ")", ";", "}" ]
We need explicit approval from the user.
[ "We", "need", "explicit", "approval", "from", "the", "user", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaAuthorizationEndpoint.java#L473-L478
21,260
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/audit/event/AbstractUaaEvent.java
AbstractUaaEvent.getOrigin
protected String getOrigin(Principal principal) { if (principal instanceof Authentication) { Authentication caller = (Authentication) principal; StringBuilder builder = new StringBuilder(); if (caller instanceof OAuth2Authentication) { OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) caller; builder.append("client=").append(oAuth2Authentication.getOAuth2Request().getClientId()); if (!oAuth2Authentication.isClientOnly()) { builder.append(", ").append("user=").append(oAuth2Authentication.getName()); } } else { builder.append("caller=").append(caller.getName()); } if (caller.getDetails() != null) { builder.append(", details=("); try { @SuppressWarnings("unchecked") Map<String, Object> map = JsonUtils.readValue((String)caller.getDetails(), new TypeReference<Map<String,Object>>(){}); if (map.containsKey("remoteAddress")) { builder.append("remoteAddress=").append(map.get("remoteAddress")).append(", "); } builder.append("type=").append(caller.getDetails().getClass().getSimpleName()); } catch (Exception e) { // ignore builder.append(caller.getDetails()); } appendTokenDetails(caller, builder); builder.append(")"); } return builder.toString(); } return principal == null ? null : principal.getName(); }
java
protected String getOrigin(Principal principal) { if (principal instanceof Authentication) { Authentication caller = (Authentication) principal; StringBuilder builder = new StringBuilder(); if (caller instanceof OAuth2Authentication) { OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) caller; builder.append("client=").append(oAuth2Authentication.getOAuth2Request().getClientId()); if (!oAuth2Authentication.isClientOnly()) { builder.append(", ").append("user=").append(oAuth2Authentication.getName()); } } else { builder.append("caller=").append(caller.getName()); } if (caller.getDetails() != null) { builder.append(", details=("); try { @SuppressWarnings("unchecked") Map<String, Object> map = JsonUtils.readValue((String)caller.getDetails(), new TypeReference<Map<String,Object>>(){}); if (map.containsKey("remoteAddress")) { builder.append("remoteAddress=").append(map.get("remoteAddress")).append(", "); } builder.append("type=").append(caller.getDetails().getClass().getSimpleName()); } catch (Exception e) { // ignore builder.append(caller.getDetails()); } appendTokenDetails(caller, builder); builder.append(")"); } return builder.toString(); } return principal == null ? null : principal.getName(); }
[ "protected", "String", "getOrigin", "(", "Principal", "principal", ")", "{", "if", "(", "principal", "instanceof", "Authentication", ")", "{", "Authentication", "caller", "=", "(", "Authentication", ")", "principal", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "caller", "instanceof", "OAuth2Authentication", ")", "{", "OAuth2Authentication", "oAuth2Authentication", "=", "(", "OAuth2Authentication", ")", "caller", ";", "builder", ".", "append", "(", "\"client=\"", ")", ".", "append", "(", "oAuth2Authentication", ".", "getOAuth2Request", "(", ")", ".", "getClientId", "(", ")", ")", ";", "if", "(", "!", "oAuth2Authentication", ".", "isClientOnly", "(", ")", ")", "{", "builder", ".", "append", "(", "\", \"", ")", ".", "append", "(", "\"user=\"", ")", ".", "append", "(", "oAuth2Authentication", ".", "getName", "(", ")", ")", ";", "}", "}", "else", "{", "builder", ".", "append", "(", "\"caller=\"", ")", ".", "append", "(", "caller", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "caller", ".", "getDetails", "(", ")", "!=", "null", ")", "{", "builder", ".", "append", "(", "\", details=(\"", ")", ";", "try", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "Object", ">", "map", "=", "JsonUtils", ".", "readValue", "(", "(", "String", ")", "caller", ".", "getDetails", "(", ")", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "Object", ">", ">", "(", ")", "{", "}", ")", ";", "if", "(", "map", ".", "containsKey", "(", "\"remoteAddress\"", ")", ")", "{", "builder", ".", "append", "(", "\"remoteAddress=\"", ")", ".", "append", "(", "map", ".", "get", "(", "\"remoteAddress\"", ")", ")", ".", "append", "(", "\", \"", ")", ";", "}", "builder", ".", "append", "(", "\"type=\"", ")", ".", "append", "(", "caller", ".", "getDetails", "(", ")", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// ignore", "builder", ".", "append", "(", "caller", ".", "getDetails", "(", ")", ")", ";", "}", "appendTokenDetails", "(", "caller", ",", "builder", ")", ";", "builder", ".", "append", "(", "\")\"", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "return", "principal", "==", "null", "?", "null", ":", "principal", ".", "getName", "(", ")", ";", "}" ]
due to some OAuth authentication scenarios which don't set it.
[ "due", "to", "some", "OAuth", "authentication", "scenarios", "which", "don", "t", "set", "it", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/audit/event/AbstractUaaEvent.java#L91-L132
21,261
cloudfoundry/uaa
server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/SpringSecurityLdapTemplate.java
SpringSecurityLdapTemplate.searchForMultipleAttributeValues
public Set<Map<String, String[]>> searchForMultipleAttributeValues(final String base, final String filter, final Object[] params, final String[] attributeNames) { // Escape the params acording to RFC2254 Object[] encodedParams = new String[params.length]; for (int i=0; i < params.length; i++) { encodedParams[i] = LdapEncoder.filterEncode(params[i].toString()); } String formattedFilter = MessageFormat.format(filter, encodedParams); logger.debug("Using filter: " + formattedFilter); final HashSet<Map<String, String[]>> set = new HashSet<Map<String, String[]>>(); ContextMapper roleMapper = new ContextMapper() { public Object mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; Map<String, String[]> record = new HashMap<String, String[]>(); for (String attributeName : attributeNames) { String[] values = adapter.getStringAttributes(attributeName); if (values == null || values.length == 0) { logger.debug("No attribute value found for '" + attributeName + "'"); } else { record.put(attributeName, values); } } record.put(DN_KEY, new String[] {adapter.getDn().toString()}); set.add(record); return null; } }; SearchControls ctls = new SearchControls(); ctls.setSearchScope(searchControls.getSearchScope()); ctls.setReturningAttributes(attributeNames); search(base, formattedFilter, ctls, roleMapper); return set; }
java
public Set<Map<String, String[]>> searchForMultipleAttributeValues(final String base, final String filter, final Object[] params, final String[] attributeNames) { // Escape the params acording to RFC2254 Object[] encodedParams = new String[params.length]; for (int i=0; i < params.length; i++) { encodedParams[i] = LdapEncoder.filterEncode(params[i].toString()); } String formattedFilter = MessageFormat.format(filter, encodedParams); logger.debug("Using filter: " + formattedFilter); final HashSet<Map<String, String[]>> set = new HashSet<Map<String, String[]>>(); ContextMapper roleMapper = new ContextMapper() { public Object mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; Map<String, String[]> record = new HashMap<String, String[]>(); for (String attributeName : attributeNames) { String[] values = adapter.getStringAttributes(attributeName); if (values == null || values.length == 0) { logger.debug("No attribute value found for '" + attributeName + "'"); } else { record.put(attributeName, values); } } record.put(DN_KEY, new String[] {adapter.getDn().toString()}); set.add(record); return null; } }; SearchControls ctls = new SearchControls(); ctls.setSearchScope(searchControls.getSearchScope()); ctls.setReturningAttributes(attributeNames); search(base, formattedFilter, ctls, roleMapper); return set; }
[ "public", "Set", "<", "Map", "<", "String", ",", "String", "[", "]", ">", ">", "searchForMultipleAttributeValues", "(", "final", "String", "base", ",", "final", "String", "filter", ",", "final", "Object", "[", "]", "params", ",", "final", "String", "[", "]", "attributeNames", ")", "{", "// Escape the params acording to RFC2254", "Object", "[", "]", "encodedParams", "=", "new", "String", "[", "params", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "encodedParams", "[", "i", "]", "=", "LdapEncoder", ".", "filterEncode", "(", "params", "[", "i", "]", ".", "toString", "(", ")", ")", ";", "}", "String", "formattedFilter", "=", "MessageFormat", ".", "format", "(", "filter", ",", "encodedParams", ")", ";", "logger", ".", "debug", "(", "\"Using filter: \"", "+", "formattedFilter", ")", ";", "final", "HashSet", "<", "Map", "<", "String", ",", "String", "[", "]", ">", ">", "set", "=", "new", "HashSet", "<", "Map", "<", "String", ",", "String", "[", "]", ">", ">", "(", ")", ";", "ContextMapper", "roleMapper", "=", "new", "ContextMapper", "(", ")", "{", "public", "Object", "mapFromContext", "(", "Object", "ctx", ")", "{", "DirContextAdapter", "adapter", "=", "(", "DirContextAdapter", ")", "ctx", ";", "Map", "<", "String", ",", "String", "[", "]", ">", "record", "=", "new", "HashMap", "<", "String", ",", "String", "[", "]", ">", "(", ")", ";", "for", "(", "String", "attributeName", ":", "attributeNames", ")", "{", "String", "[", "]", "values", "=", "adapter", ".", "getStringAttributes", "(", "attributeName", ")", ";", "if", "(", "values", "==", "null", "||", "values", ".", "length", "==", "0", ")", "{", "logger", ".", "debug", "(", "\"No attribute value found for '\"", "+", "attributeName", "+", "\"'\"", ")", ";", "}", "else", "{", "record", ".", "put", "(", "attributeName", ",", "values", ")", ";", "}", "}", "record", ".", "put", "(", "DN_KEY", ",", "new", "String", "[", "]", "{", "adapter", ".", "getDn", "(", ")", ".", "toString", "(", ")", "}", ")", ";", "set", ".", "add", "(", "record", ")", ";", "return", "null", ";", "}", "}", ";", "SearchControls", "ctls", "=", "new", "SearchControls", "(", ")", ";", "ctls", ".", "setSearchScope", "(", "searchControls", ".", "getSearchScope", "(", ")", ")", ";", "ctls", ".", "setReturningAttributes", "(", "attributeNames", ")", ";", "search", "(", "base", ",", "formattedFilter", ",", "ctls", ",", "roleMapper", ")", ";", "return", "set", ";", "}" ]
Performs a search using the supplied filter and returns the values of each named attribute found in all entries matched by the search. Note that one directory entry may have several values for the attribute. Intended for role searches and similar scenarios. @param base the DN to search in @param filter search filter to use @param params the parameters to substitute in the search filter @param attributeNames the attributes' values that are to be retrieved. @return the set of String values for each attribute found in all the matching entries. The attribute name is the key for each set of values. In addition each map contains the DN as a String with the key predefined key {@link #DN_KEY}.
[ "Performs", "a", "search", "using", "the", "supplied", "filter", "and", "returns", "the", "values", "of", "each", "named", "attribute", "found", "in", "all", "entries", "matched", "by", "the", "search", ".", "Note", "that", "one", "directory", "entry", "may", "have", "several", "values", "for", "the", "attribute", ".", "Intended", "for", "role", "searches", "and", "similar", "scenarios", "." ]
e8df3d7060580c92d33461106399f9e4f36e3cd2
https://github.com/cloudfoundry/uaa/blob/e8df3d7060580c92d33461106399f9e4f36e3cd2/server/src/main/java/org/cloudfoundry/identity/uaa/provider/ldap/extension/SpringSecurityLdapTemplate.java#L148-L187
21,262
mozilla/rhino
src/org/mozilla/javascript/ast/FunctionNode.java
FunctionNode.setParams
public void setParams(List<AstNode> params) { if (params == null) { this.params = null; } else { if (this.params != null) this.params.clear(); for (AstNode param : params) addParam(param); } }
java
public void setParams(List<AstNode> params) { if (params == null) { this.params = null; } else { if (this.params != null) this.params.clear(); for (AstNode param : params) addParam(param); } }
[ "public", "void", "setParams", "(", "List", "<", "AstNode", ">", "params", ")", "{", "if", "(", "params", "==", "null", ")", "{", "this", ".", "params", "=", "null", ";", "}", "else", "{", "if", "(", "this", ".", "params", "!=", "null", ")", "this", ".", "params", ".", "clear", "(", ")", ";", "for", "(", "AstNode", "param", ":", "params", ")", "addParam", "(", "param", ")", ";", "}", "}" ]
Sets the function parameter list, and sets the parent for each element of the list. @param params the function parameter list, or {@code null} if no params
[ "Sets", "the", "function", "parameter", "list", "and", "sets", "the", "parent", "for", "each", "element", "of", "the", "list", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/FunctionNode.java#L145-L154
21,263
mozilla/rhino
src/org/mozilla/javascript/ast/FunctionNode.java
FunctionNode.addParam
public void addParam(AstNode param) { assertNotNull(param); if (params == null) { params = new ArrayList<AstNode>(); } params.add(param); param.setParent(this); }
java
public void addParam(AstNode param) { assertNotNull(param); if (params == null) { params = new ArrayList<AstNode>(); } params.add(param); param.setParent(this); }
[ "public", "void", "addParam", "(", "AstNode", "param", ")", "{", "assertNotNull", "(", "param", ")", ";", "if", "(", "params", "==", "null", ")", "{", "params", "=", "new", "ArrayList", "<", "AstNode", ">", "(", ")", ";", "}", "params", ".", "add", "(", "param", ")", ";", "param", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a parameter to the function parameter list. Sets the parent of the param node to this node. @param param the parameter @throws IllegalArgumentException if param is {@code null}
[ "Adds", "a", "parameter", "to", "the", "function", "parameter", "list", ".", "Sets", "the", "parent", "of", "the", "param", "node", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/FunctionNode.java#L162-L169
21,264
mozilla/rhino
src/org/mozilla/javascript/ast/FunctionNode.java
FunctionNode.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { if (functionName != null) { functionName.visit(v); } for (AstNode param : getParams()) { param.visit(v); } getBody().visit(v); if (!isExpressionClosure) { if (memberExprNode != null) { memberExprNode.visit(v); } } } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { if (functionName != null) { functionName.visit(v); } for (AstNode param : getParams()) { param.visit(v); } getBody().visit(v); if (!isExpressionClosure) { if (memberExprNode != null) { memberExprNode.visit(v); } } } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "if", "(", "functionName", "!=", "null", ")", "{", "functionName", ".", "visit", "(", "v", ")", ";", "}", "for", "(", "AstNode", "param", ":", "getParams", "(", ")", ")", "{", "param", ".", "visit", "(", "v", ")", ";", "}", "getBody", "(", ")", ".", "visit", "(", "v", ")", ";", "if", "(", "!", "isExpressionClosure", ")", "{", "if", "(", "memberExprNode", "!=", "null", ")", "{", "memberExprNode", ".", "visit", "(", "v", ")", ";", "}", "}", "}", "}" ]
Visits this node, the function name node if supplied, the parameters, and the body. If there is a member-expr node, it is visited last.
[ "Visits", "this", "node", "the", "function", "name", "node", "if", "supplied", "the", "parameters", "and", "the", "body", ".", "If", "there", "is", "a", "member", "-", "expr", "node", "it", "is", "visited", "last", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/FunctionNode.java#L433-L449
21,265
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.getCurrentContext
public static Context getCurrentContext() { Object helper = VMBridge.instance.getThreadContextHelper(); return VMBridge.instance.getContext(helper); }
java
public static Context getCurrentContext() { Object helper = VMBridge.instance.getThreadContextHelper(); return VMBridge.instance.getContext(helper); }
[ "public", "static", "Context", "getCurrentContext", "(", ")", "{", "Object", "helper", "=", "VMBridge", ".", "instance", ".", "getThreadContextHelper", "(", ")", ";", "return", "VMBridge", ".", "instance", ".", "getContext", "(", "helper", ")", ";", "}" ]
Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread. <p> @return the Context associated with the current thread, or null if no context is associated with the current thread. @see ContextFactory#enterContext() @see ContextFactory#call(ContextAction)
[ "Get", "the", "current", "Context", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L409-L413
21,266
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.exit
public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
java
public static void exit() { Object helper = VMBridge.instance.getThreadContextHelper(); Context cx = VMBridge.instance.getContext(helper); if (cx == null) { throw new IllegalStateException( "Calling Context.exit without previous Context.enter"); } if (cx.enterCount < 1) Kit.codeBug(); if (--cx.enterCount == 0) { VMBridge.instance.setContext(helper, null); cx.factory.onContextReleased(cx); } }
[ "public", "static", "void", "exit", "(", ")", "{", "Object", "helper", "=", "VMBridge", ".", "instance", ".", "getThreadContextHelper", "(", ")", ";", "Context", "cx", "=", "VMBridge", ".", "instance", ".", "getContext", "(", "helper", ")", ";", "if", "(", "cx", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Calling Context.exit without previous Context.enter\"", ")", ";", "}", "if", "(", "cx", ".", "enterCount", "<", "1", ")", "Kit", ".", "codeBug", "(", ")", ";", "if", "(", "--", "cx", ".", "enterCount", "==", "0", ")", "{", "VMBridge", ".", "instance", ".", "setContext", "(", "helper", ",", "null", ")", ";", "cx", ".", "factory", ".", "onContextReleased", "(", "cx", ")", ";", "}", "}" ]
Exit a block of code requiring a Context. Calling <code>exit()</code> will remove the association between the current thread and a Context if the prior call to {@link ContextFactory#enterContext()} on this thread newly associated a Context with this thread. Once the current thread no longer has an associated Context, it cannot be used to execute JavaScript until it is again associated with a Context. @see ContextFactory#enterContext()
[ "Exit", "a", "block", "of", "code", "requiring", "a", "Context", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L487-L500
21,267
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.setLanguageVersion
public void setLanguageVersion(int version) { if (sealed) onSealedMutation(); checkLanguageVersion(version); Object listeners = propertyListeners; if (listeners != null && version != this.version) { firePropertyChangeImpl(listeners, languageVersionProperty, Integer.valueOf(this.version), Integer.valueOf(version)); } this.version = version; }
java
public void setLanguageVersion(int version) { if (sealed) onSealedMutation(); checkLanguageVersion(version); Object listeners = propertyListeners; if (listeners != null && version != this.version) { firePropertyChangeImpl(listeners, languageVersionProperty, Integer.valueOf(this.version), Integer.valueOf(version)); } this.version = version; }
[ "public", "void", "setLanguageVersion", "(", "int", "version", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "checkLanguageVersion", "(", "version", ")", ";", "Object", "listeners", "=", "propertyListeners", ";", "if", "(", "listeners", "!=", "null", "&&", "version", "!=", "this", ".", "version", ")", "{", "firePropertyChangeImpl", "(", "listeners", ",", "languageVersionProperty", ",", "Integer", ".", "valueOf", "(", "this", ".", "version", ")", ",", "Integer", ".", "valueOf", "(", "version", ")", ")", ";", "}", "this", ".", "version", "=", "version", ";", "}" ]
Set the language version. <p> Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior. @param version the version as specified by VERSION_1_0, VERSION_1_1, etc.
[ "Set", "the", "language", "version", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L684-L695
21,268
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.getImplementationVersion
public final String getImplementationVersion() { if (implementationVersion == null) { Enumeration<URL> urls; try { urls = Context.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); } catch (IOException ioe) { return null; } // There will be many manifests in the world -- enumerate all of them until we find the right one. while (urls.hasMoreElements()) { URL metaUrl = urls.nextElement(); InputStream is = null; try { is = metaUrl.openStream(); Manifest mf = new Manifest(is); Attributes attrs = mf.getMainAttributes(); if ("Mozilla Rhino".equals(attrs.getValue("Implementation-Title"))) { implementationVersion = "Rhino " + attrs.getValue("Implementation-Version") + " " + attrs.getValue("Built-Date").replaceAll("-", " "); return implementationVersion; } } catch (IOException e) { // Ignore this unlikely event } finally { try { if (is != null) is.close(); } catch (IOException e) { // Ignore this even unlikelier event } } } } return implementationVersion; }
java
public final String getImplementationVersion() { if (implementationVersion == null) { Enumeration<URL> urls; try { urls = Context.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); } catch (IOException ioe) { return null; } // There will be many manifests in the world -- enumerate all of them until we find the right one. while (urls.hasMoreElements()) { URL metaUrl = urls.nextElement(); InputStream is = null; try { is = metaUrl.openStream(); Manifest mf = new Manifest(is); Attributes attrs = mf.getMainAttributes(); if ("Mozilla Rhino".equals(attrs.getValue("Implementation-Title"))) { implementationVersion = "Rhino " + attrs.getValue("Implementation-Version") + " " + attrs.getValue("Built-Date").replaceAll("-", " "); return implementationVersion; } } catch (IOException e) { // Ignore this unlikely event } finally { try { if (is != null) is.close(); } catch (IOException e) { // Ignore this even unlikelier event } } } } return implementationVersion; }
[ "public", "final", "String", "getImplementationVersion", "(", ")", "{", "if", "(", "implementationVersion", "==", "null", ")", "{", "Enumeration", "<", "URL", ">", "urls", ";", "try", "{", "urls", "=", "Context", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResources", "(", "\"META-INF/MANIFEST.MF\"", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "return", "null", ";", "}", "// There will be many manifests in the world -- enumerate all of them until we find the right one.", "while", "(", "urls", ".", "hasMoreElements", "(", ")", ")", "{", "URL", "metaUrl", "=", "urls", ".", "nextElement", "(", ")", ";", "InputStream", "is", "=", "null", ";", "try", "{", "is", "=", "metaUrl", ".", "openStream", "(", ")", ";", "Manifest", "mf", "=", "new", "Manifest", "(", "is", ")", ";", "Attributes", "attrs", "=", "mf", ".", "getMainAttributes", "(", ")", ";", "if", "(", "\"Mozilla Rhino\"", ".", "equals", "(", "attrs", ".", "getValue", "(", "\"Implementation-Title\"", ")", ")", ")", "{", "implementationVersion", "=", "\"Rhino \"", "+", "attrs", ".", "getValue", "(", "\"Implementation-Version\"", ")", "+", "\" \"", "+", "attrs", ".", "getValue", "(", "\"Built-Date\"", ")", ".", "replaceAll", "(", "\"-\"", ",", "\" \"", ")", ";", "return", "implementationVersion", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "// Ignore this unlikely event", "}", "finally", "{", "try", "{", "if", "(", "is", "!=", "null", ")", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// Ignore this even unlikelier event", "}", "}", "}", "}", "return", "implementationVersion", ";", "}" ]
Get the implementation version. <p> The implementation version is of the form <pre> "<i>name langVer</i> <code>release</code> <i>relNum date</i>" </pre> where <i>name</i> is the name of the product, <i>langVer</i> is the language version, <i>relNum</i> is the release number, and <i>date</i> is the release date for that specific release in the form "yyyy mm dd". @return a string that encodes the product, language version, release number, and date.
[ "Get", "the", "implementation", "version", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L740-L776
21,269
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.setErrorReporter
public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
java
public final ErrorReporter setErrorReporter(ErrorReporter reporter) { if (sealed) onSealedMutation(); if (reporter == null) throw new IllegalArgumentException(); ErrorReporter old = getErrorReporter(); if (reporter == old) { return old; } Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, errorReporterProperty, old, reporter); } this.errorReporter = reporter; return old; }
[ "public", "final", "ErrorReporter", "setErrorReporter", "(", "ErrorReporter", "reporter", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "if", "(", "reporter", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "ErrorReporter", "old", "=", "getErrorReporter", "(", ")", ";", "if", "(", "reporter", "==", "old", ")", "{", "return", "old", ";", "}", "Object", "listeners", "=", "propertyListeners", ";", "if", "(", "listeners", "!=", "null", ")", "{", "firePropertyChangeImpl", "(", "listeners", ",", "errorReporterProperty", ",", "old", ",", "reporter", ")", ";", "}", "this", ".", "errorReporter", "=", "reporter", ";", "return", "old", ";", "}" ]
Change the current error reporter. @return the previous error reporter @see org.mozilla.javascript.ErrorReporter
[ "Change", "the", "current", "error", "reporter", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L797-L812
21,270
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.setLocale
public final Locale setLocale(Locale loc) { if (sealed) onSealedMutation(); Locale result = locale; locale = loc; return result; }
java
public final Locale setLocale(Locale loc) { if (sealed) onSealedMutation(); Locale result = locale; locale = loc; return result; }
[ "public", "final", "Locale", "setLocale", "(", "Locale", "loc", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "Locale", "result", "=", "locale", ";", "locale", "=", "loc", ";", "return", "result", ";", "}" ]
Set the current locale. @see java.util.Locale
[ "Set", "the", "current", "locale", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L833-L839
21,271
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.addPropertyChangeListener
public final void addPropertyChangeListener(PropertyChangeListener l) { if (sealed) onSealedMutation(); propertyListeners = Kit.addListener(propertyListeners, l); }
java
public final void addPropertyChangeListener(PropertyChangeListener l) { if (sealed) onSealedMutation(); propertyListeners = Kit.addListener(propertyListeners, l); }
[ "public", "final", "void", "addPropertyChangeListener", "(", "PropertyChangeListener", "l", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "propertyListeners", "=", "Kit", ".", "addListener", "(", "propertyListeners", ",", "l", ")", ";", "}" ]
Register an object to receive notifications when a bound property has changed @see java.beans.PropertyChangeEvent @see #removePropertyChangeListener(java.beans.PropertyChangeListener) @param l the listener
[ "Register", "an", "object", "to", "receive", "notifications", "when", "a", "bound", "property", "has", "changed" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L848-L852
21,272
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.removePropertyChangeListener
public final void removePropertyChangeListener(PropertyChangeListener l) { if (sealed) onSealedMutation(); propertyListeners = Kit.removeListener(propertyListeners, l); }
java
public final void removePropertyChangeListener(PropertyChangeListener l) { if (sealed) onSealedMutation(); propertyListeners = Kit.removeListener(propertyListeners, l); }
[ "public", "final", "void", "removePropertyChangeListener", "(", "PropertyChangeListener", "l", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "propertyListeners", "=", "Kit", ".", "removeListener", "(", "propertyListeners", ",", "l", ")", ";", "}" ]
Remove an object from the list of objects registered to receive notification of changes to a bounded property @see java.beans.PropertyChangeEvent @see #addPropertyChangeListener(java.beans.PropertyChangeListener) @param l the listener
[ "Remove", "an", "object", "from", "the", "list", "of", "objects", "registered", "to", "receive", "notification", "of", "changes", "to", "a", "bounded", "property" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L861-L865
21,273
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.firePropertyChange
final void firePropertyChange(String property, Object oldValue, Object newValue) { Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, property, oldValue, newValue); } }
java
final void firePropertyChange(String property, Object oldValue, Object newValue) { Object listeners = propertyListeners; if (listeners != null) { firePropertyChangeImpl(listeners, property, oldValue, newValue); } }
[ "final", "void", "firePropertyChange", "(", "String", "property", ",", "Object", "oldValue", ",", "Object", "newValue", ")", "{", "Object", "listeners", "=", "propertyListeners", ";", "if", "(", "listeners", "!=", "null", ")", "{", "firePropertyChangeImpl", "(", "listeners", ",", "property", ",", "oldValue", ",", "newValue", ")", ";", "}", "}" ]
Notify any registered listeners that a bounded property has changed @see #addPropertyChangeListener(java.beans.PropertyChangeListener) @see #removePropertyChangeListener(java.beans.PropertyChangeListener) @see java.beans.PropertyChangeListener @see java.beans.PropertyChangeEvent @param property the bound property @param oldValue the old value @param newValue the new value
[ "Notify", "any", "registered", "listeners", "that", "a", "bounded", "property", "has", "changed" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L877-L884
21,274
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.evaluateString
public final Object evaluateString(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain) { Script script = compileString(source, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } return null; }
java
public final Object evaluateString(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain) { Script script = compileString(source, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } return null; }
[ "public", "final", "Object", "evaluateString", "(", "Scriptable", "scope", ",", "String", "source", ",", "String", "sourceName", ",", "int", "lineno", ",", "Object", "securityDomain", ")", "{", "Script", "script", "=", "compileString", "(", "source", ",", "sourceName", ",", "lineno", ",", "securityDomain", ")", ";", "if", "(", "script", "!=", "null", ")", "{", "return", "script", ".", "exec", "(", "this", ",", "scope", ")", ";", "}", "return", "null", ";", "}" ]
Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information. @param scope the scope to execute in @param source the JavaScript source @param sourceName a string describing the source, such as a filename @param lineno the starting line number @param securityDomain an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null. @return the result of evaluating the string @see org.mozilla.javascript.SecurityController
[ "Evaluate", "a", "JavaScript", "source", "string", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1261-L1271
21,275
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.evaluateReader
public final Object evaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { Script script = compileReader(scope, in, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } return null; }
java
public final Object evaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException { Script script = compileReader(scope, in, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } return null; }
[ "public", "final", "Object", "evaluateReader", "(", "Scriptable", "scope", ",", "Reader", "in", ",", "String", "sourceName", ",", "int", "lineno", ",", "Object", "securityDomain", ")", "throws", "IOException", "{", "Script", "script", "=", "compileReader", "(", "scope", ",", "in", ",", "sourceName", ",", "lineno", ",", "securityDomain", ")", ";", "if", "(", "script", "!=", "null", ")", "{", "return", "script", ".", "exec", "(", "this", ",", "scope", ")", ";", "}", "return", "null", ";", "}" ]
Evaluate a reader as JavaScript source. All characters of the reader are consumed. @param scope the scope to execute in @param in the Reader to get JavaScript source from @param sourceName a string describing the source, such as a filename @param lineno the starting line number @param securityDomain an arbitrary object that specifies security information about the origin or owner of the script. For implementations that don't care about security, this value may be null. @return the result of evaluating the source @exception IOException if an IOException was generated by the Reader
[ "Evaluate", "a", "reader", "as", "JavaScript", "source", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1290-L1301
21,276
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.newObject
public Scriptable newObject(Scriptable scope) { NativeObject result = new NativeObject(); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Object); return result; }
java
public Scriptable newObject(Scriptable scope) { NativeObject result = new NativeObject(); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Object); return result; }
[ "public", "Scriptable", "newObject", "(", "Scriptable", "scope", ")", "{", "NativeObject", "result", "=", "new", "NativeObject", "(", ")", ";", "ScriptRuntime", ".", "setBuiltinProtoAndParent", "(", "result", ",", "scope", ",", "TopLevel", ".", "Builtins", ".", "Object", ")", ";", "return", "result", ";", "}" ]
Create a new JavaScript object. Equivalent to evaluating "new Object()". @param scope the scope to search for the constructor and to evaluate against @return the new object
[ "Create", "a", "new", "JavaScript", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1638-L1644
21,277
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.newObject
public Scriptable newObject(Scriptable scope, String constructorName) { return newObject(scope, constructorName, ScriptRuntime.emptyArgs); }
java
public Scriptable newObject(Scriptable scope, String constructorName) { return newObject(scope, constructorName, ScriptRuntime.emptyArgs); }
[ "public", "Scriptable", "newObject", "(", "Scriptable", "scope", ",", "String", "constructorName", ")", "{", "return", "newObject", "(", "scope", ",", "constructorName", ",", "ScriptRuntime", ".", "emptyArgs", ")", ";", "}" ]
Create a new JavaScript object by executing the named constructor. The call <code>newObject(scope, "Foo")</code> is equivalent to evaluating "new Foo()". @param scope the scope to search for the constructor and to evaluate against @param constructorName the name of the constructor to call @return the new object
[ "Create", "a", "new", "JavaScript", "object", "by", "executing", "the", "named", "constructor", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1656-L1659
21,278
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.newObject
public Scriptable newObject(Scriptable scope, String constructorName, Object[] args) { return ScriptRuntime.newObject(this, scope, constructorName, args); }
java
public Scriptable newObject(Scriptable scope, String constructorName, Object[] args) { return ScriptRuntime.newObject(this, scope, constructorName, args); }
[ "public", "Scriptable", "newObject", "(", "Scriptable", "scope", ",", "String", "constructorName", ",", "Object", "[", "]", "args", ")", "{", "return", "ScriptRuntime", ".", "newObject", "(", "this", ",", "scope", ",", "constructorName", ",", "args", ")", ";", "}" ]
Creates a new JavaScript object by executing the named constructor. Searches <code>scope</code> for the named constructor, calls it with the given arguments, and returns the result.<p> The code <pre> Object[] args = { "a", "b" }; newObject(scope, "Foo", args)</pre> is equivalent to evaluating "new Foo('a', 'b')", assuming that the Foo constructor has been defined in <code>scope</code>. @param scope The scope to search for the constructor and to evaluate against @param constructorName the name of the constructor to call @param args the array of arguments for the constructor @return the new object
[ "Creates", "a", "new", "JavaScript", "object", "by", "executing", "the", "named", "constructor", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1680-L1684
21,279
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.newArray
public Scriptable newArray(Scriptable scope, Object[] elements) { if (elements.getClass().getComponentType() != ScriptRuntime.ObjectClass) throw new IllegalArgumentException(); NativeArray result = new NativeArray(elements); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Array); return result; }
java
public Scriptable newArray(Scriptable scope, Object[] elements) { if (elements.getClass().getComponentType() != ScriptRuntime.ObjectClass) throw new IllegalArgumentException(); NativeArray result = new NativeArray(elements); ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Array); return result; }
[ "public", "Scriptable", "newArray", "(", "Scriptable", "scope", ",", "Object", "[", "]", "elements", ")", "{", "if", "(", "elements", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", "!=", "ScriptRuntime", ".", "ObjectClass", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "NativeArray", "result", "=", "new", "NativeArray", "(", "elements", ")", ";", "ScriptRuntime", ".", "setBuiltinProtoAndParent", "(", "result", ",", "scope", ",", "TopLevel", ".", "Builtins", ".", "Array", ")", ";", "return", "result", ";", "}" ]
Create an array with a set of initial elements. @param scope the scope to create the object in. @param elements the initial elements. Each object in this array must be an acceptable JavaScript type and type of array should be exactly Object[], not SomeObjectSubclass[]. @return the new array object.
[ "Create", "an", "array", "with", "a", "set", "of", "initial", "elements", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1712-L1720
21,280
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.jsToJava
public static Object jsToJava(Object value, Class<?> desiredType) throws EvaluatorException { return NativeJavaObject.coerceTypeImpl(desiredType, value); }
java
public static Object jsToJava(Object value, Class<?> desiredType) throws EvaluatorException { return NativeJavaObject.coerceTypeImpl(desiredType, value); }
[ "public", "static", "Object", "jsToJava", "(", "Object", "value", ",", "Class", "<", "?", ">", "desiredType", ")", "throws", "EvaluatorException", "{", "return", "NativeJavaObject", ".", "coerceTypeImpl", "(", "desiredType", ",", "value", ")", ";", "}" ]
Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed. @param value the JavaScript value to convert @param desiredType the Java type to convert to. Primitive Java types are represented using the TYPE fields in the corresponding wrapper class in java.lang. @return the converted value @throws EvaluatorException if the conversion cannot be performed
[ "Convert", "a", "JavaScript", "value", "into", "the", "desired", "type", ".", "Uses", "the", "semantics", "defined", "with", "LiveConnect3", "and", "throws", "an", "Illegal", "argument", "exception", "if", "the", "conversion", "cannot", "be", "performed", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L1874-L1878
21,281
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.removeThreadLocal
public final void removeThreadLocal(Object key) { if (sealed) onSealedMutation(); if (threadLocalMap == null) return; threadLocalMap.remove(key); }
java
public final void removeThreadLocal(Object key) { if (sealed) onSealedMutation(); if (threadLocalMap == null) return; threadLocalMap.remove(key); }
[ "public", "final", "void", "removeThreadLocal", "(", "Object", "key", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "if", "(", "threadLocalMap", "==", "null", ")", "return", ";", "threadLocalMap", ".", "remove", "(", "key", ")", ";", "}" ]
Remove values from thread-local storage. @param key the key for the entry to remove. @since 1.5 release 2
[ "Remove", "values", "from", "thread", "-", "local", "storage", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2206-L2212
21,282
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.setDebugger
public final void setDebugger(Debugger debugger, Object contextData) { if (sealed) onSealedMutation(); this.debugger = debugger; debuggerData = contextData; }
java
public final void setDebugger(Debugger debugger, Object contextData) { if (sealed) onSealedMutation(); this.debugger = debugger; debuggerData = contextData; }
[ "public", "final", "void", "setDebugger", "(", "Debugger", "debugger", ",", "Object", "contextData", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "this", ".", "debugger", "=", "debugger", ";", "debuggerData", "=", "contextData", ";", "}" ]
Set the associated debugger. @param debugger the debugger to be used on callbacks from the engine. @param contextData arbitrary object that debugger can use to store per Context data.
[ "Set", "the", "associated", "debugger", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2277-L2282
21,283
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.getDebuggableView
public static DebuggableScript getDebuggableView(Script script) { if (script instanceof NativeFunction) { return ((NativeFunction)script).getDebuggableView(); } return null; }
java
public static DebuggableScript getDebuggableView(Script script) { if (script instanceof NativeFunction) { return ((NativeFunction)script).getDebuggableView(); } return null; }
[ "public", "static", "DebuggableScript", "getDebuggableView", "(", "Script", "script", ")", "{", "if", "(", "script", "instanceof", "NativeFunction", ")", "{", "return", "(", "(", "NativeFunction", ")", "script", ")", ".", "getDebuggableView", "(", ")", ";", "}", "return", "null", ";", "}" ]
Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it. Otherwise null is returned.
[ "Return", "DebuggableScript", "instance", "if", "any", "associated", "with", "the", "script", ".", "If", "callable", "supports", "DebuggableScript", "implementation", "the", "method", "returns", "it", ".", "Otherwise", "null", "is", "returned", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2289-L2295
21,284
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.getSecurityController
SecurityController getSecurityController() { SecurityController global = SecurityController.global(); if (global != null) { return global; } return securityController; }
java
SecurityController getSecurityController() { SecurityController global = SecurityController.global(); if (global != null) { return global; } return securityController; }
[ "SecurityController", "getSecurityController", "(", ")", "{", "SecurityController", "global", "=", "SecurityController", ".", "global", "(", ")", ";", "if", "(", "global", "!=", "null", ")", "{", "return", "global", ";", "}", "return", "securityController", ";", "}" ]
The method must NOT be public or protected
[ "The", "method", "must", "NOT", "be", "public", "or", "protected" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2682-L2689
21,285
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.addActivationName
public void addActivationName(String name) { if (sealed) onSealedMutation(); if (activationNames == null) activationNames = new HashSet<String>(); activationNames.add(name); }
java
public void addActivationName(String name) { if (sealed) onSealedMutation(); if (activationNames == null) activationNames = new HashSet<String>(); activationNames.add(name); }
[ "public", "void", "addActivationName", "(", "String", "name", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "if", "(", "activationNames", "==", "null", ")", "activationNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "activationNames", ".", "add", "(", "name", ")", ";", "}" ]
Add a name to the list of names forcing the creation of real activation objects for functions. @param name the name of the object to add to the list
[ "Add", "a", "name", "to", "the", "list", "of", "names", "forcing", "the", "creation", "of", "real", "activation", "objects", "for", "functions", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2702-L2708
21,286
mozilla/rhino
src/org/mozilla/javascript/Context.java
Context.removeActivationName
public void removeActivationName(String name) { if (sealed) onSealedMutation(); if (activationNames != null) activationNames.remove(name); }
java
public void removeActivationName(String name) { if (sealed) onSealedMutation(); if (activationNames != null) activationNames.remove(name); }
[ "public", "void", "removeActivationName", "(", "String", "name", ")", "{", "if", "(", "sealed", ")", "onSealedMutation", "(", ")", ";", "if", "(", "activationNames", "!=", "null", ")", "activationNames", ".", "remove", "(", "name", ")", ";", "}" ]
Remove a name from the list of names forcing the creation of real activation objects for functions. @param name the name of the object to remove from the list
[ "Remove", "a", "name", "from", "the", "list", "of", "names", "forcing", "the", "creation", "of", "real", "activation", "objects", "for", "functions", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Context.java#L2729-L2734
21,287
mozilla/rhino
src/org/mozilla/javascript/NativeJavaMethod.java
NativeJavaMethod.preferSignature
private static int preferSignature(Object[] args, Class<?>[] sig1, boolean vararg1, Class<?>[] sig2, boolean vararg2 ) { int totalPreference = 0; for (int j = 0; j < args.length; j++) { Class<?> type1 = vararg1 && j >= sig1.length ? sig1[sig1.length-1] : sig1[j]; Class<?> type2 = vararg2 && j >= sig2.length ? sig2[sig2.length-1] : sig2[j]; if (type1 == type2) { continue; } Object arg = args[j]; // Determine which of type1, type2 is easier to convert from arg. int rank1 = NativeJavaObject.getConversionWeight(arg, type1); int rank2 = NativeJavaObject.getConversionWeight(arg, type2); int preference; if (rank1 < rank2) { preference = PREFERENCE_FIRST_ARG; } else if (rank1 > rank2) { preference = PREFERENCE_SECOND_ARG; } else { // Equal ranks if (rank1 == NativeJavaObject.CONVERSION_NONTRIVIAL) { if (type1.isAssignableFrom(type2)) { preference = PREFERENCE_SECOND_ARG; } else if (type2.isAssignableFrom(type1)) { preference = PREFERENCE_FIRST_ARG; } else { preference = PREFERENCE_AMBIGUOUS; } } else { preference = PREFERENCE_AMBIGUOUS; } } totalPreference |= preference; if (totalPreference == PREFERENCE_AMBIGUOUS) { break; } } return totalPreference; }
java
private static int preferSignature(Object[] args, Class<?>[] sig1, boolean vararg1, Class<?>[] sig2, boolean vararg2 ) { int totalPreference = 0; for (int j = 0; j < args.length; j++) { Class<?> type1 = vararg1 && j >= sig1.length ? sig1[sig1.length-1] : sig1[j]; Class<?> type2 = vararg2 && j >= sig2.length ? sig2[sig2.length-1] : sig2[j]; if (type1 == type2) { continue; } Object arg = args[j]; // Determine which of type1, type2 is easier to convert from arg. int rank1 = NativeJavaObject.getConversionWeight(arg, type1); int rank2 = NativeJavaObject.getConversionWeight(arg, type2); int preference; if (rank1 < rank2) { preference = PREFERENCE_FIRST_ARG; } else if (rank1 > rank2) { preference = PREFERENCE_SECOND_ARG; } else { // Equal ranks if (rank1 == NativeJavaObject.CONVERSION_NONTRIVIAL) { if (type1.isAssignableFrom(type2)) { preference = PREFERENCE_SECOND_ARG; } else if (type2.isAssignableFrom(type1)) { preference = PREFERENCE_FIRST_ARG; } else { preference = PREFERENCE_AMBIGUOUS; } } else { preference = PREFERENCE_AMBIGUOUS; } } totalPreference |= preference; if (totalPreference == PREFERENCE_AMBIGUOUS) { break; } } return totalPreference; }
[ "private", "static", "int", "preferSignature", "(", "Object", "[", "]", "args", ",", "Class", "<", "?", ">", "[", "]", "sig1", ",", "boolean", "vararg1", ",", "Class", "<", "?", ">", "[", "]", "sig2", ",", "boolean", "vararg2", ")", "{", "int", "totalPreference", "=", "0", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "args", ".", "length", ";", "j", "++", ")", "{", "Class", "<", "?", ">", "type1", "=", "vararg1", "&&", "j", ">=", "sig1", ".", "length", "?", "sig1", "[", "sig1", ".", "length", "-", "1", "]", ":", "sig1", "[", "j", "]", ";", "Class", "<", "?", ">", "type2", "=", "vararg2", "&&", "j", ">=", "sig2", ".", "length", "?", "sig2", "[", "sig2", ".", "length", "-", "1", "]", ":", "sig2", "[", "j", "]", ";", "if", "(", "type1", "==", "type2", ")", "{", "continue", ";", "}", "Object", "arg", "=", "args", "[", "j", "]", ";", "// Determine which of type1, type2 is easier to convert from arg.", "int", "rank1", "=", "NativeJavaObject", ".", "getConversionWeight", "(", "arg", ",", "type1", ")", ";", "int", "rank2", "=", "NativeJavaObject", ".", "getConversionWeight", "(", "arg", ",", "type2", ")", ";", "int", "preference", ";", "if", "(", "rank1", "<", "rank2", ")", "{", "preference", "=", "PREFERENCE_FIRST_ARG", ";", "}", "else", "if", "(", "rank1", ">", "rank2", ")", "{", "preference", "=", "PREFERENCE_SECOND_ARG", ";", "}", "else", "{", "// Equal ranks", "if", "(", "rank1", "==", "NativeJavaObject", ".", "CONVERSION_NONTRIVIAL", ")", "{", "if", "(", "type1", ".", "isAssignableFrom", "(", "type2", ")", ")", "{", "preference", "=", "PREFERENCE_SECOND_ARG", ";", "}", "else", "if", "(", "type2", ".", "isAssignableFrom", "(", "type1", ")", ")", "{", "preference", "=", "PREFERENCE_FIRST_ARG", ";", "}", "else", "{", "preference", "=", "PREFERENCE_AMBIGUOUS", ";", "}", "}", "else", "{", "preference", "=", "PREFERENCE_AMBIGUOUS", ";", "}", "}", "totalPreference", "|=", "preference", ";", "if", "(", "totalPreference", "==", "PREFERENCE_AMBIGUOUS", ")", "{", "break", ";", "}", "}", "return", "totalPreference", ";", "}" ]
Determine which of two signatures is the closer fit. Returns one of PREFERENCE_EQUAL, PREFERENCE_FIRST_ARG, PREFERENCE_SECOND_ARG, or PREFERENCE_AMBIGUOUS.
[ "Determine", "which", "of", "two", "signatures", "is", "the", "closer", "fit", ".", "Returns", "one", "of", "PREFERENCE_EQUAL", "PREFERENCE_FIRST_ARG", "PREFERENCE_SECOND_ARG", "or", "PREFERENCE_AMBIGUOUS", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeJavaMethod.java#L485-L532
21,288
mozilla/rhino
src/org/mozilla/javascript/SecureCaller.java
SecureCaller.callSecurely
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { @Override public Object run() { return thread.getContextClassLoader(); } }); Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized(callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized(classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } } return caller.call(callable, cx, scope, thisObj, args); }
java
static Object callSecurely(final CodeSource codeSource, Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { final Thread thread = Thread.currentThread(); // Run in doPrivileged as we might be checked for "getClassLoader" // runtime permission final ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction<Object>() { @Override public Object run() { return thread.getContextClassLoader(); } }); Map<ClassLoader,SoftReference<SecureCaller>> classLoaderMap; synchronized(callers) { classLoaderMap = callers.get(codeSource); if(classLoaderMap == null) { classLoaderMap = new WeakHashMap<ClassLoader,SoftReference<SecureCaller>>(); callers.put(codeSource, classLoaderMap); } } SecureCaller caller; synchronized(classLoaderMap) { SoftReference<SecureCaller> ref = classLoaderMap.get(classLoader); if (ref != null) { caller = ref.get(); } else { caller = null; } if (caller == null) { try { // Run in doPrivileged as we'll be checked for // "createClassLoader" runtime permission caller = (SecureCaller)AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { ClassLoader effectiveClassLoader; Class<?> thisClass = getClass(); if(classLoader.loadClass(thisClass.getName()) != thisClass) { effectiveClassLoader = thisClass.getClassLoader(); } else { effectiveClassLoader = classLoader; } SecureClassLoaderImpl secCl = new SecureClassLoaderImpl(effectiveClassLoader); Class<?> c = secCl.defineAndLinkClass( SecureCaller.class.getName() + "Impl", secureCallerImplBytecode, codeSource); return c.newInstance(); } }); classLoaderMap.put(classLoader, new SoftReference<SecureCaller>(caller)); } catch(PrivilegedActionException ex) { throw new UndeclaredThrowableException(ex.getCause()); } } } return caller.call(callable, cx, scope, thisObj, args); }
[ "static", "Object", "callSecurely", "(", "final", "CodeSource", "codeSource", ",", "Callable", "callable", ",", "Context", "cx", ",", "Scriptable", "scope", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "final", "Thread", "thread", "=", "Thread", ".", "currentThread", "(", ")", ";", "// Run in doPrivileged as we might be checked for \"getClassLoader\"", "// runtime permission", "final", "ClassLoader", "classLoader", "=", "(", "ClassLoader", ")", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "Object", "run", "(", ")", "{", "return", "thread", ".", "getContextClassLoader", "(", ")", ";", "}", "}", ")", ";", "Map", "<", "ClassLoader", ",", "SoftReference", "<", "SecureCaller", ">", ">", "classLoaderMap", ";", "synchronized", "(", "callers", ")", "{", "classLoaderMap", "=", "callers", ".", "get", "(", "codeSource", ")", ";", "if", "(", "classLoaderMap", "==", "null", ")", "{", "classLoaderMap", "=", "new", "WeakHashMap", "<", "ClassLoader", ",", "SoftReference", "<", "SecureCaller", ">", ">", "(", ")", ";", "callers", ".", "put", "(", "codeSource", ",", "classLoaderMap", ")", ";", "}", "}", "SecureCaller", "caller", ";", "synchronized", "(", "classLoaderMap", ")", "{", "SoftReference", "<", "SecureCaller", ">", "ref", "=", "classLoaderMap", ".", "get", "(", "classLoader", ")", ";", "if", "(", "ref", "!=", "null", ")", "{", "caller", "=", "ref", ".", "get", "(", ")", ";", "}", "else", "{", "caller", "=", "null", ";", "}", "if", "(", "caller", "==", "null", ")", "{", "try", "{", "// Run in doPrivileged as we'll be checked for", "// \"createClassLoader\" runtime permission", "caller", "=", "(", "SecureCaller", ")", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedExceptionAction", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "Object", "run", "(", ")", "throws", "Exception", "{", "ClassLoader", "effectiveClassLoader", ";", "Class", "<", "?", ">", "thisClass", "=", "getClass", "(", ")", ";", "if", "(", "classLoader", ".", "loadClass", "(", "thisClass", ".", "getName", "(", ")", ")", "!=", "thisClass", ")", "{", "effectiveClassLoader", "=", "thisClass", ".", "getClassLoader", "(", ")", ";", "}", "else", "{", "effectiveClassLoader", "=", "classLoader", ";", "}", "SecureClassLoaderImpl", "secCl", "=", "new", "SecureClassLoaderImpl", "(", "effectiveClassLoader", ")", ";", "Class", "<", "?", ">", "c", "=", "secCl", ".", "defineAndLinkClass", "(", "SecureCaller", ".", "class", ".", "getName", "(", ")", "+", "\"Impl\"", ",", "secureCallerImplBytecode", ",", "codeSource", ")", ";", "return", "c", ".", "newInstance", "(", ")", ";", "}", "}", ")", ";", "classLoaderMap", ".", "put", "(", "classLoader", ",", "new", "SoftReference", "<", "SecureCaller", ">", "(", "caller", ")", ")", ";", "}", "catch", "(", "PrivilegedActionException", "ex", ")", "{", "throw", "new", "UndeclaredThrowableException", "(", "ex", ".", "getCause", "(", ")", ")", ";", "}", "}", "}", "return", "caller", ".", "call", "(", "callable", ",", "cx", ",", "scope", ",", "thisObj", ",", "args", ")", ";", "}" ]
Call the specified callable using a protection domain belonging to the specified code source.
[ "Call", "the", "specified", "callable", "using", "a", "protection", "domain", "belonging", "to", "the", "specified", "code", "source", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/SecureCaller.java#L44-L111
21,289
mozilla/rhino
src/org/mozilla/javascript/ast/Yield.java
Yield.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this) && value != null) { value.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this) && value != null) { value.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", "&&", "value", "!=", "null", ")", "{", "value", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits this node, and if present, the yielded value.
[ "Visits", "this", "node", "and", "if", "present", "the", "yielded", "value", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Yield.java#L69-L74
21,290
mozilla/rhino
src/org/mozilla/javascript/ast/ForLoop.java
ForLoop.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { initializer.visit(v); condition.visit(v); increment.visit(v); body.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { initializer.visit(v); condition.visit(v); increment.visit(v); body.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "initializer", ".", "visit", "(", "v", ")", ";", "condition", ".", "visit", "(", "v", ")", ";", "increment", ".", "visit", "(", "v", ")", ";", "body", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits this node, the initializer expression, the loop condition expression, the increment expression, and then the loop body.
[ "Visits", "this", "node", "the", "initializer", "expression", "the", "loop", "condition", "expression", "the", "increment", "expression", "and", "then", "the", "loop", "body", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/ForLoop.java#L135-L143
21,291
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.setParentScope
public void setParentScope(Scope parentScope) { this.parentScope = parentScope; this.top = parentScope == null ? (ScriptNode)this : parentScope.top; }
java
public void setParentScope(Scope parentScope) { this.parentScope = parentScope; this.top = parentScope == null ? (ScriptNode)this : parentScope.top; }
[ "public", "void", "setParentScope", "(", "Scope", "parentScope", ")", "{", "this", ".", "parentScope", "=", "parentScope", ";", "this", ".", "top", "=", "parentScope", "==", "null", "?", "(", "ScriptNode", ")", "this", ":", "parentScope", ".", "top", ";", "}" ]
Sets parent scope
[ "Sets", "parent", "scope" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L54-L57
21,292
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.addChildScope
public void addChildScope(Scope child) { if (childScopes == null) { childScopes = new ArrayList<Scope>(); } childScopes.add(child); child.setParentScope(this); }
java
public void addChildScope(Scope child) { if (childScopes == null) { childScopes = new ArrayList<Scope>(); } childScopes.add(child); child.setParentScope(this); }
[ "public", "void", "addChildScope", "(", "Scope", "child", ")", "{", "if", "(", "childScopes", "==", "null", ")", "{", "childScopes", "=", "new", "ArrayList", "<", "Scope", ">", "(", ")", ";", "}", "childScopes", ".", "add", "(", "child", ")", ";", "child", ".", "setParentScope", "(", "this", ")", ";", "}" ]
Add a scope to our list of child scopes. Sets the child's parent scope to this scope. @throws IllegalStateException if the child's parent scope is non-{@code null}
[ "Add", "a", "scope", "to", "our", "list", "of", "child", "scopes", ".", "Sets", "the", "child", "s", "parent", "scope", "to", "this", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L80-L86
21,293
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.replaceWith
public void replaceWith(Scope newScope) { if (childScopes != null) { for (Scope kid : childScopes) { newScope.addChildScope(kid); // sets kid's parent } childScopes.clear(); childScopes = null; } if (symbolTable != null && !symbolTable.isEmpty()) { joinScopes(this, newScope); } }
java
public void replaceWith(Scope newScope) { if (childScopes != null) { for (Scope kid : childScopes) { newScope.addChildScope(kid); // sets kid's parent } childScopes.clear(); childScopes = null; } if (symbolTable != null && !symbolTable.isEmpty()) { joinScopes(this, newScope); } }
[ "public", "void", "replaceWith", "(", "Scope", "newScope", ")", "{", "if", "(", "childScopes", "!=", "null", ")", "{", "for", "(", "Scope", "kid", ":", "childScopes", ")", "{", "newScope", ".", "addChildScope", "(", "kid", ")", ";", "// sets kid's parent", "}", "childScopes", ".", "clear", "(", ")", ";", "childScopes", "=", "null", ";", "}", "if", "(", "symbolTable", "!=", "null", "&&", "!", "symbolTable", ".", "isEmpty", "(", ")", ")", "{", "joinScopes", "(", "this", ",", "newScope", ")", ";", "}", "}" ]
Used by the parser; not intended for typical use. Changes the parent-scope links for this scope's child scopes to the specified new scope. Copies symbols from this scope into new scope. @param newScope the scope that will replace this one on the scope stack.
[ "Used", "by", "the", "parser", ";", "not", "intended", "for", "typical", "use", ".", "Changes", "the", "parent", "-", "scope", "links", "for", "this", "scope", "s", "child", "scopes", "to", "the", "specified", "new", "scope", ".", "Copies", "symbols", "from", "this", "scope", "into", "new", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L97-L108
21,294
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.splitScope
public static Scope splitScope(Scope scope) { Scope result = new Scope(scope.getType()); result.symbolTable = scope.symbolTable; scope.symbolTable = null; result.parent = scope.parent; result.setParentScope(scope.getParentScope()); result.setParentScope(result); scope.parent = result; result.top = scope.top; return result; }
java
public static Scope splitScope(Scope scope) { Scope result = new Scope(scope.getType()); result.symbolTable = scope.symbolTable; scope.symbolTable = null; result.parent = scope.parent; result.setParentScope(scope.getParentScope()); result.setParentScope(result); scope.parent = result; result.top = scope.top; return result; }
[ "public", "static", "Scope", "splitScope", "(", "Scope", "scope", ")", "{", "Scope", "result", "=", "new", "Scope", "(", "scope", ".", "getType", "(", ")", ")", ";", "result", ".", "symbolTable", "=", "scope", ".", "symbolTable", ";", "scope", ".", "symbolTable", "=", "null", ";", "result", ".", "parent", "=", "scope", ".", "parent", ";", "result", ".", "setParentScope", "(", "scope", ".", "getParentScope", "(", ")", ")", ";", "result", ".", "setParentScope", "(", "result", ")", ";", "scope", ".", "parent", "=", "result", ";", "result", ".", "top", "=", "scope", ".", "top", ";", "return", "result", ";", "}" ]
Creates a new scope node, moving symbol table information from "scope" to the new node, and making "scope" a nested scope contained by the new node. Useful for injecting a new scope in a scope chain.
[ "Creates", "a", "new", "scope", "node", "moving", "symbol", "table", "information", "from", "scope", "to", "the", "new", "node", "and", "making", "scope", "a", "nested", "scope", "contained", "by", "the", "new", "node", ".", "Useful", "for", "injecting", "a", "new", "scope", "in", "a", "scope", "chain", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L130-L140
21,295
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.joinScopes
public static void joinScopes(Scope source, Scope dest) { Map<String,Symbol> src = source.ensureSymbolTable(); Map<String,Symbol> dst = dest.ensureSymbolTable(); if (!Collections.disjoint(src.keySet(), dst.keySet())) { codeBug(); } for (Map.Entry<String, Symbol> entry: src.entrySet()) { Symbol sym = entry.getValue(); sym.setContainingTable(dest); dst.put(entry.getKey(), sym); } }
java
public static void joinScopes(Scope source, Scope dest) { Map<String,Symbol> src = source.ensureSymbolTable(); Map<String,Symbol> dst = dest.ensureSymbolTable(); if (!Collections.disjoint(src.keySet(), dst.keySet())) { codeBug(); } for (Map.Entry<String, Symbol> entry: src.entrySet()) { Symbol sym = entry.getValue(); sym.setContainingTable(dest); dst.put(entry.getKey(), sym); } }
[ "public", "static", "void", "joinScopes", "(", "Scope", "source", ",", "Scope", "dest", ")", "{", "Map", "<", "String", ",", "Symbol", ">", "src", "=", "source", ".", "ensureSymbolTable", "(", ")", ";", "Map", "<", "String", ",", "Symbol", ">", "dst", "=", "dest", ".", "ensureSymbolTable", "(", ")", ";", "if", "(", "!", "Collections", ".", "disjoint", "(", "src", ".", "keySet", "(", ")", ",", "dst", ".", "keySet", "(", ")", ")", ")", "{", "codeBug", "(", ")", ";", "}", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Symbol", ">", "entry", ":", "src", ".", "entrySet", "(", ")", ")", "{", "Symbol", "sym", "=", "entry", ".", "getValue", "(", ")", ";", "sym", ".", "setContainingTable", "(", "dest", ")", ";", "dst", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "sym", ")", ";", "}", "}" ]
Copies all symbols from source scope to dest scope.
[ "Copies", "all", "symbols", "from", "source", "scope", "to", "dest", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L145-L156
21,296
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.getDefiningScope
public Scope getDefiningScope(String name) { for (Scope s = this; s != null; s = s.parentScope) { Map<String,Symbol> symbolTable = s.getSymbolTable(); if (symbolTable != null && symbolTable.containsKey(name)) { return s; } } return null; }
java
public Scope getDefiningScope(String name) { for (Scope s = this; s != null; s = s.parentScope) { Map<String,Symbol> symbolTable = s.getSymbolTable(); if (symbolTable != null && symbolTable.containsKey(name)) { return s; } } return null; }
[ "public", "Scope", "getDefiningScope", "(", "String", "name", ")", "{", "for", "(", "Scope", "s", "=", "this", ";", "s", "!=", "null", ";", "s", "=", "s", ".", "parentScope", ")", "{", "Map", "<", "String", ",", "Symbol", ">", "symbolTable", "=", "s", ".", "getSymbolTable", "(", ")", ";", "if", "(", "symbolTable", "!=", "null", "&&", "symbolTable", ".", "containsKey", "(", "name", ")", ")", "{", "return", "s", ";", "}", "}", "return", "null", ";", "}" ]
Returns the scope in which this name is defined @param name the symbol to look up @return this {@link Scope}, one of its parent scopes, or {@code null} if the name is not defined any this scope chain
[ "Returns", "the", "scope", "in", "which", "this", "name", "is", "defined" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L164-L172
21,297
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.getSymbol
public Symbol getSymbol(String name) { return symbolTable == null ? null : symbolTable.get(name); }
java
public Symbol getSymbol(String name) { return symbolTable == null ? null : symbolTable.get(name); }
[ "public", "Symbol", "getSymbol", "(", "String", "name", ")", "{", "return", "symbolTable", "==", "null", "?", "null", ":", "symbolTable", ".", "get", "(", "name", ")", ";", "}" ]
Looks up a symbol in this scope. @param name the symbol name @return the Symbol, or {@code null} if not found
[ "Looks", "up", "a", "symbol", "in", "this", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L179-L181
21,298
mozilla/rhino
src/org/mozilla/javascript/ast/Scope.java
Scope.putSymbol
public void putSymbol(Symbol symbol) { if (symbol.getName() == null) throw new IllegalArgumentException("null symbol name"); ensureSymbolTable(); symbolTable.put(symbol.getName(), symbol); symbol.setContainingTable(this); top.addSymbol(symbol); }
java
public void putSymbol(Symbol symbol) { if (symbol.getName() == null) throw new IllegalArgumentException("null symbol name"); ensureSymbolTable(); symbolTable.put(symbol.getName(), symbol); symbol.setContainingTable(this); top.addSymbol(symbol); }
[ "public", "void", "putSymbol", "(", "Symbol", "symbol", ")", "{", "if", "(", "symbol", ".", "getName", "(", ")", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"null symbol name\"", ")", ";", "ensureSymbolTable", "(", ")", ";", "symbolTable", ".", "put", "(", "symbol", ".", "getName", "(", ")", ",", "symbol", ")", ";", "symbol", ".", "setContainingTable", "(", "this", ")", ";", "top", ".", "addSymbol", "(", "symbol", ")", ";", "}" ]
Enters a symbol into this scope.
[ "Enters", "a", "symbol", "into", "this", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Scope.java#L186-L193
21,299
mozilla/rhino
src/org/mozilla/javascript/ast/LetNode.java
LetNode.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { variables.visit(v); if (body != null) { body.visit(v); } } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { variables.visit(v); if (body != null) { body.visit(v); } } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "variables", ".", "visit", "(", "v", ")", ";", "if", "(", "body", "!=", "null", ")", "{", "body", ".", "visit", "(", "v", ")", ";", "}", "}", "}" ]
Visits this node, the variable list, and if present, the body expression or statement.
[ "Visits", "this", "node", "the", "variable", "list", "and", "if", "present", "the", "body", "expression", "or", "statement", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/LetNode.java#L142-L150